LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Parse bytes to array

Hello,

 

I am working with LabVIEW 2013. I am receiving a set of raw bytes 10 times a second that contain ASCII characters:

*Time:09:05:01*Position:[-63.71,-73.581,-117.519]*Quaternions:[0.999102,-0.0025507,-0.041212,-0.00952388]*Euler:[-0.247893,-4.726448,-1.082074]

And so on. What I am trying to do is parse these bytes into an array. Essentially I need it to look for a "*" and parse the data in between each asterick. Something like this for the array:

 

Time: 09:05:01

Position: [-63.71,-73.581,-117.519]

Quaternions: [0.999102,-0.0025507,-0.041212,-0.00952388]

Euler: [-0.247893,-4.726448,-1.082074]

 

Can anyone point me in the right direction to get this started? I will also eventually need to plot this data, but one step at a time...

 

Thanks,

SM

 

0 Kudos
Message 1 of 13
(4,501 Views)

Hi SteMob,

 

put these bytes into an array of U8, then convert the array to a string.

 

Then use SpreadsheetStringtoArray with the asterisk as separator to convert the string into an array of strings, separated at the asterisks.

Then use ScanFromString to get your values from each string…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 13
(4,496 Views)

Hi Gerd,

 

So I am fairly new to LabVIEW, and it's been a little while since I have done any of this stuff. Could you maybe show me an example of this? I'm having trouble just going from array to string...

Thanks

SM

0 Kudos
Message 3 of 13
(4,491 Views)

Well it's kind of a "hack" but you could use spreadsheet string to array.

 

Parse.png

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 4 of 13
(4,489 Views)

RTSLVU,

 

How did you make the "array type" and the output array to be strings instead of doubles?

 

Thanks,

SM

0 Kudos
Message 5 of 13
(4,483 Views)

Oh, I also failed to mention, these incoming bytes are like an infinite loop, so somehow after it receives bytes for a second or so, I need to delete the old data out so my array doesn't just keep filling up with data for all eternity.


Thanks,

SM

0 Kudos
Message 6 of 13
(4,477 Views)