09-24-2012 08:47 PM
Hi, I was wondering if anyone had maybe a good a example on how to parse the following string of data that starts by a "~" char. Here is an example of the string message that will be reported ~00S008TST3;4;5~00S006TST3;5 on the serial port. I need to parse out each message starting at ~ and break each message down using the following header format below.
Header| ID |Type| Length| Data 1 byte| 2 bytes| 1 byte| 3 bytes| 128 bytes of data max
Header = The header will be a ‘~’ character.
ID = Default value is ‘00’.
Type= Command A,B,C,D or E
Length = The length is the number of bytes of data passed.
Data = All data will be separated by ‘;’. If a variable value is not currently available, a ‘;’ with no data should be placed in the variable location.
What I'd like to do is place each data message into a cluster with a byte array of data on the bottom so that I can past the cluster to another vi to process the message.
Thanks in advance.
09-24-2012 08:59 PM
09-24-2012 09:05 PM - edited 09-24-2012 09:19 PM
You could try something like this, but this is provided you will not get any ~ as data in the messages.
For the cluster I suggest you use a type definition.
09-24-2012 09:48 PM - edited 09-24-2012 09:49 PM
Thanks guys for your help. You guys sure make my life easier 😃 Brett could you repost something that's closer to Labview V11. That's what I'm using.
BTW, there will never be any ~ in the data, so this scan should work. The Data is simply separated by ";" and are all INT values. Now with the data stored in an array in the cluster, is there an easy way to typecast a cluster of datatypes over the data array so the data lines up byte by byte even if some data has odd bytes counts. For example one dataset returned might be 9;999;9999;999 and the data cluster relating to that would be input1(U8),input2(U16),input3(U16),input4(u16). I would probably have to scan the data array and load each datatype individually versus typecasting a cluster over that data array is this right?
Thanks again guys...