Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Refactor serial and I2C code. #73

Merged
merged 2 commits into from
Sep 12, 2023
Merged

Commits on Sep 6, 2023

  1. 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.
    haydenroche5 committed Sep 6, 2023
    Configuration menu
    Copy the full SHA
    88250ce View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    6afd1f7 View commit details
    Browse the repository at this point in the history