1

I'm searching a way to convert ascii data representing hex values to binary files. In detail, all communication on a serial port to a connected def vice (in this case a GPS receiver) is been logged by converting the hex values to strings. What I'm looking for is a way to convert this data back to binary data. Basically I'm able to do this running HxD editor and past the string extracted from the log. HxD representation of 2 line logged

What I would like to do is being able to do this on command line to not need manually to copy/paste the test to the hex editor.

The lines always start wi B562 followed by values e.g. 06 which in such case should result in an output (represented as string) of 'µb.'

As an example I'm edding a file which contains the data I want to convert, and athe resulting file as it is written by the HxD editor. This resulting file can be opened and replayed by a tool provided by u.blox.com called u-center. It shows the satelite informations being recorded ... input file log01.ublox.tmp output file log01.ubx

Thanks for any support. - Wasili

4
  • Welcome on Stackoverflow. Your question would be easier to understand and answer if you were giving an example of input file and a clear specification of the expected output. For instance, what is the separator between your input records? Newlines? And what separator do you want between the output binary values? Newlines? Nothing? On how many bytes your input (output) values? What endianness? Etc. Commented Aug 28, 2018 at 13:39
  • Thanks for the hint, I edited the question and added shared files usable for this conversion Commented Aug 28, 2018 at 16:03
  • C would probably be better for this. Commented Aug 28, 2018 at 23:34
  • I know in C it is not a problem, but instead of starting coding I can also use HxD. To be able to use a command line tool I just asked if such way exists by standard tools available in Linux distributions or even better in cygwin :) Commented Aug 29, 2018 at 8:59

1 Answer 1

4

You can use the following to convert ASCII representing hex values to binary data:

xxd -r -ps log01.ublox.tmp output.ubx
Sign up to request clarification or add additional context in comments.

1 Comment

@laiki well, the answer was posted by me, and Grant kindly corrected my English ;-). BTW if you find the answer helpful, please vote for it and accept the answer by clicking on the checkmark next to the question. TIA!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.