LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to read serial reply from Instrument with \r\n termination

Solved!
Go to solution

Hello,

 

I would like to send commands to a device via a serial connection and then read the reply until the instrument sends OK.

The instrument needs two termination characters for commands and sends two for reads: \r\n.

 

Example:

Command: "&G7&S&\r\n"

Reply:

"Received &G7&S&\r\n

\r\n

OK\r\n"

 

I want to finish the program when I get back the OK.

 

Sending the command works with my program but reading the reply does not. Labview shows the error:

-1073807252, VISA:  (Hex 0xBFFF006C) An overrun error occurred during transfer. A character was not read from the hardware before the next character arrived.

 

Thank you for your help!

0 Kudos
Message 1 of 3
(4,685 Views)
Solution
Accepted by topic author Soe9

You have a data overrun happening, meaning you are not getting the data fast enough.  Since you have a clear protocol for the instrument, let's use it.

1. Enable the termination character and set it to be the Line Feed (0xA, \n).  Both of these settings are the default for the Configure Serial Port, so let's just delete those controls.

2. DO NOT USE THE BYTES AT PORT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! (Did I emphasize that enough?).  Since you are using the termination character, just tell the VISA Read to read more bytes than you ever expect in a message.  The VISA Read will stop when it reads the termination character (since you now have it enabled).

3. Get rid of the wait in the loop.  The VISA Read will determine your loop rate.  Don't slow it down.  This is the main reason you are getting the buffer overrun.

 

 



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 3
(4,665 Views)

Thank you for your help. The VI works!

0 Kudos
Message 3 of 3
(4,622 Views)