Showing results for 
Search instead for 
Did you mean: 

VISA Read Doesn't Appear to Work

Hello Good People:


I am fairly new to LabVIEW, currently trying to simulate a GNSS /GPS receiver display using a virtual COM port and VISA protocol. To test the VI, I picked a randomly created NMEA sentence in GPGGA format, and used it as a string constant as an input to VISA Write's write buffer.


In the attached screenshot, the output from the VISA Write correctly shows the byte count, but the output from the VISA Read (return count 2) is always zero. It doesn't seem to read anything that is being written to my COM port. The read buffer output is also blank. What am I doing wrong here?


Thanks a lot in advance!

Download All
0 Kudos
Message 1 of 16

A serial port is not a buffer. (EDIT: well it is, but not one FIFO buffer).


What you write should be handled by a device connected to the com port. The device should reply, and that can be received by the sender.


Or did to connect the COM Rx and Tx (2 and 3 IIRC), to create a loop? That would be required. That would have been important to mention...


If you want to create a simulator to test an application, you can use com0com to connect a virtual com port to another com port (or TCP\IP).

0 Kudos
Message 2 of 16

Almost every serial port communication problem through VISA can be usually solved after watching this video and learning what is mentioned in there.


Rolf Kalbermatter
My Blog
Message 3 of 16

Sorry, botched that link:


VIWeek 2020/Proper way to communicate over serial 

Rolf Kalbermatter
My Blog
Message 4 of 16

Ignore this

"Should be" isn't "Is" -Jay
0 Kudos
Message 5 of 16

I do not have actual physical com ports on my laptop. So I used an emulator software to create two virtual com ports (COM1 COM2) which are currently paired. My NI MAX also displays these virtual ports on the left pane. 

0 Kudos
Message 6 of 16

I’ll be watching it now. Thank you very much for this pointer.

0 Kudos
Message 7 of 16

Thank you very much. I look forward to learning from it.

0 Kudos
Message 8 of 16

@Jasper16 wrote:

Thank you very much. I look forward to learning from it.

One of the takeaways of that video is probably that you shouldn't use bytes at port (,at all or only in very specific cases).


When you write the data, it will take time to get the reply, so right after the write there are 0 bytes at port, so you'll read nothing.


It's always better to rely on end termination characters, and for NMEA, that's certainly the way to go.


Set the count to read way to high, use a reasonable time out, and let the end termination characters decide when the message is complete. 

0 Kudos
Message 9 of 16

Funny you mentioned this. I modified the code a bit to write to COM1 and put it in a producer loop. Then I created a second while loop (consumer) and made the 'read' operation to read from COM2. The data is then displayed properly. I have virtual COM ports where COM1 is paired to COM2.

0 Kudos
Message 10 of 16