LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

COM timeout occuring when I click on user interface

I am using CVI 7.0 on XP.

I have an application that is writing to and readomg from the serial port. I initiate the reading and writing through an asynchronous callback. I suspend callback timers if I have not returned from a full communication loop. I of course initiate callback timers after the loop so I can go again when the next cycle hits. My problem comes when I click on a control, numeric and text boxes are the worst, it appears that I get a COM timeout. My program will stop for x number of seconds, where X is my timeout limit on the comport.

What I really want to do is separate all userinterface activity from the communication loop. I thought the asychronous timer would do just that. But it does not
appear to be so. I also tried initiating the asychronous timer from a seperate thread, but after reading more realized this probably is not going to help since asychrounous timers really should initiate their own thread anyway.

I have looked at the commcallback2 example but don't think that is really what I need. I don't want to have to use the commcallback if I do not have to.

Has anyone ever tried starting the user inteface in its own thread? Would this help. It seems like it should be separate already.

I can send some simple example code if necessary.

Regards,

Derrick
0 Kudos
Message 1 of 5
(3,121 Views)
Derrick,

The asynchronous timer callback runs in a separate thread from the user interface thread ( http://digital.ni.com/public.nsf/websearch/2A312DC9A7750502862569A60059B4C1?OpenDocument ), so your program's threading is probably OK. Is there a control callback attached to the controls you're clicking on (numeric, text boxes) that contains significant processing? Also, could you post what code you're using within the asynchronous callback?

If you think the problem might be related to the serial port programming, you might also consider posting in the serial discussion forum as well.

David McClelland
National Instruments
0 Kudos
Message 2 of 5
(3,118 Views)
David,

I figured out the problem. I did some research on your webpage and found an article that discussed a very similar problem. I ended up installing COM callback that would set a flag when the data was recieved at the comport. Then in my loop that sends to the comport and does UIR stuff, I put a do while loop before every read that will process system events if the flag has not been set. It works great.

If anyone has a similar problem I can provide more information.

Regards,

Derrick
0 Kudos
Message 3 of 5
(3,118 Views)

Hi !

I think I have this kind of problem, but for my problem, I think I need to disable the COM callback. Do you know if it's possible and how to do that ?

In my application, the PC sends data to an other entity on the serial port, the other one send back with an acknowledge the computer receive thanks to the com callback and then send again an other date and so on ! but after some minuts, the 2nd or more ack is not received. So I want to disable the comballback (I have tryied all  thought but nothing works), and do a ComRd after my ComWrt ! It worked before i need to insall a comcallback for other stuff !

Thanks a lot,

Julie

0 Kudos
Message 4 of 5
(3,053 Views)

I've found the solution. Or more exactly, Pierre helps me on CVI Rebel Site Forum (french forum).

You just have to uninstall the callback by installing an other com callback with a null pointer : error = InstallComCallback(COMPORT, LWRS_TXEMPTY, 1, 0, 0, 0); !!!! and install the old one if you want to re use it !

0 Kudos
Message 5 of 5
(3,046 Views)