NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Strings in TestStand are being Cut at Every Occurrence of \0

Solved!
Go to solution

Hello,

 

I get a binary string from  Serial Port Read.vi:

"\00\A5"

 

TestStand String Value Test cut it after "\0

Is there a way to escape it?

 

The same Problem was here disscussed:

https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z0000019S80SAE&l=de-CH

 

I also found:

https://zone.ni.com/reference/en-XX/help/370052AA-01/tsapiref/reftopics/utility_escape_m/

 

Can anyone give my an adwise how to solve it ?

 

Attached my simple Test 

 

Greets Martin

 

 

 

Download All
0 Kudos
Message 1 of 8
(1,835 Views)

Your main issue is that strings in TestStand cannot have a NULL character.  I'm assuming this is coming from the C definition of strings (must be terminated with a NULL character).  Instead, you could use an array of bytes (String to Byte Array in your VI) and have your limit also be an array of bytes.  Another option would be to have your VI pass out the data converted to an ASCII format (ex: pass out "00A5" instead of "\00\A5").


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 8
(1,804 Views)

Hi, 

Did you try to change the type for the string parameter to binary?

Regards, 

Anand Jain

NI

 

Anand_Jain_0-1614282142910.png

 

Message 3 of 8
(1,786 Views)

Also, if you ever need to programmatically store a string with an embedded null in a TestStand variable or property, there is this: SetValBinary Method - TestStand 2019 Help - National Instruments (ni.com)

0 Kudos
Message 4 of 8
(1,768 Views)

@Anand Jain

Thanks for your help.

 

Yes I have allredy set the type to binary.

Generely it works this way.

 

but...

 

If I set to binary, I get a String something like "E@=3@J20100hULSH0:00RW0V"

Not nice...

 

I would prefer to get something like "\00\A5"

 

Greets

0 Kudos
Message 5 of 8
(1,731 Views)

@crossrulz

Thanks for your help.

 

Instead, you could use an array of bytes (String to Byte Array in your VI) and have your limit also be an array of bytes

 

Ok. But if I do it this was, i cannot use a String Value Test.

Correct?

 

Another option would be to have your VI pass out the data converted to an ASCII format (ex: pass out "00A5" instead of "\00\A5")

 

Ok. If I do it in this way, is there allredy a LabView function to do this?

What function can I use afterwards the output "string read"?

 

martin8573556_0-1614588966923.png

 

Greets

0 Kudos
Message 6 of 8
(1,727 Views)
Solution
Accepted by crossrulz

@martin8573556 wrote:

Another option would be to have your VI pass out the data converted to an ASCII format (ex: pass out "00A5" instead of "\00\A5")

 

Ok. If I do it in this way, is there allredy a LabView function to do this?

What function can I use afterwards the output "string read"?

 

martin8573556_0-1614588966923.png


I would rewrite your VI as follows.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 7 of 8
(1,718 Views)

@ 

 

Thanks for your help.

 

ok it works in this way, but...

 

the disadvantage of this solusion is, that "serialPortRead.vi" is a standart NI vi in the serial.llb.

If I make  a copy of it and rewrite it for example "serialPortRead_hex" as you suggested and d I ev I ever have to reinstall LabView "serialPortRead_hex" will be missing. Ok, I could make a local copy of it...

 

Would be nice if there would be (maybe in future) a solution in TestStand to do this.

 

At meantime I can work with this solution.

Thanks and greets Martin

0 Kudos
Message 8 of 8
(1,627 Views)