LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Error 4702 - building a regular expression to compare a VISA read

I have created a simple VI to write and read to a stepper motor controller.  The command I am sending returns the status of the home and limit switches that connect to the controller.  This is a nibble hex value.  I am trying to compare the reply string from the VISA read to a regular expression to check whether the limit switch has been activated. I am getting an error 4702 which states there is a null character in the reply string and my regular expression does not account for that.  I have read through the regular exopression help page numerous times and I have to say NI could explain that a little better (IMHO).  Anyway, I was hoping some of the VISA gurus could look at the attached VI and help me build the regular expression for the Match Regular Expression function.

 

The reply string from the controller is in the VI block and I have  labeled it as such. What I am trying to do is capture the number 15 in the reply string.  That number can be any number between 0 and 15.

0 Kudos
Message 1 of 5
(3,174 Views)

I don't know about the reg expr functions.

 

But what you could try is a string search and replace, and replace the 00 (in string display hex mode) with an empty string before feeding it to the reg ex.

0 Kudos
Message 2 of 5
(3,160 Views)
Regular expressions do not work for strings that contain NULL <\00> characters. NULL is traditionally used to terminate strings. If you want to use regular expressions on your binary data you will need to replace the NULL characters wth something else such as "<NULL>" or strip them out in order to use the regular expression.


Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 3 of 5
(3,156 Views)

Great!!  Thanks for the replies.  I'm confused with identifying the NULL character in the controller reply string.  The <\00> is that the square block at the end of the string?  There is a strange character at the beginning of the string, a "y" with two dots over it,  is that the NULL character.  When I use hyperterminal I get the same string as in the VI posted... "y/0'15" but with no square block at the end.  Which charcter is the NULL charcter in that reply string?

 

I will probably use Raven Fan's suggestion.  That's a good idea!  Thanks again for your help!!

 

CJ 

0 Kudos
Message 4 of 5
(3,139 Views)
Right click on the string indicator and select "Hex display": you will see the string as a sequence of hex numbers (2 digits for each character); then locate character 00
Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 5 of 5
(3,131 Views)