feat: add gs_usb support on Windows

candleLight, CANable, CANnectivity and cantact adapters speak gs_usb. On
Linux and macOS the kernel driver exposes them as SocketCAN interfaces, so
SavvyCAN already reached them through Qt SerialBus. Windows has no such
driver, which left those adapters unusable there.

Add a GSUSBConnection that talks to the hardware directly over WinUSB:

- one connection per physical device, one SavvyCAN bus per CAN channel
- CAN FD including BRS, plus RTR, extended IDs and error frames
- known good bit timings for 16/48/80/160/170 MHz device clocks, with a
  generic solver for clocks the tables do not cover
- hardware timestamps, unwrapped across the 32 bit rollover and anchored
  to the host clock so they line up with the rest of SavvyCAN

gs_usb multiplexes every channel over a single USB bulk IN endpoint, so a
single reader thread drains it and hands frames to the connection thread in
batches, coalescing the wakeups. That keeps one producer on the lock free
queue, which the tx echo path already writes to.

Device scans skip adapters that a live connection holds. candle_dev_open()
shares the file handle and queues read URBs immediately, so probing a device
in use would consume frames the open connection is waiting for.

connections/candle_api is an unmodified copy of the candle Windows API, LGPL
3.0 rather than MIT and only compiled into Windows builds. See its README for
provenance.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XZnuZJ7zc3e8hk6C8bGDZN
This commit is contained in:
Refuhr
2026-07-29 09:25:32 +02:00
co-authored by Claude Opus 5
parent 30328f773a
commit 3ae429ae48
19 changed files with 3157 additions and 3 deletions
+19
View File
@@ -36,6 +36,25 @@ Consult the SocketCAN documentation for details on configuring such devices.
QT also includes a "virtualcan" device type. You can use this to create a bus that will loop back anything you send to it. This is useful for testing without needing to connect any devices or load any log files.
Connecting to gs_usb Devices (Windows)
======================================
gs_usb is the USB protocol spoken by candleLight, CANable (candleLight firmware), CANnectivity,
cantact and similar open hardware adapters. On LINUX and macOS these devices are handled by the
kernel gs_usb driver and show up as ordinary SocketCAN interfaces, so use the "QT SerialBus
Devices" option there. Windows has no such driver, which is why SavvyCAN talks to them directly
over WinUSB.
Select "gs_usb", pick your device from the list, choose a bus speed and, for FD capable hardware,
tick CAN FD and pick a data rate. Multi channel adapters appear as a single connection with one
SavvyCAN bus per channel, each of which can be configured separately once the connection exists.
The device interface has to be bound to WinUSB. Recent candleLight and CANnectivity firmware
declares this itself through WCID descriptors, so Windows installs the driver automatically when
the adapter is first plugged in. Older firmware may need the WinUSB driver assigned manually with
a tool such as Zadig. If the device does not show up in the list, that binding is the first thing
to check.
Connecting to Socketcand
========================