cybercase / netmd-js

Typescript library to access NetMD MiniDisc devices
GNU General Public License v2.0
39 stars 12 forks source link

Simplify getTrackCount() response parsing #41

Closed thp closed 2 years ago

thp commented 2 years ago

Instead of reading a sized byte array (%x) and then parsing and comparing its contents, we can also read fixed constants:

  1. The 16-bit length in big endian byte order: 0006
  2. The 5 fixed bytes following: 0010000200
  3. The single byte containing the track count %b

This is untested, please make sure it actually does work before merging :)

thp commented 2 years ago

Related Python code change in minidisc-ffwd (tested, working): https://github.com/thp/linux-minidisc/commit/3cc871eb4c79781a8e3673f238aa1ef4513673c9