Add the number of the USB port in the DeviceDesc structure (#18)

This commit is contained in:
CriJonsi
2017-09-07 17:27:58 +02:00
committed by zagrodzki
parent c113a5e0de
commit 01840c1d23
3 changed files with 5 additions and 0 deletions

View File

@@ -28,6 +28,7 @@ type DeviceDesc struct {
Bus int // The bus on which the device was detected
Address int // The address of the device on the bus
Speed Speed // The negotiated operating speed for the device
Port int // The usb port on which the device was detected
// Version information
Spec BCD // USB Specification Release Number

View File

@@ -29,6 +29,7 @@ var fakeDevices = []fakeDevice{
devDesc: &DeviceDesc{
Bus: 1,
Address: 1,
Port: 1,
Spec: Version(2, 0),
Device: Version(1, 0),
Vendor: ID(0x9999),
@@ -72,6 +73,7 @@ var fakeDevices = []fakeDevice{
devDesc: &DeviceDesc{
Bus: 1,
Address: 2,
Port: 2,
Spec: Version(2, 0),
Device: Version(1, 3),
Vendor: ID(0x8888),
@@ -179,6 +181,7 @@ var fakeDevices = []fakeDevice{
devDesc: &DeviceDesc{
Bus: 1,
Address: 3,
Port: 3,
Spec: Version(2, 0),
Device: Version(1, 0),
Vendor: ID(0x1111),

View File

@@ -230,6 +230,7 @@ func (libusbImpl) getDeviceDesc(d *libusbDevice) (*DeviceDesc, error) {
dev := &DeviceDesc{
Bus: int(C.libusb_get_bus_number((*C.libusb_device)(d))),
Address: int(C.libusb_get_device_address((*C.libusb_device)(d))),
Port: int(C.libusb_get_port_number((*C.libusb_device)(d))),
Speed: Speed(C.libusb_get_device_speed((*C.libusb_device)(d))),
Spec: BCD(desc.bcdUSB),
Device: BCD(desc.bcdDevice),