@tstand wrote:
I am reading a barcode label via RS232 and barcode reader send data every 8 seconds or so (presentation mode).
Since the data is constantly being sent (even at a slow rate), I would recommend putting the reading of the serial port into a parallel loop. If you only care about the latest reading, you can use a Notifier or Global Variable to send the data to your main processing loop. If you want every reading, you should use a Queue or User Event.
Other note: DO NOT USE THE BYTES AT PORT TO DETERMINE HOW MANY BYTES TO READ!!!!!!!!!!!!!!!!!!!!!!!!!! (still now emphasized enough).
Based on your code, your instrument ends the data message with a Carriage Return (CR, 0xD, 13). You already have the VISA session set up to use this. So just tell the VISA Read to read more bytes than you expect in a message. The VISA Read will read until it reads the number of bytes you tell it, it reads the termination character, or times out. If you use the Bytes At Port like you are, you have a high risk of getting partial messages. But by telling the VISA Read to read more bytes than you expect, you are relying on that termination character and you will get the full message.
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