02-23-2011 10:52 AM
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.
Solved! Go to Solution.
02-23-2011 11:05 AM
Have you looked at Match Regular Expression
Try
S:([0-9A-F]+)
I:([0-9A-F]+)
V:([0-9A-F]+)
T:([0-9A-F]+)
02-23-2011 11:07 AM - edited 02-23-2011 11:13 AM
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)
02-23-2011 05:14 PM
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!
02-28-2011 02:19 AM
here is one possible solution:
to avoid error pop ups you have to program an error handling.
02-28-2011 08:47 AM
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.
03-01-2011 05:43 AM
@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:) )
03-01-2011 07:58 AM
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
08-18-2011 03:53 PM
@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.
Hi!
I try to do something similar.
Can somebody post vi seen above?
thanks!
08-22-2011 04:27 PM
Hello!
Here is a template of that .jpg you posted. Hope this helps!
Jordan