Skip to content

Fix/kisswrapper singleflight sethardware#71

Draft
agessaman wants to merge 7 commits into
pyMC-dev:devfrom
agessaman:fix/kisswrapper-singleflight-sethardware
Draft

Fix/kisswrapper singleflight sethardware#71
agessaman wants to merge 7 commits into
pyMC-dev:devfrom
agessaman:fix/kisswrapper-singleflight-sethardware

Conversation

@agessaman
Copy link
Copy Markdown
Contributor

This has two categories of fixes raised by wo0f's G2 issues. The first is the intermixing of signals. This implements single flight command execution to prevent race conditions that we were seeing.

It also handles modem disconnect and re-enumeration by marking the modem as degraded and attempting a reconnect. It allows a brief warm-up period in case the modem lost power and needs to reinitialize the KISS modem firmware.

This is a work in progress, and I'm still working with wo0f to ensure that this is resilient against the issues he is experiencing.

Before merging it will at least need the test firmware ids pulled out.

agessaman added 7 commits May 15, 2026 18:39
- Introduced a set of allowed responses for SetHardware commands to handle legitimate OK responses.
- Implemented single-flight command execution to prevent race conditions during concurrent requests.
- Updated methods to accept an optional timeout parameter for better control over response waiting.
- Enhanced response queue management to handle late or out-of-order responses effectively.
- Added tests to ensure correct behavior of command responses and timeout handling.
- Added a serial write lock to ensure atomic writes across threads, preventing interleaving of frame bytes during concurrent operations.
- Updated the _write_frame method to utilize the new lock, enhancing reliability in multi-threaded environments.
- Introduced tests to verify that UART writes from different callers do not overlap, ensuring data integrity during transmission.
- Changed the version from "1.0.10" to "1.0.10-agdev" in both pyproject.toml and __init__.py to reflect the current development status of the project.
- Added mechanisms for managing degraded connection states, including flags for degraded status and reasons.
- Implemented a reconnect worker to handle automatic reconnection attempts after connection failures.
- Updated the connect and disconnect methods to properly manage connection states and thread handling.
- Enhanced error handling during serial communication to ensure robust operation in multi-threaded environments.
- Introduced tests to validate the new reconnect behavior and degraded state management.
…d safety

- Updated connection handling to set `is_connected` based on the success of the handshake process.
- Enhanced thread conditions in the RX and TX workers to check for the serial connection's readiness.
- Modified the `configure_radio` method to validate the serial connection state before proceeding.
- Added tests to ensure correct behavior of connection states during connect and reconnect operations.
- Changed the version from "1.0.10-agdev" to "1.0.10.dev1" in both pyproject.toml and __init__.py to indicate a new development iteration.
- Introduced new parameters for post-connect settling and configuration retries to improve connection robustness.
- Implemented retry logic for the `configure_radio` method, allowing for transient failures during configuration attempts.
- Added tests to validate the new retry behavior and ensure correct connection state management during configuration.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant