Skip to content

Commit

Permalink
[skip-ci] feat: Refactor serial and I2C code.
Browse files Browse the repository at this point in the history
- 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
haydenroche5 committed Sep 1, 2023
1 parent 93927f5 commit e7305e6
Show file tree
Hide file tree
Showing 3 changed files with 203 additions and 219 deletions.
Loading

0 comments on commit e7305e6

Please sign in to comment.