LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Re: Match regular expression Escape

Solved!
Go to solution

Hello, I would join this auhtor's question with my escape character issue.

I need parse serial communication, where some characters are used for control the communication. But thay may occur also in payload data, so escape character is used as prefix.  (ESC)(restricted_characted). In this protocol escape is value 0x1F. control values are 0x1A to 0x1E

 

How I can easily "cleanup" recieved string, from ESC characters (thay may occur 0 to N-occurences) ?

 

Example

0x1A 0x03 0x02 0x1F 0x1B 0x1A 0x1B

here escape character tells that ending character 0x1B is earlier, so physically datagram is 0x1A 0x03 0x02 0x1B 0x1B (bold are controls)

 

Thanks you

LPR

0 Kudos
Message 1 of 5
(2,365 Views)

Hi LPR,

 

I moved your message into your own threasd because your problem is slightly different…

 

Basically you want to filter those escape chars from your message: just do so!

What have you tried and where are you stuck?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 5
(2,357 Views)
Solution
Accepted by KPr_HW

Finally I solved problem by right sorting and logic of packet processing.

  • Firstly I detect end of packet, that should contain END character, but not ESC character before. For that I use "Match pattern" wtih REGEX [^\xDA][\xB0].
  • Then I parse begining of packet (START character)
  • And last thing I remove ESCape character by "Search and Replace String".

I hope, it can help somebody else with processing, parsing packets.

 

KP

 

Message 3 of 5
(2,297 Views)

Holy cow, I hate parsing serial strings of this nature.  It's never nice and clean.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 4 of 5
(2,277 Views)
Solution
Accepted by KPr_HW

@KPr_HW wrote:

Finally I solved problem by right sorting and logic of packet processing.

  • Firstly I detect end of packet, that should contain END character, but not ESC character before. For that I use "Match pattern" wtih REGEX [^\xDA][\xB0].
  • Then I parse begining of packet (START character)
  • And last thing I remove ESCape character by "Search and Replace String".

I hope, it can help somebody else with processing, parsing packets.

 

KP

 


That's a good way. Or convert the string to an array of chars/U8 and flag if 1F is found. If so, the next character should be included 'as is' (and all standard ones, ofc). If End character is found, break loop and send out the resulting string.

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 5 of 5
(2,260 Views)