mirror of
https://github.com/pybricks/pybricks-code.git
synced 2026-07-28 04:08:05 +00:00
usb/sagas: always set configuration
On some OSes, like macOS, the configuration may not be selected, so we need to make sure it is always set.
This commit is contained in:
committed by
David Lechner
parent
6fc327a917
commit
c6302232e3
+10
-11
@@ -161,17 +161,16 @@ function* handleUsbConnectPybricks(hotPlugDevice?: USBDevice): Generator {
|
||||
return;
|
||||
}
|
||||
|
||||
// REVISIT: For now, we are making the assumption that there is only one
|
||||
// configuration and it is already selected and that it contains a Pybricks
|
||||
// interface.
|
||||
assert(
|
||||
usbDevice.configuration !== undefined,
|
||||
'USB device configuration is undefined',
|
||||
);
|
||||
assert(
|
||||
usbDevice.configuration.interfaces.length > 0,
|
||||
'USB device has no interfaces',
|
||||
);
|
||||
const [, selectErr] = yield* call(() => maybe(usbDevice.selectConfiguration(1)));
|
||||
if (selectErr) {
|
||||
// TODO: show error message to user here
|
||||
console.error('Failed to select USB device configuration:', selectErr);
|
||||
yield* put(usbDidFailToConnectPybricks());
|
||||
yield* cleanup();
|
||||
return;
|
||||
}
|
||||
|
||||
assert(usbDevice.configuration !== null, 'USB device configuration is null');
|
||||
|
||||
const iface = usbDevice.configuration.interfaces.find(
|
||||
(iface) =>
|
||||
|
||||
Reference in New Issue
Block a user