LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

instrument io assistant parse hex values?

Solved!
Go to solution

My "instrument" sends out a string like this once per second:

S:09 I:002D V:0B29 T:10A9
S:09 I:002D V:0B29 T:10A9
S:09 I:002D V:0B29 T:10A8
S:09 I:002D V:0B29 T:10A9
S:09 I:002D V:0B29 T:10A9
S:09 I:0031 V:0B28 T:10A8
S:09 I:0031 V:0B28 T:10A8
S:09 I:002D V:0B29 T:10A8
S:09 I:0031 V:0B28 T:10A8

 

I want to parse this into values using instrument io assistant.

The values are hex-ascii and I don't see an option to parse that.

Also, how do I define the delimiters to have the "voltage" token read from V:xxxx ?

 

Since my instrument is a microcontroller, I can change how the data comes out if that's easier.  I chose this format because the raw output is readable on TeraTerm.

 

0 Kudos
Message 1 of 10
(3,784 Views)
Solution
Accepted by topic author pabbott

Have you looked at Match Regular Expression

 

Try

 

S:([0-9A-F]+)

 

I:([0-9A-F]+)

 

V:([0-9A-F]+)

 

T:([0-9A-F]+)

 

regexp.png

Omar
0 Kudos
Message 2 of 10
(3,778 Views)

scan from string.png

 

If you send out the data add a termination /r/n (or one of them)  and read the string with visa, and activ termination character  (set to the char)

 

 

Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


0 Kudos
Message 3 of 10
(3,775 Views)

Great.  Thanks both of you.

I actually used "scan from string" because it looks easier.

 

My next question is how to get it to ignore data that doesn't match the pattern without throwing an error.

For instance, if my instrument ouputs some other data occasionally like:

 

PowerUp

Cal:0234

S:09 I:002D V:0B29 T:10A9
S:09 I:0031 V:0B28 T:10A8
S:09 I:0031 V:0B28 T:10A8

Batt In:03 Sense:4857
S:09 I:002D V:0B29 T:10A8
S:09 I:0031 V:0B28 T:10A8

 

Thanks!

 

myserialexample.png

0 Kudos
Message 4 of 10
(3,753 Views)

here is one possible solution:

scan from string 02.png

 

to avoid error pop ups you have to program an error handling.

 

 

Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


0 Kudos
Message 5 of 10
(3,711 Views)

That is why I prefer the regular expressions instead of the scan from string because it is more flexible if you create your regular expression correctly.

 

Perl Regular Expressions

 

ReadingHex.png

Omar
Message 6 of 10
(3,698 Views)

 


@Omar II wrote:

That is why I prefer the regular expressions instead of the scan from string because it is more flexible if you create your regular expression correctly.

 


 

You are right, regex are very powerful, however this case quite simple and regex are not that easy to read.

The main solution here is to separate the first token and enter the appropriate case structure for interpretation. Using regex or scan from string is just a choice of tool (handheld multimeter or a full equipped PXI chassis:) )

Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


0 Kudos
Message 7 of 10
(3,682 Views)

Danke Henrik,

I just realized I should download your VI to see all the cases. It wasn't making sense from only the picture you posted.

I'm new to this "visual programming".  I think I still prefer C...

 

Thanks for you help!

-Paul

0 Kudos
Message 8 of 10
(3,674 Views)

@Omar II wrote:

That is why I prefer the regular expressions instead of the scan from string because it is more flexible if you create your regular expression correctly.

 

Perl Regular Expressions

 

ReadingHex.png


Hi!

 

I try to do something similar.

Can somebody post vi seen above?

 

thanks!

0 Kudos
Message 9 of 10
(3,543 Views)

Hello!

Here is a template of that .jpg you posted. Hope this helps!

 

Jordan

0 Kudos
Message 10 of 10
(3,491 Views)