Use int for Bus/Addr, not uint8.
This commit is contained in:
@@ -57,7 +57,7 @@ func parseVIDPID(vidPid string) (usb.ID, usb.ID, error) {
|
|||||||
return usb.ID(vid), usb.ID(pid), nil
|
return usb.ID(vid), usb.ID(pid), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseBusAddr(busAddr string) (uint8, uint8, error) {
|
func parseBusAddr(busAddr string) (int, int, error) {
|
||||||
s := strings.Split(busAddr, ":")
|
s := strings.Split(busAddr, ":")
|
||||||
if len(s) != 2 {
|
if len(s) != 2 {
|
||||||
return 0, 0, fmt.Errorf("want bus:addr, two 8-bit decimal unsigned integers separated by colon, e.g. 1:1")
|
return 0, 0, fmt.Errorf("want bus:addr, two 8-bit decimal unsigned integers separated by colon, e.g. 1:1")
|
||||||
@@ -70,7 +70,7 @@ func parseBusAddr(busAddr string) (uint8, uint8, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, 0, fmt.Errorf("device address must be an 8-bit decimal unsigned integer")
|
return 0, 0, fmt.Errorf("device address must be an 8-bit decimal unsigned integer")
|
||||||
}
|
}
|
||||||
return uint8(bus), uint8(addr), nil
|
return int(bus), int(addr), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -84,7 +84,7 @@ func main() {
|
|||||||
|
|
||||||
var devName string
|
var devName string
|
||||||
var vid, pid usb.ID
|
var vid, pid usb.ID
|
||||||
var bus, addr uint8
|
var bus, addr int
|
||||||
switch {
|
switch {
|
||||||
case *vidPID == "" && *busAddr == "":
|
case *vidPID == "" && *busAddr == "":
|
||||||
log.Fatal("You need to specify the device through a --vidpid flag or through a --busaddr flag.")
|
log.Fatal("You need to specify the device through a --vidpid flag or through a --busaddr flag.")
|
||||||
|
@@ -23,8 +23,8 @@ import (
|
|||||||
// Descriptor is a representation of a USB device descriptor.
|
// Descriptor is a representation of a USB device descriptor.
|
||||||
type Descriptor struct {
|
type Descriptor struct {
|
||||||
// Bus information
|
// Bus information
|
||||||
Bus uint8 // The bus on which the device was detected
|
Bus int // The bus on which the device was detected
|
||||||
Address uint8 // The address of the device on the bus
|
Address int // The address of the device on the bus
|
||||||
|
|
||||||
// Version information
|
// Version information
|
||||||
Spec BCD // USB Specification Release Number
|
Spec BCD // USB Specification Release Number
|
||||||
|
@@ -277,8 +277,8 @@ func (libusbImpl) getDeviceDesc(d *libusbDevice) (*Descriptor, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return &Descriptor{
|
return &Descriptor{
|
||||||
Bus: uint8(C.libusb_get_bus_number((*C.libusb_device)(d))),
|
Bus: int(C.libusb_get_bus_number((*C.libusb_device)(d))),
|
||||||
Address: uint8(C.libusb_get_device_address((*C.libusb_device)(d))),
|
Address: int(C.libusb_get_device_address((*C.libusb_device)(d))),
|
||||||
Spec: BCD(desc.bcdUSB),
|
Spec: BCD(desc.bcdUSB),
|
||||||
Device: BCD(desc.bcdDevice),
|
Device: BCD(desc.bcdDevice),
|
||||||
Vendor: ID(desc.idVendor),
|
Vendor: ID(desc.idVendor),
|
||||||
|
Reference in New Issue
Block a user