LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Hex command for serial communication

Solved!
Go to solution

Dear Community,

please have a look at the attached code.

For the specified inputs n1=20 and n2=21 I need the string output indicator to be:

020D140D150D (hex display)

instead i get

020D31340D31350D.

How can I achieve that?

Thanks in advance

0 Kudos
Message 1 of 7
(788 Views)
Highlighted
Solution
Accepted by topic author labviewette

Don't convert the numbers to a string. Just create the byte array and then use "byte array to string"
answer.png


Certified LabVIEW Architect
0 Kudos
Message 2 of 7
(774 Views)
Highlighted
Solution
Accepted by topic author labviewette

Personally, I like to use Replace Array Subset to build up these types of commands.


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 3 of 7
(769 Views)
Highlighted

Everyone has their favorite methods -- I prefer Format into String (right-click and look at Edit Format String and "adjust as needed").

Hex command.png

Brief explanation:  \\ means a single backslash (backslash has a special meaning, so \n is NewLine), %x means "number as hex", and ordinary characters mean themselves.

 

I have to say I don't understand why the original formulation didn't work (it wasn't something you did, as it didn't work for me, either ...).

 

Bob Schor

0 Kudos
Message 4 of 7
(755 Views)
Highlighted

@Bob_Schor wrote:

Everyone has their favorite methods -- I prefer Format into String (right-click and look at Edit Format String and "adjust as needed").

That code does not produce the desired outcome. He wants the byte data, not the ASCII string. 

 

I have to say I don't understand why the original formulation didn't work (it wasn't something you did, as it didn't work for me, either ...).

 

Bob Schor


I don't understand. Of course it doesn't work. The number is converted to a string. Maybe you didn't notice his output string indicator is set to hex display.


Certified LabVIEW Architect
0 Kudos
Message 5 of 7
(742 Views)
Highlighted

@thols wrote:

@Bob_Schor wrote:

Everyone has their favorite methods -- I prefer Format into String (right-click and look at Edit Format String and "adjust as needed").

That code does not produce the desired outcome. He wants the byte data, not the ASCII string. 

 

I have to say I don't understand why the original formulation didn't work (it wasn't something you did, as it didn't work for me, either ...).

 

Bob Schor


I don't understand. Of course it doesn't work. The number is converted to a string. Maybe you didn't notice his output string indicator is set to hex display.


Right -- I missed that detail ...

 

BS

0 Kudos
Message 6 of 7
(735 Views)
Highlighted

yep, that's right what I need.

Thanks.

0 Kudos
Message 7 of 7
(732 Views)