LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

string pattern search error

Solved!
Go to solution

Hello,

 

 

I've encountered a problem using string pattern search in labview.

I am using xbee pro modules (API mode) from digi to set up a network with 8+ nodes. Each node has a microcontroller behind it that, when requested by the lv program, sends a package in the form of 01-08-07-04-00-00-00-00-00-00-40-64;

This i would like to extract out of the received frame.

This works for all units except one. When copying the configuration and placing a different module (different addres) the problem dissapears, but i don't want to risk encountering this problem when working in the field

 

 

There are 2 api received the first one is a transmit status frame and the 2nd one is the received frame containing the data i want.

In order to do so i assemble the received frame identifier (0x90) the module address (8 bytes long), the network addres (2 bytes long) and frame number for the matching.

 

I have included the vi, you can see and choose between the working and not working data by using the control.

Also i've inluded this screenshot of the xbee datasheet to inform about the received frame format.

 

 

Can anyone see the mistake I'm making or has similar experiences?

 

Kind regards

Rob

 

 

ScreenHunter_02 Nov. 03 16.54.gif

 

 

0 Kudos
Message 1 of 4
(3,492 Views)

sorry,

 

apparently i can't eddit my previous message, but here is the correct vi (did not set the corresponding addresses as default vallue...)

0 Kudos
Message 2 of 4
(3,484 Views)
Solution
Accepted by topic author Kokodiem

Hi kokodiem

 

The problem you are having is actually related to the regular expression being used. If you check the help for the match pattern function, you will see that there is a list for 'special characters' being used. In this list, you will see that a + is being interpretted as a regular expression, rather than the "+" sign itself. In hex presentation, the + sign is represented by the 0x2B value. As this value is used in the address of the string not being formatted, it means that in your string you actually have the '+' sign, meaning that the match pattern function will interpret it as a regular expression.

 

If you do want Labview to search for the special character itself, rather then interpretting it as a regular expression, you should escape it with a \ (or in hex 0x5C). So in case for the non-formatted string, the original regular expression used was:

 

\90\00\13\A2\00@V+\E5\FF\FE\01 or hex: 9000 13A2 0040 562B E5FF FE01

 

Since the + sign has to be 'escaped', the regular expression to use should be in this case:

 

\90\00\13\A2\00@V\\+\E5\FF\FE\01 or hex: 9000 13A2 0040 565C 2BE5 FFFE 01

 

If you try the last one, you will see the string will be formatted fine.

 

You can find some more information in the following forum post. It might be quite interesting to take a look at it since it contains an example VI to automatically escape the special characters.

 

http://forums.ni.com/ni/board/message?board.id=170&message.id=51850&requireLogin=False

 

Best Regards

Michiel
Applications Engineer
NI Belgium
http://www.ni.com/ask
Message 3 of 4
(3,441 Views)
I've figured it out myself by now, but still thanks for taking your time for this problem! Smiley Wink
0 Kudos
Message 4 of 4
(3,423 Views)