Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add back product and maunfacturer for USB details on MacOS #190

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion enumerator/enumerator.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type PortDetails struct {
PID string
SerialNumber string

// Manufacturer string
Manufacturer string

// Product is an OS-dependent string that describes the serial port, it may
// be not always available and it may be different across OS.
Expand Down
16 changes: 13 additions & 3 deletions enumerator/usb_darwin.go → enumerator/usb_darwin_cgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
// license that can be found in the LICENSE file.
//

//go:build darwin && cgo

package enumerator

// #cgo LDFLAGS: -framework CoreFoundation -framework IOKit
Expand Down Expand Up @@ -70,14 +72,16 @@ func extractPortInfo(service io_registry_entry_t) (*PortDetails, error) {
vid, _ := usbDevice.GetIntProperty("idVendor", C.kCFNumberSInt16Type)
pid, _ := usbDevice.GetIntProperty("idProduct", C.kCFNumberSInt16Type)
serialNumber, _ := usbDevice.GetStringProperty("USB Serial Number")
//product, _ := usbDevice.GetStringProperty("USB Product Name")
//manufacturer, _ := usbDevice.GetStringProperty("USB Vendor Name")
//fmt.Println(product + " - " + manufacturer)

product := usbDevice.GetName()
manufacturer, _ := usbDevice.GetStringProperty("USB Vendor Name")

port.IsUSB = true
port.VID = fmt.Sprintf("%04X", vid)
port.PID = fmt.Sprintf("%04X", pid)
port.SerialNumber = serialNumber
port.Product = product
port.Manufacturer = manufacturer
}
return port, nil
}
Expand Down Expand Up @@ -220,6 +224,12 @@ func (me *io_registry_entry_t) GetClass() string {
return C.GoString(&class[0])
}

func (me *io_registry_entry_t) GetName() string {
name := make([]C.char, 128 /* the size of io_name_t */)
C.IORegistryEntryGetName(C.io_object_t(*me), &name[0])
return C.GoString(&name[0])
}

// io_iterator_t

type io_iterator_t C.io_iterator_t
Expand Down
Loading