LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

RS232 Messdaten filtern

Solved!
Go to solution

Hallo,

 

ich habe folgendes Datenprotokoll aus meiner seriellen Schnittstelle über Visa read ausgelesen:

Start Script<\r><\n><I="0A12"/><\r><\n><X1 AN="ActA1" VN="Pos" UN="%" SC="0.100" OF="0" MI="0.000" MA="100.000" TS="1"/><\r><\n><RT A="99" T="1200" C="0"/><\r><\n><D="0000000000034"/><\r><\n><D="0000000A00035"/><\r><\n><D="0000001400043"/><\r><\n><D="0000001E00063"/><\r><\n><D="0000002800087"/><\r><\n><D="00000032000AB"/><\r><\n><D="0000003C000D3"/><\r><\n><D="0000046000379"/><\r><\n><D="0000046A0037A"/><\r><\n><D="000004740037B"/><\r><\n><D="0000047E0037C"/><\r><\n><D="000004880037C"/><\r><\n><D="000004920037C"/><\r><\n><D="RTO Cnt = 0 (120,120)

 

Die Daten sind hexadezimal unter dem Tag D zischen " " zu finden, für mich relevant sind allerdings nur die letzten 4 Stellen. Bsp: D="0000000000034"      => 0034.  Ich habe bereits mit String suchen gearbeitet, allerdings erhalte ich hier immer die Fehlermeldung, dass der Eingangsstring keine Parameter im erwarteten Format (hex) enthält. 

Bin dankbar für jede Hilfe. Bei weiteren Fragen, gerne melden.

Viele Grüße

Tim


0 Kudos
Message 1 of 8
(471 Views)

Hi Tim,

 

welcome to this forum!

Please keep in mind you are using the worldwide LabVIEW forum, so you better ask in English.

Für deutschsprachige Kommunikation gibt es das www.labviewforum.de…

 

Which format does your string response use? Do you really receive those "\r"/"\n" strings as literal chars "\" and "r" (or "n") or do you receive the ASCII chars LF/CR?

 

What have you tried so far and where are you stuck?

 

This is what I get within minutes:

Best regards,
GerdW


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

Hi GerdW,

 

thanks for the fast reply. 

I receive the data in that format (the version before I copied the data from antoher program, thanks for your advice):

Start Script
<I="0A12"/>
<X1 AN="ActA1" VN="Pos" UN="%" SC="0.100" OF="0" MI="0.000" MA="100.000" TS="1"/>
<RT A="97" T="1200" C="0"/>
<D="0000000000381"/>
<D="0000000A00381"/>
<D="0000001400381"/>
<D="0000001E00381"/>
<D="0000002800381"/>
<D="0000003200381"/>
<D="0000003C00381"/>
<D="0000004600381"/>
<D="0000005000382"/>

...

I tried to find the hex data with %4x with the scan from string function, but i see that you used the match pattern function. I attached my VI file below.

Your example looks great, can you send me the VI file?

Best regards,

Tim

0 Kudos
Message 3 of 8
(435 Views)

Hi Tim,

 


@Tim970 wrote:

<I="0A12"/>
<X1 AN="ActA1" VN="Pos" UN="%" SC="0.100" OF="0" MI="0.000" MA="100.000" TS="1"/>
<RT A="97" T="1200" C="0"/>
<D="0000000000381"/>
...

I tried to find the hex data with %4x with the scan from string function, but i see that you used the match pattern function. I attached my VI file below.


ScanFromString needs an exact match of input string with format string pattern, so parsing just for "%x" will result in errors as the string starts with "<I", which clearly is not a hex-formatted number…

 


@Tim970 wrote:

Your example looks great, can you send me the VI file?


I didn't save the VI because of its simplicity. You can easily recreate it…

 

(You can also move the code inside the FOR loop into the WHILE loop. I just separated the code into two loops to show the different steps of handling the data…)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 8
(423 Views)
Solution
Accepted by topic author Tim970

Hi Tim,

 


@Tim970 wrote:

Your example looks great, can you send me the VI file?


What about this:

You need to add some error checking/handling as you can see for this "D="RTO…" data item!

 

Do you receive data from a CAN network? The header of your data reminds me on definitions in a DBC file…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 8
(413 Views)

Hi,

that looks very good, thanks. I read the date from a measuring device. I'm having the problem right now, when I try to integrate this system into my existing one, I only get " at the array outputs (see picture failure). How do I have to integrate the while block? My second question, what is the name of the block for the xFFFF bitmask?

 

Best regards,

Tim

Download All
0 Kudos
Message 6 of 8
(388 Views)

Hi Tim,

 


@Tim970 wrote:

I'm having the problem right now, when I try to integrate this system into my existing one, I only get " at the array outputs (see picture failure). How do I have to integrate the while block?


In my example I was analyzing the whole "Antwort" string, but in your implementation you only parse each single line in the message…

And in the MatchPattern function to search for the trailing quotation mark you made the mistake of using the wrong output: you search for a quotation mark and you use the output for the "match substring". Do you really wonder why you always get that quotation mark?

 


@Tim970 wrote:

My second question, what is the name of the block for the xFFFF bitmask?


It's and AND function…

(Basic LabVIEW knowledge: blue wires and blue numeric constants indicate integer data. You can see the integer datatype in the image…)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 7 of 8
(364 Views)

Hi,

 

Thank you very much for your help, I've only been using labview for a few days, so unfortunately I always make trivial errors. Your tips helped me a lot.

 

Best regards,

 

Tim

0 Kudos
Message 8 of 8
(321 Views)