12-31-2014 06:30 AM
hi all
having a bit of data manipulation trouble here.
i am receiving an ascii string over ethernet. when i displayy it as HEX code on my front panel i get the following:
1025 2C68 00AD 7640 0004 0004 1100 0077 1111 11FA
this is fine and correct. however i need to write this to a text file as well. all i get doing this is ascii "garbage"
i have tried to convert it to hex string using cast to decimal the decimal number to hex string but all i get is this (or variations depending on the representation i use for the cast):
00000000000000000000000010252C6700AD7258
im not sure what representation to use etc.
help would be appreciated
regards
12-31-2014 06:49 AM - edited 12-31-2014 06:50 AM
Use String To Byte Array followed by Number To Hex String. Throw in a Concatinate String to change the array of strings into a single string.
12-31-2014 06:55 AM
the string in is ascii. will that code still work as is?
12-31-2014 07:21 AM
You said you displayed what you got in a string that is set to hexidecimal display. That is what I gave you as the input. And that is just the display. The data doesn't matter. That code will give you a string that shows the hexidecimal representation of the data in and ASCII text format.
Have to be really careful in how we state what is hex vs ASCII. It gets confusion way too easily.
12-31-2014 09:20 AM
yes.
thats on my front panel. however it doesnt appear in the text file i write to like that. its ascii with all the missing chars etc.
i need to change the received string from the ethernet to a readable format in the text file (just like the front panel hex code thing does).
i did manage this a couple of weeks ago but have forgotten how i did it.
note that i nearly get what i want from the casting, but there are loads of leading zeros.
12-31-2014 09:33 AM
What you see in the String Out (normal) is what it iwll look like in a text file editor.
12-31-2014 09:34 AM
12-31-2014 09:37 AM
i am using type cast.
to decimal then using number to hex string.
i have just noted that my string is larger than 16 characters. but when i try and make the width bigger than16 on the number to hex string all it does is add leading zeros.
im obviously being stupid........
12-31-2014 09:41 AM
tried what you posted and that worked fine
apologoes and many thanks
12-31-2014 10:02 AM
actually spoke too soon
yes it does work, but if you get a byte of 00 it appears to strip that out and it not a part of the resultant string
ho hum