Commit 45b5199
committed
[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.1 parent 93927f5 commit 45b5199
File tree
3 files changed
+213
-210
lines changed- notecard
- test
3 files changed
+213
-210
lines changed
0 commit comments