Skip to content

Commit

Permalink
fix(uhk-usb): do the reenumeration in try-catch block
Browse files Browse the repository at this point in the history
  • Loading branch information
ert78gb committed Aug 28, 2020
1 parent 4928d5a commit d7217dd
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/uhk-usb/src/uhk-hid-device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ export class UhkHidDevice {
x.productId === enumeratedProductId);

if (inBootloaderMode) {
this.logService.misc(`[UhkHidDevice] Reenumerating devices`);
this.logService.misc('[UhkHidDevice] Reenumerating devices');
return;
}

Expand All @@ -230,8 +230,12 @@ export class UhkHidDevice {
const data = getTransferData(message);
this.logService.usb(`[UhkHidDevice] USB[T]: Enumerated device, mode: ${reenumMode}`);
this.logService.usb('[UhkHidDevice] USB[W]:', bufferToString(data).substr(3));
device.write(data);
device.close();
try {
device.write(data);
device.close();
} catch (error) {
this.logService.misc('[UhkHidDevice] Reenumeration error. We hope it would not break the process', error);
}
jumped = true;
} else {
this.logService.usb('[UhkHidDevice] USB[T]: Enumerated device is not ready yet');
Expand Down

0 comments on commit d7217dd

Please sign in to comment.