DIGImend / hidrd

HID report descriptor I/O library and conversion tool
GNU General Public License v2.0
171 stars 29 forks source link

Add an hex dump input format #2

Closed ao2 closed 10 years ago

ao2 commented 10 years ago

Hi,

what about adding a new input format to hidrd-convert so that it can read hex dumps of HID descriptors directly?

gHID (https://code.google.com/p/ghid/) calls this format "dat", it would make sense to import it directly considering that it is used in the hidrd-convert documentation too.

Thanks, Antonio

spbnick commented 10 years ago

Hi, ao2. This conversion can be easily done on the command line (with xxd -r -p) and the older wiki page was using it in the examples. Perhaps I shouldn't have removed it when making the README.md version.

However, this might be a convenience feature as people rarely store descriptors in binary.

Will an additional format, perhaps named "hex", do for you?

You will be able to use it like this:

cat descriptor.txt | hidrd-convert -i hex -o code
ao2 commented 10 years ago

I agree it is not strictly necessary but it still makes sense to have the feature built in.

'hex' is fine as the format name, thanks.

spbnick commented 10 years ago

Antonio, @ao2, could you please check out the latest master and see if the hex format works as you want it to? Thank you.

ao2 commented 10 years ago

The output is good, thanks a lot.

Maybe you can consider adding an option to control the line wrapping, but the hex output is usable already as it is.

The input parser seems to be robust enough to parse the "dat" output from gHID too, which has no starting space and no line wrapping (it's just one line of hex bytes separated by spaces).

Thanks again, Antonio

spbnick commented 10 years ago

Thanks for testing, Antonio. I'll add an output width control option.

ao2 commented 10 years ago

Good, thanks.

Now gHID can even read the output produced by hidrd-convert -o hex --oo width=0, the leading white space gives no problem.

spbnick commented 10 years ago

Great :)!