Share Binary Data Containing Multiple NULL '\0' Characters to a TestStand Local Variable
Primary Software: TestStand
Primary Software Version: 3.0
Primary Software Fixed Version: N/A
Secondary Software: N/A
Problem: I am trying to write binary data to a String property value in TestStand from my test code module, but when I look at the value in TestStand after the module completes, everything after the first NULL is missing.
Solution: If you want to share binary data that contains multiple NULL ('\0') characters between a TestStand test code module and the TestStand environment you should set up an array of numbers in your sequence file that will hold the data regardless of its type within your code module. For instance, if you want to pass an array of characters from a C-style DLL function back to a TestStand local variable, you should create a local variable that is an array of numbers in your sequence that will ultimately hold the data that the code module writes.
Since a numeric value in TestStand is a generic 32-bit maximum numeric type it can hold any standard numeric data type whether it is an integer, char, or floating point value at any given time. When using numeric values, the only constraint is its 32-bit width.
If you want to share binary data that contains multiple NULL ('\0') values between a code module and TestStand, you should not use a String data type as the TestStand storage mechanism. A String in TestStand follows the premise that a C-style string ends with the first instance of a NULL character. If you pass a String value as a parameter, and then attempt to write data that contains multiple NULLs to the String's data space, TestStand will truncate everything after the first NULL when storing the value in the String property. You should instead create a Numeric Array in TestStand, as no special treatment will be given to NULL values (to the numeric array they are just zero values).
For an example of actually sharing a TestStand local array variable with a test code module, consider the following: The code snippet below is a C function residing in a DLL that can be called in a DLL Flexible Prototype Adapter Action step. The function takes as a parameter an array of shorts (notice again that the data type doesn't matter, just the size of the memory space taken up by the array):
void __declspec(dllexport) __stdcall write(char num)
If in the "Specify Module..." dialog for the Action step that calls this DLL function you were to specify that a TestStand sequence local array variable be passed to the function for storing data into it, you could actually specify that the buffer be passed as several different data types. For instance, if the local variable array contains 5 indices, you would have to specify that it is a 32-bit value type (i.e. long) in order to keep the function from overstepping its bounds, since 5 X 4 bytes equals 20 bytes (which is required inside the function). If the local variable array actually contained 10 indices, you could either specify that it is an array of longs or shorts, because both would be sufficient to store 20 bytes of data.
Note: You also have control over the size of the temporary buffer that TestStand uses to pass property values as parameters to test code modules. Read Chapter 13 of the TestStand User Manual about "String Parameters" and "Array Parameters" under the section titled "DLL Flexible Prototype Adapter" for more information.
Note: The information above pertains to any type of test code module including LabVIEW VIs that need to share binary data with TestStand.
Report Date: 05/22/2002
Last Updated: 09/29/2017
Document ID: 2LLF0EEV