LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

COM Port blocking

I'm writing a program in LabWindows 5.5.1 and I've been having problems with the COM Ports. I have COM Port 1 setup to read data at 1200 baud anytime there is data in the input Q using a callback. At the momement this callback is being run in the same thread as the GUI, I will change it to run in it's own thread very soon. I'm using COM Port 2 to send GPS Data at 38.4 kBaud using an AsyncTimer at a rate of 10Hz. I have the ability to turn ON/OFF the GPS but COM 1 is always waiting for data using the callbacks.

The GPS data is transmitted to a device that reads the GPS data and sends out a status message that I read on COM 1. If the device is receiving GPS data it transmits a status message that's 35 bytes long at the rate the GPS data is received,
10 Hz. This cannot be changed. If the device is NOT receiving a GPS message it sends out a status message that's 232 bytes long at a rate of 2 seconds.

This setup work fine when I'm NOT sending GPS data and the longer status message is being transmitted. Once I turn on the GPS messages, I cannot read anything from COM 1 but COM 2 continutes to transmits. I have confirmed this using debugging statements in the COM 1 Callback when it reads the buffer. InQLen() returns a number > 0 but when I try to read out the data in the buffer using ComRd(1,Buffer,InQLen), I get an empty buffer.

This leads to me to believe that COM 2 is somehow blocking the reading of COM 1 since they are occuring at the same rate. Am I correct? If so how can I resolve this problem? I need to be able to read both COM Ports at the same time in order for my program to work correctly. If you'd like any more details about what I'm doing to help you answer my problem just ask.
Thanks in advance.

Stev
e
0 Kudos
Message 1 of 2
(2,609 Views)
Hello Steve,

Interesting problem. You should be able to write and read simultaneously from different COM ports with no interference; I tried it here just to be sure. What do you mean by "10Hz"? Are you writing something to the port every 100ms?

I would try simplifying the problem by paring down the code to just do the serial-related calls, and then using loopbacks on the serial ports to eliminate any possible device-oddities. (A loopback connector connects pins 2-3 assuming you're not using hardware flow control).

Is any of this on a third-party serial card, or are these COM ports on the motherboard of your PC? A lot of these serial calls make system level calls and so it's possible that the system calls are actually returning odd values for InQLen() or t
he ComRd() calls. What does your rs232err global variable tell you about the return from ComRd? Maybe something went wrong there. Call ReturnRS232Error() to get the error value.

Also, I've found PortMon to be a valuable source of information about what system calls are being made and the result of those calls. You can find more information about it here: http://www.sysinternals.com/ntw2k/freeware/portmon.shtml

Scott B.
Applications Engineer
National Instruments
0 Kudos
Message 2 of 2
(2,609 Views)