When I read from my serial port, LabVIEW continuously polls for data until the data is available on the port. This increases my processor and resource usage and prevents other loops in my program from executing smoothly. How can I prevent this?
This issue can be resolved by using VISA events. A VISA event can be generated when a serial character arrives at the port using the VISA Enable Event function. Within a while loop, you can then place a VISA Wait on Event function before the VISA Read function.The VISA Read will be executed only when a character is received at the serial port. Until the data arrives at the serial port, the thread containing the VISA Wait on Event function is suspended. Therefore, the VISA Read function is executed only when data is available at the port. By specifying the number of bytes to read as 1, you ensure that the serial port is polled only when data is available. Before the program stops, a VISA Disable Event function is used to close the event before closing the VISA session.
These functions can be found in LabVIEW on the block diagram functions palette by browsing to: Instrument I/O»VISA» Advanced»Event Handling.
For more information on the VISA Wait on Event function, please refer to the LabVIEW Help.
Thank you for your feedback.
You changed your response to Not Helpful
You changed your response to Helpful
Timeout on VISA Wait On Event Even Though the Event Has Occurred
VISA Wait on Event Function
Collaborate with other users in our discussion forums
A valid service agreement may be required, and support options vary by country.