Replace tty0tty with a USB/IP CP2102 simulator - #121
Merged
Merged
Conversation
GitHub's Azure kernels ship no USB serial drivers, so the emulated CP2102 had nothing to bind to. Build usbserial and cp210x out of tree from the matching upstream sources, and build the emulator once per push instead of once per Python version.
… the simulation per USB frame
puddly
force-pushed
the
puddly/usbip-cp2102
branch
from
September 27, 2026 14:34
70e5a6c to
705987e
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #121 +/- ##
==========================================
+ Coverage 93.11% 94.13% +1.01%
==========================================
Files 24 24
Lines 4025 4025
==========================================
+ Hits 3748 3789 +41
+ Misses 277 236 -41 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I was researching USB/IP and realized something interesting: USB/IP allows real kernel drivers to attach to fake devices exposed by userspace tools. For serialx, this allows reasonably-accurate simulation of serial hardware and lets us improve on both tty0tty and com0com.
Kernel modules like tty0tty cover the 99% use case of virtual serial ports that only need to shuttle data through a serial-ish pipe, there's no reason to be "accurate". For serialx, however, we ideally want something that behaves like a real pair of adapters connected end-to-end:
As it turns out, this is very straightforward to implement by allowing the real
cp210xkernel driver to attach to a pair of emulated USB devices connected over loopback USB/IP. The fake USB devices show up in/dev/serial/by-id/with proper metadata and pass the entire serialx test suite. All of the tty0tty test suite quirks for Linux have been removed:no-rts-cts,no-dtr-dsr,no-num-unwritten-bytes,no-reset-write-buffer,no-write-timeout,no-buffer-controlbecomes justno-reset-write-buffer.