LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Get the correct String-format for VISA Write (escape sequence code)

Hi there,

 

I'm trying to send a String-Message to a Serial (SR-232) device. The sending and receiving works. The problem is, to get the correct formatted string, that will be sent.

 

The Device is a 8x Relay Card

- The Format of a msg is 4 Bytes long with 2 bytes each for COMMAND, ADDRESS, DATA, CRC.

- CRC = XOR of the first 3 bytes

Example: "Set all relays" = "03 00 FF FC"

 

Now the problem:

Sending a String like "03 01 FF FD" is not working. I have to get the right separator between the bytes.

One way to get it right, is to do the following:

- Create a string field (user input) with Escape-Code representation and type in "\03\00\FF\FC" manually. This works.

 

But I want to generate the String programmatically. But there is no way (I'm aware of) to do this.

The "normal" representation of the '\'-Code-String "\03\00\FF\FC" would be "" (a box and "yu" with two dots above each).

 

So the bottom line is, I have 4 bytes in seperate numeric fields, that must be packed in one string so that the serial (visa) device understands it.

 

I'm very new to LabView and I hope there is a easy way to do so.

Thanks in advance!

Ingo

 

 

0 Kudos
Message 1 of 3
(3,578 Views)

You want "Byte Array to String".  You have an array of U8 integers (or you build the array), pass that array into byte array to string, and on the other side you now have a string you can pass to your VISA write.

 

You can also build the string programmatically using concatenate.  It all depends on how you are starting out.  Remember that a byte is a byte, and when you look as a string, the appearance of whether is is \03 or a crazy character is just the display setting of the string control (or constant or indicator).  All represent the ASCII character which is ETX on the ascii chart.  The \03 display is not called an escape code, but is called "\code display".  If you used hex code display then it would look like 0300 FFFC.  And password display would be ****.

0 Kudos
Message 2 of 3
(3,565 Views)

 


@Ravens Fan wrote:

You want "Byte Array to String".  You have an array of U8 integers (or you build the array), pass that array into byte array to string, and on the other side you now have a string you can pass to your VISA write.


Thank you! That did it quite easy.

 

0 Kudos
Message 3 of 3
(3,552 Views)