From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

parsing a string using an escape character.

I'm writing a vi that is parsing a fram read from the serial port in order to remove some "forbidden" characters.

It works like this: 0xC0 and 0xC1 represents BOF and EOF respectively, but might show up on other occasions.

If they do, they should be preceeded by 0x7D and have bit no 5 complemented. The same applies for the

character 7D.

 

This means:

 

C0 -> 7DE0

C1 -> 7DE1

7D -> 7D5D

 

The vi I'm trying to make is supposed to decode this. It's created from a for loop going through the string character

by character. For every character it reads two bytes into an array. If the first byte is not equal to 0x7D it is simply

passed on as outdata. If it is equal to 0x7D the second byte is complemented and passed on.

 

The problem is this: When an escape character is removed I'd like the for loop to skip ahead one step, or there

will be a missplaced extra character in the outdata. This isn't done easily

 

Pictures of the vi, in it's two different cases is provided.

Download All
0 Kudos
Message 1 of 7
(3,637 Views)

Hi Tzench,

instead of using the "i" terminal you can use a shiftregister to build your own pointer. Add one in the second case and two in the first.

 

Mike

Message Edited by MikeS81 on 01-26-2009 11:36 AM
Message 2 of 7
(3,634 Views)

Hi Tzench

I hope I correctly understood your problem. You want to replace every 7DE0 with C0 etc. For this you may use the "search and replace string" function. Se picture. This will work the other way also C0->7DE0Smiley Wink

 

Message Edited by t06afre on 01-26-2009 11:54 AM


Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
(Sorry no Labview "brag list" so far)
Message 3 of 7
(3,622 Views)
I tried this and it worked rather well, except for that for every escape character that is removed a zero is added at the end of the outdata string. Is there something simple I could do or should I change it all to a while-loop?
0 Kudos
Message 4 of 7
(3,587 Views)
This seemed like a very good solution, but I didn't get it to work properly. I entered 7DE1 as a hexadecimal numerical constant and typecast it to a string in order to use it as a search string. It didn't find and replace the string I wanted to. I suppose this is a data representation problem.
0 Kudos
Message 5 of 7
(3,582 Views)

Take a look at this example. Your task should not be a problem.

Good luck



Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
(Sorry no Labview "brag list" so far)
0 Kudos
Message 6 of 7
(3,571 Views)

Hi Tzench,

 

why not simply create a string constant, switch to "hex display" and enter "7de1" (without quotes) ???

Best regards,
GerdW


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