08-09-2023 09:14 AM
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.
08-09-2023 09:37 AM - edited 08-09-2023 09:39 AM
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.
08-09-2023 02:46 PM
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.
08-09-2023 02:47 PM
Thank you! This helped to parse the data! It was exactly what I was looking for!
08-09-2023 11:10 PM
@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