From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Fast processing of RS232 consumes too much time resulting in UI problems

Hi,

I wrote a program in CVI 6.0 which reads data from the serial port using a COM callback function. The data are received (no tx at all) in packages of 4Bytes, 700 timnes per second (115200kbaud). These data are read from the input queue bytewise (buffered reading resulted in unexpected behavior), displayed and logged in a file. This works fine. But when the serial communication is established no more button events are executed from the UI. Even when the communication has already stopped the pushed buttons are not handled. Only when there is no input during the serial data transfer (only beforehand and afterwards) the buttons are handled correctly.

I also tried to use threads and even forcing
CVI to execute UI commands resulted in an slow overall behavior.

Maybe I just didn't try the correct sequence of execution or handled the threads incorrect. Hopefully this is enough information. I would be really grateful for every hint that brings me closer to the solution.

Best regards, MairRi
0 Kudos
Message 1 of 4
(2,810 Views)
When you're in a callback function, CVI queues user interface events, but it does not process those events until you return from the callback. The ProcessSystemEvents function lets CVI (and Windows) process events from within a callback. See the online help for ProcessSystemEvents.
You may still need to use a separate thread for the comm stuff.
0 Kudos
Message 2 of 4
(2,810 Views)
Thank you for your quick replay.

Unfortunately my response is a little bit deflating, because I tried to insert an ProcessSystemEvents during the data reception and also handling this command only when the serial callback is started what led in both cases to a stack overflow (input buffer is always filled above notification level due to slow processing speed => every received byte triggers the callback).

Anyway, I can create a ThreadPool and also schedule a function. I didn't understand how to put processes to idle. Maybe this is one problem of my not working multithreading solution.

Best regards - MairRi
0 Kudos
Message 3 of 4
(2,810 Views)
Another thing you can try is, to install a Callback with the function InstallComCallback. Everytime a user defined number of characters, or a user defined specific character is received on the serial port, an event is added to the Event queue, and the callback function is executed. So you do not have to poll the COM-Port, and the USer Interface Events can be handeled properly.

Best Regards,

André
0 Kudos
Message 4 of 4
(2,810 Views)