LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

read 41, 8, or 4 bytes at serial port Wait on Event

I have a program that needs to continuously read the serial port. The messages that are sent can be 41, 8, or 4 bytes in length.

I am using the VISA Wait on Event function. Is this the way to go about this? We cannot use a termination character because it can be actual data that is being sent. I read the serial port when there are 4 or bytes.

0 Kudos
Message 1 of 3
(2,820 Views)

I've never used the VISA Wait on Event.  If dealing with binary data over the serial port, just use the Bytes At Port and read that many bytes.  I typically through in some sort of wait in there to keep the loop from dominating.

 

Do you have a good protocol of what the messages look like?  When dealing with binary data, there is typically a sync byte that you should look for and then a message ID of some sort so that you know how many bytes are in your current message.  This can be done with multiple reads or just concatinating strings and search/split string.


GCentral
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
(2,815 Views)

You're right. I am probably overthinking this.

0 Kudos
Message 3 of 3
(2,790 Views)