Add USB transport support#41
Open
cal-brmmr wants to merge 1 commit into
Open
Conversation
Add a UsbTransport for USB printer class devices (e.g. /dev/usb/lp0) that don't support TTY ioctls like tcgetattr/tcdrain. Changes: - Add src/transport/usb.rs: UsbTransport that opens devices in write-only mode, writes in chunks with flush() pacing (no tcdrain), and supports send_programs() with JOB_DELAY_MS between jobs - Add Transport trait in src/transport/mod.rs with open_transport() helper that auto-detects: rfcomm paths use BluetoothTransport, everything else uses UsbTransport - Update main.rs and all server handlers to use open_transport() instead of directly constructing BluetoothTransport This enables estrella to work with Star printers connected via USB in addition to Bluetooth RFCOMM.
Owner
|
@cal-brmmr hey! amazing work! I've authorized CI to run, I see that linting needs to be fixed, but the code looks good to me! would you mind addressing? great implementation, I like that it's automatic. |
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.
Summary
Adds a
UsbTransportfor USB printer class devices (e.g./dev/usb/lp0) alongside the existingBluetoothTransport. USB printer devices don't support TTY ioctls (tcgetattr/tcdrain), so this transport skips all TTY configuration and uses simpleflush()pacing instead.Changes
New:
src/transport/usb.rsUsbTransportstruct that opens device files in write-only modeflush()between each (notcdrain)write_all()andsend_programs()matchingBluetoothTransportinterfaceJOB_DELAY_MSpause between programs (same as Bluetooth)New:
Transporttrait insrc/transport/mod.rsBluetoothTransportandUsbTransportopen_transport(device)helper that auto-detects:rfcomm→BluetoothTransport(TTY config + tcdrain)UsbTransport(no TTY ioctls)Updated:
src/main.rs+ server handlersBluetoothTransport::open()calls replaced withtransport::open_transport()--device /dev/usb/lp0) now work automaticallyWhy
The current Bluetooth transport uses
tcgetattr/tcsetattr/tcdrainwhich fail on USB printer devices with "Inappropriate ioctl for device". USB printer class devices (/dev/usb/lp*) are not TTY devices and need a simpler write path.Testing
cargo build --release --no-default-featuresrfcommin device path)/dev/usb/lp0on a Star TSP143