Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[skip-ci] feat: Refactor serial and I2C code.
- Get rid of conditionals on transaction manager existence and if serial locking should be used by adding no-op implementations of each. - Handle serial and I2C locking with decorators, serial_lock and i2c_lock, respectively. - Add timeout functionality to I2C locking. Prior to this commit, it would spin forever if the lock couldn't be acquired. - For both serial and I2C, combine common code from Transaction and Command into an internal function, _transact. Locking happens over this function. - Migrate all freestanding serial functions to methods of OpenSerial. - Create a _read_byte abstraction for the three platforms we support (CPython, MicroPython, CircuitPython). - Merge the functionality of _preprocess_req into _prepare_request. These are always used together, so it doesn't really make sense to have them as separate functions. Additionally, have _prepare_request do everything needed to transform the request data for transmission. Namely, encode the request string as UTF-8 bytes. Finally, make _prepare_request a method of Notecard. There's no reason for it to be a free function. - Rename I2C's _send_payload to _transmit. - Move Transaction and Command into the base Notecard class. They are now fully abstracted from the underlying comms layer.
- Loading branch information