LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

If first nibble of a particular array value was zero, it was omitted in log (text) file

Solved!
Go to solution

An array of hex values are written to a log file.

 

Actual array    : 3b 6d 03 45 0f eb 12 34 45 8d 0c

Log file shows: 3b 6d   3 45   f eb 12 34 45 8d   c

 

That is if the first nibble was zero, then the second nibble alone gets printed in the log file.

Any workarounds?

 

Thanks

Mathan

0 Kudos
Message 1 of 9
(3,482 Views)

Hi Mathan,

 

Is it possible if you could upload a sample VI?

 

Thanks,

Message Edited by Mark M on 11-12-2008 11:01 AM
Best regards,

Mark M.
Applications Engineer
National Instruments UK & Ireland
0 Kudos
Message 2 of 9
(3,470 Views)

here we go

 

 

0 Kudos
Message 3 of 9
(3,457 Views)

here we go

 

 

0 Kudos
Message 4 of 9
(3,457 Views)

You should add a width of 2 to hex writer. Also change your datatype to I16 to prevent dataloss.

 

Ton

Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
Message 5 of 9
(3,451 Views)

Hi Mathan,

 

You would need to explicitly specify the width of hex string that you want them to be presented after conversion, otherwise "Number To Hexadecimal String Function" will only use the exact number of digits of the number without out padding zeros to the left.

 

You can do this by wiring a numeric constant to the "width" terminal to VI "Number To Hexadecimal String Function".

 

Please let me know if I can help further,

Best regards,

Mark M.
Applications Engineer
National Instruments UK & Ireland
Message 6 of 9
(3,449 Views)
Solution
Accepted by Mathan

... and don't forget that the inner FOR loop can be deleted without any change in outcome (don't mind the coercion dot, it's a bug).

 

You can even delete the "number to hexadecimal string" and simply use "%02x" for the format of the inner Array tho spreadsheet string. (See Image)

 

 <<<<<<<< Same thing!

 

I also don't understand the outer FOR loop. You create an array of spreadsheet strings with a space as delimiter and then write this as a spreadsheet string with tab as delimiter. I have the feeling that all this could be done more elegantly and in fewer steps.

What is the actual input? (e.g. the dimension of the blue 2D array)

How should the file look like? (delimiters for rows and columns, etc.)

 

Maybe you could just wire the blue array to "write to spreadsheet file" and use %02x as format? Try it! No loop or other code needed.

Message Edited by altenbach on 11-12-2008 07:53 AM
Message 7 of 9
(3,404 Views)

Dear christian,

 

Thanks for the solution. Working smart. Smiley Happy

 

I want to mention one thing here. Actually this conversion code was written by you only for me in some other thread started by me. I was not able to point out that thread and also that conversion is not related to that particular thread. You helped me in that case. But i forgot the solution and its a long back. Hence i started this new thread. And i will remember this anymore. Thanks a lot.

 

The thing is the array of hexadecimal numbers was an output from a particular response to a function. I need to convert this to get properly displayed in the log file. The values are something like this : 3B 6D 00 02 FE C4 7A 0F

 

I will try to locate the particular thread and attach here.

 

Thanks,

Mathan

0 Kudos
Message 8 of 9
(3,375 Views)

mathan wrote:

Actually this conversion code was written by you only for me in some other thread started by me.


I would never....!  😮   I think you are confusing me with Mike. 😄

Message 9 of 9
(3,349 Views)