Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Bytes At Serial Port.vi not read well, generally read two bytes less

I need to make an vi that works with serial comm, but I don´t want to use VISAs vi.
I need to read a variable string so I´m using the "Bytes At serial Port.vi" to know how many bytes has the word I´have to read. But it doesn´t work well. It give me two bytes less.
In the attachment file there is an simple example where I read what I write, and no read the same. Look at that read two bytes less
0 Kudos
Message 1 of 2
(3,424 Views)
I don't think you are using these VIs in a correct manner. Since the query can happen immediately after the write, you have no way of knowing that the device has returned its full response. You must ensure some sleep occurs between the write and the query.

An alternate way to do this works well if your device terminates every response with the same character, such as LF. That way you can just do a VISA Read with the maximum number of bytes you'd ever get back, and VISA will stop reading when it sees that character.

By the way, the VISA Bytes at Serial Port returns whatever the OS returns, and I can say with high confidence that this specific problem is not with those components (VISA or the OS).

Dan Mondrik
Senior Software Engineer, NI-VISA

National Instruments
Message 2 of 2
(3,424 Views)