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.
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.
12-06-2013 02:19 AM
Greetings,
I have a problem with the serial communication in my Labview program.
I have made an application that reads from serial port, searches for beggining characters, and later counts data after that beggining characters into variables in Labview program.
Everything work fine, but problem starts when I unplug the device from computer.
Program blocks and I could not do anything. Even Visa Close does not do anything.
I need to restart my computer to make my application works.
I made some indicators in subVi, and I see that when I unplug the device the error from READ VISA changes.
My question is: How to handle this event(error) to restart or unblock my serial device.
I am attaching a SubVi, that searches for starting characters " KBON,"
Best regards,
Chris
12-06-2013 02:52 AM
12-09-2013 03:17 AM
Hi Chris,
From the standpoint of VISA capabilities, you should be able to programmatically handle the desconection of the serial port. I am however not certain that your specific serial port hardware is OK with that.
As to how to handle disconnection using VISA:
I recommend using the "timeout" pin of the VISA Configure Serial Port VI
when the timeout is reached and no data is transferred, you will get a timeout error on the error wire.
You can then programmatically handle this error case in your code in a very similarly to this example.
I recommend experimenting to see what error codes your application throws, or alternatively you can use the VISA error codes documentation to create the case structures needed to hande these errors.
In all cases, you should close the VISA reference. Leaving the serial port rescource "open" in your operating system may be the reason why you need to restart your computer every time (as restarting will for sure free up the serial port rescource).