NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

define string containing NULL characters

I want to define a string containing NULL characters using an expression.
I tried the following:
FileGlobals.Command_connect=Str(0x10,"%c") + Str(0x02,"%c") + Str(0x00,"%c") + Str(0x00,"%c") + Str(0x1D,"%c") + Str(0x0F,"%c") + Str(0x10,"%c") + Str(0x03,"%c")
The FileGlobals.Command_connect should 8 characters long but when I do a Len() on the string, the result is 6 characters.
 
Anyone has an idea?
0 Kudos
Message 1 of 7
(7,519 Views)
Is this string for use with LabVIEW? If so than look in the manual "Using LabVIEW with TestStand" for the section "Calling VIs with String Parameters". If you get a binary string out from a labview VI you will see what the format looks like in TestStand (basically the non-ascii characters are escaped).

If this string is for a dll call then you should use a numeric array instead of a string and pass it into your dll as an array of 8-bit integers (i.e. char). You can set a numeric array easily in an expression as follows:

Locals.numArray = { 0x10, 0x02, 0x00, 0x00, 0x1d, 0x0f, 0x10, 0x03 }

Also, since your string is no longer NULL terminated you will need to pass a size parameter into your function as well so you know how big the array is. You can easily do this in an expression as follows:

GetNumElements(Locals.numArray)

Hope this helps,
-Doug
0 Kudos
Message 2 of 7
(7,430 Views)

I too am trying to construct a TestStand string which includes the ascii NUL character - but it is ignored. Anything else is fine.

 

Str(0x00,"%c") has no effect,  

Chr(0x00) has no effect

 

Is there any way to do this without referring to LabVIEW or a numerical array - but simply doing it in a TestStand expression as a string?

 

Thanks,

 

Ronnie

 

 

Message Edited by Believer on 11-23-2009 10:34 AM
TestStand 4.2.1, LabVIEW 2009, LabWindows/CVI 2009
0 Kudos
Message 3 of 7
(7,010 Views)

TestStand does not support embedded NULLs in strings. Depending on what you are going to be using the string for you can either:

 

1) Use an array of numbers instead.

2) If you are going to be passing the string into labview you can use an escape sequence to show where you want the NULLs to be, though there won't really be a NULL in the string until the LabVIEW adapter processes it and passes it into labview.

 

If you are directly calling a dll that takes a string with embedded NULL characters (or really binary data which is not really a string at all) I'd recommend using approach 1) and passing the array of numbers into the function as an array of type 'char'.

 

Hope this helps,

-Doug

0 Kudos
Message 4 of 7
(7,005 Views)

Thanks for the quick response Doug.

 

OK - I'm trying to write out to the serial port using serial.llb\Serial Port Write.vi

 

Even if I put an escape character in the string ("\0") in the Locals window, and change the Parameter Type to "Binary String" for the LabVIEW call, the RS232 port is still seeing 5C 30 (the ascii equivalents for "\" and "0").

 

I am looking for the RS232 port to see 00.

TestStand 4.2.1, LabVIEW 2009, LabWindows/CVI 2009
0 Kudos
Message 5 of 7
(7,002 Views)

Believer -

 

In order to pass a NULL terminating character from TestStand to LabVIEW (with the LabVIEW parameter set to Binary String) you will need to use the string: "\00". If you use "\0", the adapter will assume that you actually wanted to use a "\" and a "0" and will thus actually pass "\\0" to LabVIEW. If you use "\00" the adapter will recognize that you are intentionally sending a NULL terminating character and pass it appropriately. Please give this a try and let me know if it works for you.

 

Hope this helps.

Manooch H.
National Instruments
Message 6 of 7
(6,975 Views)
Manooch, yes that was it! Thanks!
TestStand 4.2.1, LabVIEW 2009, LabWindows/CVI 2009
0 Kudos
Message 7 of 7
(6,959 Views)