antplusbridge/cmd
Erik Brakkee 9efdfc9b83 Robustness for the USB connection.
ant: replace usb.GetDevice with direct gousb usage

Remove dependency on antgo/driver/usb to fix libusb context leaks on
device-not-found errors. The previous code called usb.GetDevice which
creates a gousb.Context via libusb_init but leaks it on every error
path (device not found, interface claim failure, etc.). Calling
ListenForTrainer repeatedly (e.g. starting with no dongle and plugging
it in later) triggered a libusb assertion in pthread_key_create because
the leaked contexts were never torn down.

Replace with direct gousb calls in ListenForTrainer, managing the
gousb.Context lifecycle explicitly. Cleanup is ordered correctly on
all paths: release interface, close device, close context, cancel
the ANT message goroutine context.

Also convert panics to returned errors for graceful retry.
2026-06-14 15:20:56 +02:00
..
bridge Robustness for the USB connection. 2026-06-14 15:20:56 +02:00