ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

build hexadecimal string into byte array

Solved!
Go to solution

My end task is to send commands over UDP to an FPGA. The commands are available in Python script.

I haven't worked with byte arrays for years and am looking for some help.

 

Attached is LoopThroughItemNumber.vi  I want to replace the hex value in column 5 to change a setting.

I manually created the array that works but am struggling with code to do the same thing. Thank you in advance for looking at this.

 

0 Kudos
Message 1 of 15
(3,058 Views)

Hi kierzie,

 

unfortunately I cannot open your VI due to its LabVIEW version, but maybe this can help you:

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 15
(3,002 Views)

Hi GerdW,

 

Your answer helped. Attached is a new file saved for LabVIEW 2021. I apologize for not thinking to do that with the first post.

 

In the 2021 version I added code to change the item number.

 

Thank you for your help!

 

kierzie

using LabVIEW 2023 on Win10/11

 

 

0 Kudos
Message 3 of 15
(2,970 Views)
Solution
Accepted by kierzie123

If I understand the problem correctly, here's what I would do:

 

 

altenbach_0-1703124616096.png

 

 

Message 4 of 15
(2,959 Views)
Solution
Accepted by kierzie123

@altenbach the scan format should be 0x%x instead of 0x%d.

Message 5 of 15
(2,949 Views)

Or this:

hs.png

"If you weren't supposed to push it, it wouldn't be a button."
Message 6 of 15
(2,926 Views)

Thank you very much! We will be using array index 5 because of the way the embedded engineers wrote their code.  What I need to change is in the second byte of the U16.

 

raphschru's advice to use 0x%x will probably work as well.

 

The replies helped me get past a huge roadblock.

0 Kudos
Message 7 of 15
(2,921 Views)

This solution works also, once I changed the array index from 4 to 5!

0 Kudos
Message 8 of 15
(2,920 Views)

@raphschru wrote:

@altenbach the scan format should be 0x%x instead of 0x%d.


Sorry yes, small typo. (Of course it does not make a difference if all numbers are very small has seen here). 😄

 

(I edited my post to avoid confusion in the future)

0 Kudos
Message 9 of 15
(2,893 Views)

Just for fun, this minimal code works too... Less pink! 😄

 

altenbach_0-1703144237574.png

 

Message 10 of 15
(2,859 Views)