Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Serial Data Read with ";"

Hi,

 

I have a device that is sending data over RS-232 and I am trying to capture this data and visually display it on the front panel for the user. 

 

The device is sending the data in the following format:

 

"HI Byte + Low Byte ;"

 

Here is what the first 8 bytes look like on putty:

 

#0B9A;0FB3;001C;01F3;

 

When the 256 bytes are sent a carriage return is used, and the data starts again from the beginning. 

 

Is it possible to serial read this data, and build a byte array to allow me to separate the data into individual data indicators? EX: 0B9A --> Temperature1; 0FB3 --> Voltage1; 001C --> Temperature2; 01F3 --> Voltage2

 

I am also fairly new to Labview so I don't know if this is at all possible, or what is the best approach to use. I appreciate any help or guidance. 

0 Kudos
Message 1 of 5
(669 Views)

This should help with the parsing of the string.

 

I first use String Subset to remove the first character.  After that, Spreadsheet String To Array will parse the data into an array.  In this case, use ";" as the delimiter, "%04x" as the format, and a 1D array of U16 as the data type.  You can use Index Array to pull out the individual elements if you need to.


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
Message 2 of 5
(664 Views)

I figured it out. 

 

For those who are reading continuous data DO NOT USE "Number of Bytes at Serial Port". 

 

Instead set the number of bytes to read way higher than the number of bytes to receive, and set the termination character you expect to see. Make sure to clear the timeout error from the visa read, and everything should work as expected. 

0 Kudos
Message 3 of 5
(624 Views)

Thank you! This helped to parse the data! It was exactly what I was looking for!

0 Kudos
Message 4 of 5
(623 Views)

@quinncook wrote:

I figured it out. 

 

For those who are reading continuous data DO NOT USE "Number of Bytes at Serial Port".


Unless you are dealing with a horrible protocol, you should never be using the Bytes At Port to tell VISA Read how much to read.  For a lot more tips on serial communication: VIWeek 2020/Proper way to communicate over serial


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 5 of 5
(602 Views)