diff --git a/enumerator/enumerator.go b/enumerator/enumerator.go index 6f0f32d..a253a17 100644 --- a/enumerator/enumerator.go +++ b/enumerator/enumerator.go @@ -15,6 +15,7 @@ type PortDetails struct { IsUSB bool VID string PID string + MI string SerialNumber string // Manufacturer string diff --git a/enumerator/usb_linux.go b/enumerator/usb_linux.go index bad2323..15b20d7 100644 --- a/enumerator/usb_linux.go +++ b/enumerator/usb_linux.go @@ -72,6 +72,10 @@ func parseUSBSysFS(usbDevicePath string, details *PortDetails) error { if err != nil { return err } + mi, err := readLine(filepath.Join(usbDevicePath, "bInterfaceNumber")) + if err != nil { + return err + } serial, err := readLine(filepath.Join(usbDevicePath, "serial")) if err != nil { return err @@ -88,6 +92,7 @@ func parseUSBSysFS(usbDevicePath string, details *PortDetails) error { details.IsUSB = true details.VID = vid details.PID = pid + details.MI = mi details.SerialNumber = serial //details.Manufacturer = manufacturer //details.Product = product diff --git a/enumerator/usb_windows.go b/enumerator/usb_windows.go index b69e115..8b5f172 100644 --- a/enumerator/usb_windows.go +++ b/enumerator/usb_windows.go @@ -18,32 +18,34 @@ import ( func parseDeviceID(deviceID string, details *PortDetails) { // Windows stock USB-CDC driver if len(deviceID) >= 3 && deviceID[:3] == "USB" { - re := regexp.MustCompile("VID_(....)&PID_(....)(\\\\(\\w+)$)?").FindAllStringSubmatch(deviceID, -1) - if re == nil || len(re[0]) < 2 { + re := regexp.MustCompile("VID_(....)&PID_(....)&MI_(..)(\\\\(\\w+)$)?").FindAllStringSubmatch(deviceID, -1) + if re == nil || len(re[0]) < 3 { // Silently ignore unparsable strings return } details.IsUSB = true details.VID = re[0][1] details.PID = re[0][2] - if len(re[0]) >= 4 { - details.SerialNumber = re[0][4] + details.MI = re[0][3] + if len(re[0]) >= 5 { + details.SerialNumber = re[0][5] } return } // FTDI driver if len(deviceID) >= 7 && deviceID[:7] == "FTDIBUS" { - re := regexp.MustCompile("VID_(....)\\+PID_(....)(\\+(\\w+))?").FindAllStringSubmatch(deviceID, -1) - if re == nil || len(re[0]) < 2 { + re := regexp.MustCompile("VID_(....)\\+PID_(....)+MI_(..)(\\+(\\w+))?").FindAllStringSubmatch(deviceID, -1) + if re == nil || len(re[0]) < 3 { // Silently ignore unparsable strings return } details.IsUSB = true details.VID = re[0][1] details.PID = re[0][2] - if len(re[0]) >= 4 { - details.SerialNumber = re[0][4] + details.MI = re[0][3] + if len(re[0]) >= 5 { + details.SerialNumber = re[0][5] } return }