From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.


Showing results for 
Search instead for 
Did you mean: 

Help with String Parsing & Tokens

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.

0 Kudos
Message 1 of 4
What have you tried? The spreadsheet string to array with a ; as a delimiter will work. For that matter, you should set the serial read to terminate on that so you would get a single data packet with each read. After that, a simple scan from string can be used. I'm not sure why you would care about the header.
0 Kudos
Message 2 of 4

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.



0 Kudos
Message 3 of 4

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...


0 Kudos
Message 4 of 4