Using COM1

Discussion about the ZBasic language including the System Library. If you're not sure where to post your message, do it here. However, do not make test posts here; that's the purpose of the Sandbox.
Post Reply
victorf
Posts: 342
Joined: 01 January 2006, 4:08 AM
Location: Schenectady, New York

Using COM1

Post by victorf »

I would like to use the download port for some testing by sending serial data to my -24 from my PC via my USB to Serial interface. The reference guide says that I can open the port as COM1 and set it to the desired configuration programmatically. If I do so, how would that effect the ability to download the test program modifications? In other words, can I still download to the -24 while the test program is running and is in control of COM1? Seems like a Catch-22 to me!

Vic
Vic Fraenckel
KC2GUI
windswaytoo ATSIGN gmail DOT com
Don_Kirby
Posts: 341
Joined: 15 October 2006, 3:48 AM
Location: Long Island, New York

Post by Don_Kirby »

The short answer is yes.

The long answer:

While the download is in progress, the com port is unavailable to read data from. As soon as the download is finished, and the processor reboots though, you can reopen the post and read data from it.

The usual sequence of events for my testing purposes goes like this:

1. program is running on ZX sending data to PC through FTDI USB-Serial converter. (Com1 on ZX)
2. PC side has Hyperterminal running to let me interact with the chip.
3. Compile new/updated code in IDE
4. Disconnect Hyperterminal from PC com port (click 'hang up')
5. Click 'Go' in IDE to download new/updated code
6. Wait for download to finish (just a few seconds)
7. Reconnect with Hyperterminal
8. Lather, rinse, repeat.

Throughout the process, there is no need to change any com port settings on either side of the transaction. Everything happens on the same physical port (whichever you choose). Hyperterminal is setup for the default ZX Com1 settings (19200, 8, N, 1), and the IDE does it's own download thing at (I think) 115Kbps.

Alternatively, you could have your program output it's data on ZX Com 2 (or any other one besides Com 1). The IDE will still use (ZX) Com 1. This of course, requires 2 serial port connections between the PC and the ZX, but will avoid having to disconnect/reconnect the port that you are using to monitor the program's output. During the program download process however, there will still be no data output from the ZX as the program is halted during the download/update process.

-Don
Don_Kirby
Posts: 341
Joined: 15 October 2006, 3:48 AM
Location: Long Island, New York

Post by Don_Kirby »

After re-reading my own post, I feel I should clarify a little.

When you start a program download, the reset line (DTR) is toggled in a very specific manner by the IDE (or ZLoad if you're using that). When the ZX sees this toggling, it automatically switches to download mode. Effectively, the com port that you have opened programmatically is closed, the chip changes to the download compatible port settings (baud rate, etc...). When the download is complete, the ZX is reset, and your new program begins running, which may or may not reopen the com port with the setttings you have chosen.

So, while both things can't happen at the same time, no specific action is required on your part except to make sure that the com port is available to the IDE (or ZLoad) on the PC.

-Don
victorf
Posts: 342
Joined: 01 January 2006, 4:08 AM
Location: Schenectady, New York

Post by victorf »

Don,

Thanks for taking the time to fill me in on this. I think that I would be able to test better if I could use two connections, but I only have hardware (USB>Serial) for one. I am sending test strings from my PC to the -24 to see how various functions handle them. Haven't been too successful yet! :(

If I am using COM1 (9600B) to send strings to the -24, can I also use COM1 to send the PC data using Debug.Print?

Any further enlightenment will be appreciated.

Vic
Vic Fraenckel
KC2GUI
windswaytoo ATSIGN gmail DOT com
Don_Kirby
Posts: 341
Joined: 15 October 2006, 3:48 AM
Location: Long Island, New York

Post by Don_Kirby »

victorf wrote:If I am using COM1 (9600B) to send strings to the -24, can I also use COM1 to send the PC data using Debug.Print?
If you have opened the port manually, by assigning input and output queues, and calling OpenCom, then yes. Although the default speed for Debug.Print is 19,200, you override that when you open Com1 with other parameters.

If this is the case, you can send data out of the '24 using any number of methods, including Debug.Print, Console.Write[line], or PutQueueStr. They all have slightly different behaviors, which are described in much detail in the system library manual.

-Don
Post Reply