LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

COM callback routine stops working

Hi,

I'm developing an app with CVI 5.0 consisting of two COM ports, each
receiving 9600 baud data and displaying it in separate text boxes. I'm
using a COM port callback function to extract the serial data and put
it into queues, and using two timers to update the text boxes with the
queued data every 250 ms. I'm installing the same serial port callback
function for both COM ports.

The application works fine for the first few lines of text. But at
random points in time after the fist few lines of received data, the
COM port callback routine will stop working for one or the other of
the COM ports (in other words, callbacks are no longer being generated
for one of the ports even though that port is still receiving serial
data.) The other
port will seemingly continue to operate normally.

Does anyone have any ideas as to why a COM callback may stop
functioning?

Thanks,
Shawn
0 Kudos
Message 1 of 4
(3,596 Views)
Shawn,
Are you using the InstallComCallback function? Are you tying both COM ports back to the same COM callback? If they are both ties to the same callback, I would look at sending them to different callbacks, to reduce your chance at error. You might also want to increase the time delay for the timers that are running to update the textboxes, because two of those running at delays of 250ms might be enough to slow down system performance to the level that you may miss a COM read. Are you doing any other type of .uir events other than what you have mentioned at the same time as these COM events?
I think a great overall option here would be to look into multithreading, and see if you can break down processor times better. You can find information on mult
ithreading here:
http://digital.ni.com/manuals.nsf/websearch/E6AC754434055C0386256694004F482E?OpenDocument&node=132100_US

Daniel McChane
Application Engineering
National Instruments
0 Kudos
Message 2 of 4
(3,596 Views)
Daniel,

I've resolved my problem. I was using interrupts using the
LWRS_RECEIVE mask and had set the interrupt threshold to 1 character.
Apparently I didn't always completely clear out the receive queue
(i.e. take it below the interrupt threshold of 1 character) before
exiting the callback. I believe if this is what caused the callback
routine to stop functioning.

I changed the mask to LWRS_RXCHAR which interrupts on every character
and all appears to be well.

I did however heed your advice about multithreading and have installed
async timers to update my console windows rather than using the
intrinsic CVI timer control. The screen updating is much less choppy
now.

Thanks,
Shawn
0 Kudos
Message 3 of 4
(3,596 Views)

Hi Shawn.

 

I am trying to write a COM call back routine kinda like what you have described but I am having difficuly with the receive port section.

Is your code available or could you look at mine?

 

Thanks, Brad.

0 Kudos
Message 4 of 4
(3,290 Views)