Please consider adding channel labels to the binary export format documented here with the next format version bump. I frequently run offline analysis of binary dumps but currently have to maintain separate records of channel names.
It would be fine if these were truncated at some maximum length, to preserve straightforward offset calculations.
It would be nice if the binary export format could include the metadata, perhaps as a separate file with a defined format. For this project the meta.json is being extracted from the .sal file and used directly, but an official mechanism would be ideal!
master ← wohali:feat/add-sal-support
opened 03:21AM - 06 May 26 UTC
HI Len, thank you so much for `readtape`! This has been valuable for recovering … important-to-me but not necessarily important-to-the-world 9 track data.
I'd like to contribute back to the project, if that's OK! I have added support to readtape for direct processing of Saleae Logic v2.x binary export data.
This support relies on the presence of an additional metadata file, `meta.json`, which is trivially extractable from the saved Saleae `.sal` data capture using any unzip utility. The json file maps device channel numbers to capture filenames, and can also provide useful metadata for the readtape process, such as bpi, ips, datetime of data capture, start and end times within the full data capture session, comments, and so on.
As the new workflow bypasses `csvtbin`, I have also added the `-starttime`, `-endtime` and `-scale` arguments to readtape itself. These have been very useful, even for previously converted tbin files!
Adding this support required "vendoring" two single-file dependencies into the program, [one for JSON parsing](https://github.com/DaveGamble/cJSON), the [other for TOML parsing](https://github.com/cktan/tomlc17). Both are compatibly MIT licensed. I am hoping the TOML library can help improve overall parameter handling in the future, and would be happy to work on enhancements here if you'll allow.
Both runtime performance and disk space required show a marked improvement, including over csvtbin; see `A_saleae_performance.md` in this pull request for further detail.
I hope you like what you see! Please let me know if I can answer any questions for you.
There are a few further related changes in this pull request, some segregated into separate commits should you not wish to take them.
* I added a `.gitignore` file to ensure that build artifacts and test run data won't end up in the repo.
* I changed `PE_MAX_POSTBITS` from 40 to 41, as with my captures, readtape was incorrectly leaving the "all ones" postamble bit within the data block, resulting in every block being one byte too long (and incorrect).
* I removed the `bool` typedef as `unsigned char` in favour of `stdbool.h`. I saw your comment in `decoder.h`, and reviewed all code, but was unable to find any use of the `#define unknown 0xff` value, nor any use of a `bool` value outside of `true` (1) and `false` (0). The change was necessary for compatibility with the vendored libraries. An alternative if you prefer would be to rename `readtape`'s bool as `rt_bool` or similar.
* I've placed guards around the `#define DEBUG` and `DEBUGALL` statements so that these may be overwritten by Makefiles or other build processes without having to edit the source directly. Mostly, I did this so I didn't accidentally check in turning on DEBUG by default.