LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to start getting data properly using rs232

Solved!
Go to solution
Yes, the code does wait for 31 bytes within the timeout you set.  If your timeout is set to 10 seconds you could get half of one message and half of the next.  If your time out is smaller, an error will be generated if 31 bytes are not read within the timeout the buffer is flushed and you should read the next packet from start to end.  The reason for flushing the buffer is to discard any partial messages that may be in the buffer before reading the next message.
0 Kudos
Message 11 of 13
(1,041 Views)

When monitoring a device that is continually transmitting data, we have to expect that we will not be lucky enough to start listening inbetween packets. If we start listening half way through we should expect to find a previous message fragment waiting in the input buffer. When there are larege dealys inbetween and we now the lenght of the packet, we can use the approach above. Another way of framing your data into complete packets is to read all of the bytes at the port and then examine them for a valid frame format.

 

Read_WindMaster.PNG

 

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 12 of 13
(1,036 Views)

abdel2 wrote:

 

Raven, you method worked great! I used the exact same logic except I had to use 13 (0xd) as a termination character becase the 31-byte string I read always had 0xd at the beginning and 0xA at the end (unlike what the manual says).

 

 


Good to hear!  Yes, you are correct it should be 13 (0xD).  I forgot to look back at the manual or example string when I was working up the example.

0 Kudos
Message 13 of 13
(1,031 Views)