Skip to content

WebUSB Support#114

Draft
pd0wm wants to merge 2 commits into
mainfrom
worktree-webusb
Draft

WebUSB Support#114
pd0wm wants to merge 2 commits into
mainfrom
worktree-webusb

Conversation

@pd0wm

@pd0wm pd0wm commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

No description provided.

pd0wm and others added 2 commits June 24, 2026 16:33
- Make CanAdapter::send/recv async so async-only transports (WebUSB) and
  blocking ones (rusb/SocketCAN) share one trait. AsyncCanAdapter drives
  adapters on a dedicated thread (block_on) natively and via spawn_local on
  wasm.
- Add a generic UsbBackend trait with RusbBackend (native) and WebUsbBackend
  (wasm) impls; port the panda onto it (Panda<B>).
- Decouple USB transport from adapter: rusb-backend / webusb backend features,
  independent of adapters. panda implies rusb-backend so --features panda is
  unchanged; panda-over-WebUSB is --features panda,webusb. rusb is a not(wasm)
  target dependency. isotp/uds gated out of the wasm build. Adds a Trunk demo.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Port the PEAK PCAN-USB FD adapter onto the UsbBackend trait (Peak<B>) so it
works over WebUSB in the browser as well as rusb natively. Generalizes the
trait: control transfers take a request type + recipient (PEAK uses
Vendor/Other), write_bulk returns the written byte count (short-write
requeue), and read_bulk reports a timeout as an empty read so adapters stay
backend-agnostic. RusbBackend auto-detaches the kernel driver on open.

The web demo gains a second button to connect to a PEAK adapter, and
scripts/release_peak_usb.sh unbinds the in-kernel peak_usb driver (WebUSB
cannot detach kernel drivers) so a browser can claim the device on Linux.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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