Add WebSerial support and align SLCAN parsing behavior#387
Conversation
pavel-kirienko
left a comment
There was a problem hiding this comment.
@copilot address my comments
|
@copilot address my comments above |
Addressed in commit |
pavel-kirienko
left a comment
There was a problem hiding this comment.
@maksimdrachov The webserial driver needs to set up the SLCAN channel during initialization with the specified CAN bitrate. To initialize the channel we need to send C (to close) and then O (to reopen). See how it's done in https://github.com/dronecan/pydronecan/blob/master/dronecan/driver/slcan.py
|
Let me know if this is too sloppy, I'm not sure if I should feel bad for commiting 100% AI-written code. |
1fabc30 to
3ba5be0
Compare
- Rename _slcan.py -> _media_slcan.py (it is a medium driver, not the stack). - Import CAN wire constants from _wire.py instead of redefining them. - Hide all low-level SLCAN constants behind encode_deinit/encode_init_sequence/ classify_init_response; webserial no longer composes raw command bytes. - No default bitrate is guessed; non-standard bitrates are sent as-is. - Reset adapters in unknown states: close, settle, purge stale input, then open. - Audit exception handling; drop the unsound init RuntimeError swallow and dead CancelledError clauses. - Bump version to 2.0.0.dev3. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
🇺🇸 FOLKS — this PR? It's a BEAUTIFUL PR. Maybe the most beautiful SLCAN PR anyone has ever seen. Believe me. 🇺🇸 We took The abstraction? It was leaky. Very leaky. Sad! Now it's TIGHT — sealed up so good that The bitrate — listen to this — we used to GUESS the default. Guessing! A disaster. Now if you don't give us a bitrate, we don't make one up. And your Zubax CANFace — great adapter, tremendous adapter — gets its raw bitrate, no questions asked. Unknown-state adapters? We close, we settle, we PURGE the swamp of stale frames, then we open. No old garbage gets through. Nobody does resets like this. Exception handling — we audited it top to bottom. Found a swallow that was, frankly, unsound. GONE. Dead CI — all green. Windows, Mac, Linux. 3.11, 3.12, 3.13. WINNING everywhere. This is what happens when you do it RIGHT. Merging it. It's gonna be HUGE. 🚀 |
Adds browser-oriented WebSerial support for CAN-over-SLCAN and incorporates reviewer-requested protocol adjustments.
Implemented updates include:
Protocolwith an explicitABCfor the async serial port contract inwebserial.py.WebSerialSLCANInterface.filter()a no-op (no software filtering where no hardware filtering exists).WebSerialSLCANInterface.__repr__()formatting as requested.src/pycyphal2/can/__init__.py._slcan.pyparser behavior to remain compatible with the requested pydronecan superset expectations, including accepted frame forms and permissive timestamp-tail handling, while preserving robust malformed-input dropping semantics.