From 88a04454ae62cebba385aa74e24fc8f9786ec15c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20Monda?= Date: Wed, 6 Sep 2017 21:57:46 +0200 Subject: [PATCH] Ignore HID exception which gets thrown when the bootloader is already up. Remove noisy messages. --- packages/usb/uhk.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/usb/uhk.js b/packages/usb/uhk.js index 942120f6..549a8329 100755 --- a/packages/usb/uhk.js +++ b/packages/usb/uhk.js @@ -18,11 +18,17 @@ function getUhkDevice() { ((device.usagePage === 128 && device.usage === 129) || device.interface === 0)); if (!foundDevice) { - console.error('UHK Device not found:'); return null; } - return new HID.HID(foundDevice.path); + let hid; + try { + hid = new HID.HID(foundDevice.path); + } catch (error) { + // Already jumped to the bootloader, so ignore this exception. + return null; + } + return hid; } function getBootloaderDevice() { @@ -30,10 +36,7 @@ function getBootloaderDevice() { device.vendorId === 0x1d50 && device.productId === 0x6120); if (!foundDevice) { - console.error('UHK Bootloader not found:'); return null; - } else { - console.info(foundDevice); } return new HID.HID(foundDevice.path);