LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

is there an easier way to format strings for serial send?

I always seem to have a hard time with serial writes. When writing to flash
memory I need to send an 'A' as the two characters '41'. Not the hex 41,
but the two ascii characters. When I send I16 values I have less problem as
I can use the 'number to hexadecimal string' function. As example, I change
integer 10 to the 4 characters '000A'. Is there any other similarly simple
method to do the same for strings? I was able to make a vi to do this, but
I don't like using complex code when a simpler way could be used.
0 Kudos
Message 1 of 4
(2,759 Views)
Have you tried "String to Byte Array" Function?
Message 2 of 4
(2,759 Views)
You can do it as the following:
string -> String to byte array -> Number to Hexadecimal String (length = 2) -> Concatenate String -> Serial String.


LabVIEW, C'est LabVIEW

0 Kudos
Message 3 of 4
(2,759 Views)
Thanks. That is what I was looking for.

"Jean-Pierre Drolet" wrote in message
news:5065000000050000004BBC0000-1031838699000@exchange.ni.com...
> You can do it as the following:
> string -> String to byte array -> Number to Hexadecimal String (length
> = 2) -> Concatenate String -> Serial String.
0 Kudos
Message 4 of 4
(2,759 Views)