02-25-2021 03:48 AM
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
Solved! Go to Solution.
02-25-2021 07:00 AM
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").
02-25-2021 01:43 PM
Hi,
Did you try to change the type for the string parameter to binary?
Regards,
Anand Jain
NI
02-25-2021 05:14 PM
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)
03-01-2021 02:43 AM
@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
03-01-2021 02:57 AM
@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"?
Greets
03-01-2021 06:15 AM - edited 03-01-2021 06:16 AM
@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"?
I would rewrite your VI as follows.
03-11-2021 01:57 AM
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
06-04-2024 07:40 AM
@martin8573556 wrote:
I would prefer to get something like "\00\A5"
It is possible to achieve this solely in TestStand, but it requires skillfully juggling step looping properties, expressions, and the API. An example is in the attachment.