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.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

serial port interrupt

I am a new user of LabView. I have been working a project for a month. I can explain shortly:
I used serial visa in my application. I configure all necessary thing for using serial port (port number, baud rate, etc.)
I configured the time out also, but I do not want to use it. Because when the time out finish serial visa read the port. If there is nothing
at the port read a empty string (""). It is a problem in my application.
I want to read the port when anything written. (when a interrupt occur) 
May be it is just an easy problem but I could not find.
Thanks for your help.
0 Kudos
Message 1 of 4
(7,487 Views)
There are a couple of ways to accomplish this. You can use the VISA Bytes at Serial Port function. If the number of bytes available is 0, then you don't do a read. You can also use VISA events (Instrument I/O>VISA>VISA Advanced>Event Handling. Enable the Serial Character event and do a VISA Wait on Event.
0 Kudos
Message 2 of 4
(7,481 Views)
Thanks for your help. I tried your advice (serial event). It works, now the problem is about timeout. I defined the timeout 2000 ms. After 2000 ms finish I again read "" (null).
I want to read unconnect from any time. Only if any byte on port.
I attached my application, can you give me an other advice after looking it ?
0 Kudos
Message 3 of 4
(7,441 Views)
Horseman,
I am trying to understand exactly what you are trying to do. If I understand you correctly, your code is wait for event is timing out and then it goes ahead and tries to make a read anyways. The read then returns nothing, so you would like your code not to read at all if it times out. Is this correct? In this situation, you would want to make a case statement that would have a case for when there was characters to read, and separate case for the time out to do nothing.  Was that what you were looking to do?

Cheers,
-Marshall R
0 Kudos
Message 4 of 4
(7,424 Views)