Skip to content

Parse HID units

Peter Hutterer requested to merge whot/hid-tools:wip/parse-hid-units into master

This sits on top of #25 (closed) (mostly because I used that one to test).

This fixes various general issues with the unit parsing too, the previous code didn't parse units correctly in all cases.

This changes the human-readable decoded output to the mathematical one using the unit designations, for example the recording from #25 (closed) has a Unit report of 0x67, 0x21, 0xd1, 0xf0, 0x00 (see byte 505). This previously printed:

    Unit (Ampere^-1,Seconds^-3,Gram,Centimeter^2,SILinear)

and is now printed as

    Unit (SILinear: cm² * g * s⁻³ * A⁻¹)

The order is always the same because python guarantees a dict order matching the insert order. That the output is inverted from the previous is an implementation side-effect but for most cases we handle with hidtools the new order is the more natural output anyway (e.g. length before time is more readable as time often has a negative exponent).

Merge request reports

Loading