mirror of
https://github.com/siemens-mobile-hacks/node-serialport-bindings-cpp.git
synced 2026-11-25 18:37:19 +00:00
This change migrates to typescript. The tests have been modified to conform to typescript and to cleanup cases when they weren't actually working (only one or two cases). I've defined the existing bindings interface for all platforms. There are changes I'd love to make but didn't here (update/set/get/getBaudRate etc are messy). This should in theory be a drop in for the existing bindings. If there are bugs I imagine they're type related not functionality. I dropped abstract bindings as having it a separate package didn't make sense during the refactor. I'd like to iterate on the design a bit more before returning to that class. Mockbinding may also now be drifted slightly from this package. I'll clean those inconsistencies up when I upgrade the main repo.
42 lines
1.2 KiB
TypeScript
42 lines
1.2 KiB
TypeScript
import { assert } from '../test/assert'
|
|
import { serialNumParser } from './win32-sn-parser'
|
|
|
|
const devices = {
|
|
'FTDI Device': {
|
|
pnpId: 'FTDIBUS\\VID_0403+PID_6015+DO004ZB7A\\0000',
|
|
serialNumber: 'DO004ZB7',
|
|
},
|
|
'Arduino Mega': {
|
|
pnpId: 'USB\\VID_2341&PID_0042\\85531303630351C081D2',
|
|
serialNumber: '85531303630351C081D2',
|
|
},
|
|
'Atlas Scientific EZO-RGB Sensor': {
|
|
pnpId: 'FTDIBUS\\VID_0403+PID_6015+DJ1XJE67A\\0000',
|
|
serialNumber: 'DJ1XJE67',
|
|
},
|
|
'Gearmo FTDI2-LED USB RS-232 Serial Adapter': {
|
|
pnpId: 'FTDIBUS\\VID_0403+PID_6001+AL1WHZWFA\\0000',
|
|
serialNumber: 'AL1WHZWF',
|
|
},
|
|
'Arducam Nano V3.0 (Arduino Nano with FTDI)': {
|
|
pnpId: 'FTDIBUS\\VID_0403+PID_6001+A51MAMMEA\\0000',
|
|
serialNumber: 'A51MAMME',
|
|
},
|
|
'Pretend Device with an unknown pnp id': {
|
|
pnpId: 'WATEVER\\Whoever\\However!',
|
|
serialNumber: null,
|
|
},
|
|
'bad data': {
|
|
pnpId: undefined,
|
|
serialNumber: null,
|
|
},
|
|
}
|
|
|
|
describe('serialNumParser', () => {
|
|
for (const [device, info] of Object.entries(devices)) {
|
|
it(`parses pnp id for ${device}`, () => {
|
|
const { pnpId, serialNumber } = info
|
|
assert.equal(serialNumParser(pnpId), serialNumber)
|
|
})
|
|
}
|
|
})
|