11-12-2008 04:04 AM
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
Solved! Go to Solution.
11-12-2008 05:00 AM - edited 11-12-2008 05:01 AM
Hi Mathan,
Is it possible if you could upload a sample VI?
Thanks,
11-12-2008 05:30 AM
here we go
11-12-2008 05:30 AM
here we go
11-12-2008 05:48 AM
You should add a width of 2 to hex writer. Also change your datatype to I16 to prevent dataloss.
Ton
11-12-2008 05:50 AM
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,
11-12-2008 09:49 AM - edited 11-12-2008 09:53 AM
... 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.
11-13-2008 07:44 AM
Dear christian,
Thanks for the solution. Working smart.
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
11-13-2008 11:34 AM
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. 😄