Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make changes to support binary transfers.
- Add CRC support. - Align serial and I2C code with note-c. This encompasses mimicking the algorithms used in note-c and also things like delay lengths, number of retries, transaction timeout lengths, etc. - Align transaction logic with note-c. The majority of this work is in the reworked `Transaction` function, which is analogous to `noteTransactionShouldLock` in note-c. - Rework serial/I2C locking so that the lock can be held for the entirety of a binary transfer. For example, for a binary receive operation, the host needs to send a `card.binary.get` and then immediately receive the binary data from the Notecard. The serial/I2C lock should be held for the entirety of this operation, rather than be released after the `card.binary.get` and reacquired for the receipt of the binary data. - Add two methods for both serial and I2C: `transmit` and `receive`. `transmit` is used to transmit arbitrary bytes to the Notecard (e.g. after `card.binary.put`). `read_until_newline` is used to read a stream of bytes from the Notecard, stopping after reading a newline (e.g. after a `card.binary.get`). These are analogous to the `chunked(Receive|Transmit)` functions in note-c. - Overhaul unit testing. This commit adds many new unit tests, in addition to reorganizing things. Tests for the `Notecard` base class are in test_notecard.py. `OpenSerial` tests are in test_serial.py, and `OpenI2C` tests are in test_i2c.py. There is a some code repetition here, especially between the `_transact` and `Reset` methods of `OpenSerial` and `OpenI2C`. Again, this follows the pattern in note-c and was done consciously. We may want to factor out that repetition in the future, but for now, I'm prioritizing parity with the "source of truth" (note-c).
- Loading branch information