MadLittleMods / node-usb-detection

List USB devices in system and detect changes on them.
MIT License
371 stars 114 forks source link

Why do PID and VID differ from the ones reported by `serialport`? #128

Closed hrueger closed 3 years ago

hrueger commented 3 years ago

node-usb-detection reports this:

{
    locationId: 0,
    vendorId: 1155,
    productId: 22336,
    deviceName: 'Serielles USB-Gerät (COM12)',
    manufacturer: 'Microsoft',
   serialNumber: '0021003A4341570720323032',
    deviceAddress: 13
}

and serialports list() method reports this:

{
    path: 'COM12',
    manufacturer: 'Microsoft',
    serialNumber: '0021003a4341570720323032',
    pnpId: 'USB\\VID_0483&PID_5740\\0021003A4341570720323032',
    locationId: 'Port_#0003.Hub_#0001',
    vendorId: '0483',
    productId: '5740'
}

The serialnumber is the same, although it is uppercase in serialport.

MadLittleMods commented 3 years ago

@hrueger Which one is correct?

I'm not sure why they differ.

hrueger commented 3 years ago

@MadLittleMods Thanks for the quick reply!

I'm not sure. If I do a google search for VID 0483 and PID 5740, I find the correct device: https://devicehunt.com/view/type/usb/vendor/0483/device/5740

However, searching for VID 1155 and PID 22336, I find this: https://community.st.com/s/feed/0D50X00009XkYSESA3

On the bottom of that page, there's also something about VirtualCOMPort...

hrueger commented 3 years ago

I think that https://www.npmjs.com/package/usb returns the same VID and PID as node-usb-detection, however, I don't get a serialnumber there. Maybe your VID and PID are from the device itself and serialport's are from the serial port and not from the device itself? I don't know.

MadLittleMods commented 3 years ago

Here are the docs for SerialPort.list() for reference: https://serialport.io/docs/api-stream/#serialportlist

If we are matching what the usb package returns, that seems like we're probably doing the right thing. Still would be good to understand the difference here.

@hrueger When you are using node-usb-detection, do you see multiple devices? Is there one listed with VID 0483 and PID 5740 as well?

You're theory could be on the right track.

MadLittleMods commented 3 years ago

@hrueger It looks like serialport has their vendorId and productId in hexadecimal. Converting them to decimal, they match node-usb-detection


I was tipped off by the hex hint by https://github.com/serialport/node-serialport/issues/1652 and was confused how a number could be upper or lowercase.

Then I saw someone's example output that had 04d8 and f793 in https://github.com/serialport/node-serialport/issues/1278

hrueger commented 3 years ago

Ah, that makes sense 👍 So I can close this issue?

MadLittleMods commented 3 years ago

@hrueger :+1: Yep closed! Thanks for the quick follow-up here 😸