11-25-2020 04:35 PM
Hi all,
I am trying to parse serial HEX data from my SPS30 dust monitor. The way that I am approaching this is to use a case structure to parse data. The reason I am using this method is because the protocol of the data is SHDLC. Where the start byte is the 7E, then next byte is the address byte, 3rd is the command byte, 4th is the length byte, and then the Tx data bytes, ending with the 7E byte again. I can use the case selectors to categorize the data into bins and organize it in the way that the datasheet shows. I am having trouble with selecting the case, because the data is coming in as hex, I suspect that the case selector is in decimal or ascii and is expecting a decimal string. But, most characters from hex are just NUL so it just looks like an empty space. I looked for "Radix" to change it to hex but could not find it. Please, correct me if I'm wrong, I'm still trying to understand this. Thank you for your help!
Solved! Go to Solution.
11-25-2020 04:51 PM
What I see is that you are taking 1 character from the beginning of the string and wiring that into a case selector. For the case that you show, (if you attached an actual VI, we could see what else is going on) you are comparing it to "01".
Guess what, a 1 character string will never be equal to a 2 character string.
To change a radix to Hex, you need to set it to be selecting integers, not strings. Wind don't you take your string data and convert them to integers (e.g. Scan from String or other functions that are on String/Number conversion palette), then wire that into your case structure.
11-27-2020 08:30 AM
Use String To Byte Array and then Index Array to get the first element. When you wire that up to the case selector, you can right-click on the case structure and select Radix->Hex.
11-30-2020 12:02 PM - edited 11-30-2020 12:04 PM
Well there's a couple ways to go about this...