Skip to content

Commit 425570d

Browse files
authored
Merge pull request #120 from particle-iot/feature/sc-134606/inform-user-when-using-slow-usb
Add USB version to EDL devices
2 parents b00f0dd + 516393d commit 425570d

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

.github/workflows/ci.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,12 @@ jobs:
1717
experimental:
1818
- false
1919
node_version:
20-
- 12
21-
- 14
2220
- 16
21+
- 22
2322
steps:
2423
- uses: actions/checkout@v2
2524
- name: Setup node
26-
uses: actions/setup-node@v2
25+
uses: actions/setup-node@v4
2726
with:
2827
registry-url: 'https://registry.npmjs.org'
2928
node-version: ${{ matrix.node_version }}

src/edl-device.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ const VENDOR_ID_QUALCOMM = 0x05c6;
55
const PRODUCT_ID_EDL_DEVICE = 0x9008;
66

77
class EdlDevice {
8-
constructor({ serialNumber }) {
8+
constructor({ serialNumber, usbVersion }) {
99
this.serialNumber = serialNumber;
1010
this.id = this._computeDeviceId();
11+
this.usbVersion = usbVersion;
1112
}
1213

1314
_computeDeviceId() {
@@ -31,7 +32,7 @@ class EdlDevice {
3132
try {
3233
await dev.open();
3334
const serialNumber = dev.productName.replace(/.*_SN:/, '');
34-
return new EdlDevice({ serialNumber });
35+
return new EdlDevice({ serialNumber, usbVersion: dev.usbVersion });
3536
} finally {
3637
dev.close();
3738
}

src/usb-device-node.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,11 @@ class UsbDevice {
224224
set quirks(qs) {
225225
this._quirks = qs;
226226
}
227+
228+
get usbVersion() {
229+
const version = this._dev.deviceDescriptor.bcdUSB;
230+
return { major: version >> 8, minor: (version & 0xff) >> 4 };
231+
}
227232
}
228233

229234
async function getUsbDevices(filters) {

0 commit comments

Comments
 (0)