zabsalahid / serialport-gsm

SerialPort-GSM is a simplified plugin for communicating with gsm modems. (Primarily for sms) (Focused in PDU mode)
MIT License
88 stars 46 forks source link

USB modem shows up several times when listing #123

Closed sts-ryan-holton closed 1 year ago

sts-ryan-holton commented 1 year ago

Hi, I've installed this library onto my Raspberry Pi 4, which has four USB ports, there's nothing plugged in to any of them. When I plug my HUAWEI USB modem into one of the ports and then run:

serialportgsm.list((err, result) => {
    console.log(result)
})

The modem shows up three times, with a different path on each. Here's the output:

[
  {
    path: '/dev/ttyUSB0',
    manufacturer: 'HUAWEI',
    serialNumber: undefined,
    pnpId: 'usb-HUAWEI_HUAWEI_Mobile-if00-port0',
    locationId: undefined,
    vendorId: '12d1',
    productId: '1c05'
  },
  {
    path: '/dev/ttyUSB1',
    manufacturer: 'HUAWEI',
    serialNumber: undefined,
    pnpId: 'usb-HUAWEI_HUAWEI_Mobile-if01-port0',
    locationId: undefined,
    vendorId: '12d1',
    productId: '1c05'
  },
  {
    path: '/dev/ttyUSB2',
    manufacturer: 'HUAWEI',
    serialNumber: undefined,
    pnpId: 'usb-HUAWEI_HUAWEI_Mobile-if02-port0',
    locationId: undefined,
    vendorId: '12d1',
    productId: '1c05'
  },
  {
    path: '/dev/ttyAMA0',
    manufacturer: undefined,
    serialNumber: undefined,
    pnpId: undefined,
    locationId: undefined,
    vendorId: undefined,
    productId: undefined
  }
]

How would I know which one to connect to from here?

Apollon77 commented 1 year ago

In fact by default such devices expose several ports with special meanings. I needed to use USB2 with my stick (PCUI port) ... in fact you can try the lib with each port and you will see where it connects.

In the end sending

"^GETPORTMODE" shjould let you see which port is which

Apollon77 commented 1 year ago

(sometimes also USB0 works directly)