From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

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
(2,930 Views)
Solution
Accepted by 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
(2,916 Views)
Solution
Accepted by 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
(2,911 Views)

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
(2,897 Views)

@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
(2,884 Views)

@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
(2,877 Views)

yep, that's right what I need.

Thanks.

0 Kudos
Message 7 of 7
(2,874 Views)