libusb

package
v2.1.0+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 28, 2022 License: LGPL-3.0 Imports: 6 Imported by: 1

README

libusb go wrapper

This is a go wrapper around libusb

The code is mostly copied from https://github.com/deadsy/libusb

ALSO NOTE - there is a hardcoded device filter because of random windows errors

License

Code is under GNU LGPL 2.1.

Documentation

Overview

Package libusb provides go wrappers for libusb-1.0

Index

Constants

View Source
const (
	CLASS_PER_INTERFACE       = C.LIBUSB_CLASS_PER_INTERFACE
	CLASS_AUDIO               = C.LIBUSB_CLASS_AUDIO
	CLASS_COMM                = C.LIBUSB_CLASS_COMM
	CLASS_HID                 = C.LIBUSB_CLASS_HID
	CLASS_PHYSICAL            = C.LIBUSB_CLASS_PHYSICAL
	CLASS_PRINTER             = C.LIBUSB_CLASS_PRINTER
	CLASS_PTP                 = C.LIBUSB_CLASS_PTP
	CLASS_IMAGE               = C.LIBUSB_CLASS_IMAGE
	CLASS_MASS_STORAGE        = C.LIBUSB_CLASS_MASS_STORAGE
	CLASS_HUB                 = C.LIBUSB_CLASS_HUB
	CLASS_DATA                = C.LIBUSB_CLASS_DATA
	CLASS_SMART_CARD          = C.LIBUSB_CLASS_SMART_CARD
	CLASS_CONTENT_SECURITY    = C.LIBUSB_CLASS_CONTENT_SECURITY
	CLASS_VIDEO               = C.LIBUSB_CLASS_VIDEO
	CLASS_PERSONAL_HEALTHCARE = C.LIBUSB_CLASS_PERSONAL_HEALTHCARE
	CLASS_DIAGNOSTIC_DEVICE   = C.LIBUSB_CLASS_DIAGNOSTIC_DEVICE
	CLASS_WIRELESS            = C.LIBUSB_CLASS_WIRELESS
	CLASS_APPLICATION         = C.LIBUSB_CLASS_APPLICATION
	CLASS_VENDOR_SPEC         = C.LIBUSB_CLASS_VENDOR_SPEC
)

Device and/or Interface Class codes.

View Source
const (
	DT_DEVICE                = C.LIBUSB_DT_DEVICE
	DT_CONFIG                = C.LIBUSB_DT_CONFIG
	DT_STRING                = C.LIBUSB_DT_STRING
	DT_INTERFACE             = C.LIBUSB_DT_INTERFACE
	DT_ENDPOINT              = C.LIBUSB_DT_ENDPOINT
	DT_BOS                   = C.LIBUSB_DT_BOS
	DT_DEVICE_CAPABILITY     = C.LIBUSB_DT_DEVICE_CAPABILITY
	DT_HID                   = C.LIBUSB_DT_HID
	DT_REPORT                = C.LIBUSB_DT_REPORT
	DT_PHYSICAL              = C.LIBUSB_DT_PHYSICAL
	DT_HUB                   = C.LIBUSB_DT_HUB
	DT_SUPERSPEED_HUB        = C.LIBUSB_DT_SUPERSPEED_HUB
	DT_SS_ENDPOINT_COMPANION = C.LIBUSB_DT_SS_ENDPOINT_COMPANION
)

Descriptor types as defined by the USB specification.

View Source
const (
	ENDPOINT_IN  = C.LIBUSB_ENDPOINT_IN  // In: device-to-host.
	ENDPOINT_OUT = C.LIBUSB_ENDPOINT_OUT // Out: host-to-device.
)

Endpoint direction. Values for bit 7 of Endpoint_Descriptor.BEndpointAddress.

View Source
const (
	TRANSFER_TYPE_CONTROL     = C.LIBUSB_TRANSFER_TYPE_CONTROL
	TRANSFER_TYPE_ISOCHRONOUS = C.LIBUSB_TRANSFER_TYPE_ISOCHRONOUS
	TRANSFER_TYPE_BULK        = C.LIBUSB_TRANSFER_TYPE_BULK
	TRANSFER_TYPE_INTERRUPT   = C.LIBUSB_TRANSFER_TYPE_INTERRUPT
	TRANSFER_TYPE_BULK_STREAM = C.LIBUSB_TRANSFER_TYPE_BULK_STREAM
)

Endpoint transfer type. Values for bits 0:1 of Endpoint_Descriptor.BmAttributes.

View Source
const (
	REQUEST_GET_STATUS        = C.LIBUSB_REQUEST_GET_STATUS
	REQUEST_CLEAR_FEATURE     = C.LIBUSB_REQUEST_CLEAR_FEATURE
	REQUEST_SET_FEATURE       = C.LIBUSB_REQUEST_SET_FEATURE
	REQUEST_SET_ADDRESS       = C.LIBUSB_REQUEST_SET_ADDRESS
	REQUEST_GET_DESCRIPTOR    = C.LIBUSB_REQUEST_GET_DESCRIPTOR
	REQUEST_SET_DESCRIPTOR    = C.LIBUSB_REQUEST_SET_DESCRIPTOR
	REQUEST_GET_CONFIGURATION = C.LIBUSB_REQUEST_GET_CONFIGURATION
	REQUEST_SET_CONFIGURATION = C.LIBUSB_REQUEST_SET_CONFIGURATION
	REQUEST_GET_INTERFACE     = C.LIBUSB_REQUEST_GET_INTERFACE
	REQUEST_SET_INTERFACE     = C.LIBUSB_REQUEST_SET_INTERFACE
	REQUEST_SYNCH_FRAME       = C.LIBUSB_REQUEST_SYNCH_FRAME
	REQUEST_SET_SEL           = C.LIBUSB_REQUEST_SET_SEL
	SET_ISOCH_DELAY           = C.LIBUSB_SET_ISOCH_DELAY
)

Standard requests, as defined in table 9-5 of the USB 3.0 specifications.

View Source
const (
	REQUEST_TYPE_STANDARD = C.LIBUSB_REQUEST_TYPE_STANDARD
	REQUEST_TYPE_CLASS    = C.LIBUSB_REQUEST_TYPE_CLASS
	REQUEST_TYPE_VENDOR   = C.LIBUSB_REQUEST_TYPE_VENDOR
	REQUEST_TYPE_RESERVED = C.LIBUSB_REQUEST_TYPE_RESERVED
)

Request type bits of Control_Setup.BmRequestType.

View Source
const (
	RECIPIENT_DEVICE    = C.LIBUSB_RECIPIENT_DEVICE
	RECIPIENT_INTERFACE = C.LIBUSB_RECIPIENT_INTERFACE
	RECIPIENT_ENDPOINT  = C.LIBUSB_RECIPIENT_ENDPOINT
	RECIPIENT_OTHER     = C.LIBUSB_RECIPIENT_OTHER
)

Recipient bits of Control_Setup.BmRequestType in control transfers. Values 4 through 31 are reserved.

View Source
const (
	ISO_SYNC_TYPE_NONE     = C.LIBUSB_ISO_SYNC_TYPE_NONE
	ISO_SYNC_TYPE_ASYNC    = C.LIBUSB_ISO_SYNC_TYPE_ASYNC
	ISO_SYNC_TYPE_ADAPTIVE = C.LIBUSB_ISO_SYNC_TYPE_ADAPTIVE
	ISO_SYNC_TYPE_SYNC     = C.LIBUSB_ISO_SYNC_TYPE_SYNC
)

Synchronization type for isochronous endpoints. Values for bits 2:3 of Endpoint_Descriptor.BmAttributes.

View Source
const (
	ISO_USAGE_TYPE_DATA     = C.LIBUSB_ISO_USAGE_TYPE_DATA
	ISO_USAGE_TYPE_FEEDBACK = C.LIBUSB_ISO_USAGE_TYPE_FEEDBACK
	ISO_USAGE_TYPE_IMPLICIT = C.LIBUSB_ISO_USAGE_TYPE_IMPLICIT
)

Usage type for isochronous endpoints. Values for bits 4:5 of Endpoint_Descriptor.BmAttributes.

View Source
const (
	SPEED_UNKNOWN = C.LIBUSB_SPEED_UNKNOWN
	SPEED_LOW     = C.LIBUSB_SPEED_LOW
	SPEED_FULL    = C.LIBUSB_SPEED_FULL
	SPEED_HIGH    = C.LIBUSB_SPEED_HIGH
	SPEED_SUPER   = C.LIBUSB_SPEED_SUPER
)

Speed codes. Indicates the speed at which the device is operating.

View Source
const (
	LOW_SPEED_OPERATION   = C.LIBUSB_LOW_SPEED_OPERATION
	FULL_SPEED_OPERATION  = C.LIBUSB_FULL_SPEED_OPERATION
	HIGH_SPEED_OPERATION  = C.LIBUSB_HIGH_SPEED_OPERATION
	SUPER_SPEED_OPERATION = C.LIBUSB_SUPER_SPEED_OPERATION
)

Supported speeds (WSpeedSupported) bitfield. Indicates what speeds the device supports.

View Source
const (
	BT_WIRELESS_USB_DEVICE_CAPABILITY = C.LIBUSB_BT_WIRELESS_USB_DEVICE_CAPABILITY
	BT_USB_2_0_EXTENSION              = C.LIBUSB_BT_USB_2_0_EXTENSION
	BT_SS_USB_DEVICE_CAPABILITY       = C.LIBUSB_BT_SS_USB_DEVICE_CAPABILITY
	BT_CONTAINER_ID                   = C.LIBUSB_BT_CONTAINER_ID
)

USB capability types.

View Source
const (
	SUCCESS             = C.LIBUSB_SUCCESS
	ERROR_IO            = C.LIBUSB_ERROR_IO
	ERROR_INVALID_PARAM = C.LIBUSB_ERROR_INVALID_PARAM
	ERROR_ACCESS        = C.LIBUSB_ERROR_ACCESS
	ERROR_NO_DEVICE     = C.LIBUSB_ERROR_NO_DEVICE
	ERROR_NOT_FOUND     = C.LIBUSB_ERROR_NOT_FOUND
	ERROR_BUSY          = C.LIBUSB_ERROR_BUSY
	ERROR_TIMEOUT       = C.LIBUSB_ERROR_TIMEOUT
	ERROR_OVERFLOW      = C.LIBUSB_ERROR_OVERFLOW
	ERROR_PIPE          = C.LIBUSB_ERROR_PIPE
	ERROR_INTERRUPTED   = C.LIBUSB_ERROR_INTERRUPTED
	ERROR_NO_MEM        = C.LIBUSB_ERROR_NO_MEM
	ERROR_NOT_SUPPORTED = C.LIBUSB_ERROR_NOT_SUPPORTED
	ERROR_OTHER         = C.LIBUSB_ERROR_OTHER
)

Error codes.

View Source
const (
	TRANSFER_COMPLETED = C.LIBUSB_TRANSFER_COMPLETED
	TRANSFER_ERROR     = C.LIBUSB_TRANSFER_ERROR
	TRANSFER_TIMED_OUT = C.LIBUSB_TRANSFER_TIMED_OUT
	TRANSFER_CANCELLED = C.LIBUSB_TRANSFER_CANCELLED
	TRANSFER_STALL     = C.LIBUSB_TRANSFER_STALL
	TRANSFER_NO_DEVICE = C.LIBUSB_TRANSFER_NO_DEVICE
	TRANSFER_OVERFLOW  = C.LIBUSB_TRANSFER_OVERFLOW
)

Transfer status codes.

View Source
const (
	TRANSFER_SHORT_NOT_OK    = C.LIBUSB_TRANSFER_SHORT_NOT_OK
	TRANSFER_FREE_BUFFER     = C.LIBUSB_TRANSFER_FREE_BUFFER
	TRANSFER_FREE_TRANSFER   = C.LIBUSB_TRANSFER_FREE_TRANSFER
	TRANSFER_ADD_ZERO_PACKET = C.LIBUSB_TRANSFER_ADD_ZERO_PACKET
)

Transfer.Flags values.

View Source
const (
	CAP_HAS_CAPABILITY                = C.LIBUSB_CAP_HAS_CAPABILITY
	CAP_HAS_HOTPLUG                   = C.LIBUSB_CAP_HAS_HOTPLUG
	CAP_HAS_HID_ACCESS                = C.LIBUSB_CAP_HAS_HID_ACCESS
	CAP_SUPPORTS_DETACH_KERNEL_DRIVER = C.LIBUSB_CAP_SUPPORTS_DETACH_KERNEL_DRIVER
)

Capabilities supported by an instance of libusb on the current running platform. Test if the loaded library supports a given capability by calling Has_Capability().

View Source
const (
	LOG_LEVEL_NONE    = C.LIBUSB_LOG_LEVEL_NONE
	LOG_LEVEL_ERROR   = C.LIBUSB_LOG_LEVEL_ERROR
	LOG_LEVEL_WARNING = C.LIBUSB_LOG_LEVEL_WARNING
	LOG_LEVEL_INFO    = C.LIBUSB_LOG_LEVEL_INFO
	LOG_LEVEL_DEBUG   = C.LIBUSB_LOG_LEVEL_DEBUG
)

Log message levels.

View Source
const (
	HOTPLUG_EVENT_DEVICE_ARRIVED = C.LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED
	HOTPLUG_EVENT_DEVICE_LEFT    = C.LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT
)

Hotplug events.

View Source
const API_VERSION = C.LIBUSB_API_VERSION

libusb API version.

View Source
const (
	BM_LPM_SUPPORT = C.LIBUSB_BM_LPM_SUPPORT
)

Bitmasks for USB_2_0_Extension_Descriptor.BmAttributes.

View Source
const (
	BM_LTM_SUPPORT = C.LIBUSB_BM_LTM_SUPPORT
)

Bitmasks for SS_USB_Device_Capability_Descriptor.BmAttributes.

View Source
const BT_CONTAINER_ID_SIZE = C.LIBUSB_BT_CONTAINER_ID_SIZE
View Source
const BT_SS_USB_DEVICE_CAPABILITY_SIZE = C.LIBUSB_BT_SS_USB_DEVICE_CAPABILITY_SIZE
View Source
const BT_USB_2_0_EXTENSION_SIZE = C.LIBUSB_BT_USB_2_0_EXTENSION_SIZE

BOS descriptor sizes.

View Source
const CONTROL_SETUP_SIZE = C.LIBUSB_CONTROL_SETUP_SIZE
View Source
const DT_BOS_MAX_SIZE = C.LIBUSB_DT_BOS_MAX_SIZE
View Source
const DT_BOS_SIZE = C.LIBUSB_DT_BOS_SIZE
View Source
const DT_CONFIG_SIZE = C.LIBUSB_DT_CONFIG_SIZE
View Source
const DT_DEVICE_CAPABILITY_SIZE = C.LIBUSB_DT_DEVICE_CAPABILITY_SIZE
View Source
const DT_DEVICE_SIZE = C.LIBUSB_DT_DEVICE_SIZE

Descriptor sizes per descriptor type.

View Source
const DT_ENDPOINT_AUDIO_SIZE = C.LIBUSB_DT_ENDPOINT_AUDIO_SIZE
View Source
const DT_ENDPOINT_SIZE = C.LIBUSB_DT_ENDPOINT_SIZE
View Source
const DT_HUB_NONVAR_SIZE = C.LIBUSB_DT_HUB_NONVAR_SIZE
View Source
const DT_INTERFACE_SIZE = C.LIBUSB_DT_INTERFACE_SIZE
View Source
const DT_SS_ENDPOINT_COMPANION_SIZE = C.LIBUSB_DT_SS_ENDPOINT_COMPANION_SIZE
View Source
const ENDPOINT_ADDRESS_MASK = C.LIBUSB_ENDPOINT_ADDRESS_MASK
View Source
const ENDPOINT_DIR_MASK = C.LIBUSB_ENDPOINT_DIR_MASK
View Source
const ERROR_COUNT = C.LIBUSB_ERROR_COUNT

Total number of error codes.

View Source
const (
	//HOTPLUG_NO_FLAGS  = C.LIBUSB_HOTPLUG_NO_FLAGS
	HOTPLUG_ENUMERATE = C.LIBUSB_HOTPLUG_ENUMERATE
)

Flags for hotplug events.

View Source
const HOTPLUG_MATCH_ANY = C.LIBUSB_HOTPLUG_MATCH_ANY

Wildcard matching for hotplug events.

View Source
const ISO_SYNC_TYPE_MASK = C.LIBUSB_ISO_SYNC_TYPE_MASK
View Source
const ISO_USAGE_TYPE_MASK = C.LIBUSB_ISO_USAGE_TYPE_MASK
View Source
const TRANSFER_TYPE_MASK = C.LIBUSB_TRANSFER_TYPE_MASK

in BmAttributes

Variables

This section is empty.

Functions

func Alloc_Streams

func Alloc_Streams(dev Device_Handle, num_streams uint32, endpoints []byte) (int, error)

func Attach_Kernel_Driver

func Attach_Kernel_Driver(hdl Device_Handle, interface_number int) error

func Bulk_Transfer

func Bulk_Transfer(hdl Device_Handle, endpoint uint8, data []byte, timeout uint) ([]byte, error)

func CPU_To_LE16

func CPU_To_LE16(x uint16) uint16

func Cancel_Sync_Transfers_On_Device

func Cancel_Sync_Transfers_On_Device(hdl Device_Handle)

libusb_cancel_sync_transfers_on_device(struct libusb_device_handle *dev_handle) {

func Cancel_Transfer

func Cancel_Transfer(transfer *Transfer) error

func Claim_Interface

func Claim_Interface(hdl Device_Handle, interface_number int) error

func Clear_Halt

func Clear_Halt(hdl Device_Handle, endpoint uint8) error

func Close

func Close(hdl Device_Handle)

func Control_Transfer

func Control_Transfer(hdl Device_Handle, bmRequestType uint8, bRequest uint8, wValue uint16, wIndex uint16, data []byte, timeout uint) ([]byte, error)

func Control_Transfer_Get_Data

func Control_Transfer_Get_Data(transfer *Transfer) *byte

func Detach_Kernel_Driver

func Detach_Kernel_Driver(hdl Device_Handle, interface_number int) error

func Error_Name

func Error_Name(code int) string

func Exit

func Exit(ctx Context)

func Extra_str

func Extra_str(x []byte) string

return a string for the extra buffer

func Free_BOS_Descriptor

func Free_BOS_Descriptor(bos *BOS_Descriptor)

func Free_Config_Descriptor

func Free_Config_Descriptor(config *Config_Descriptor)

func Free_Container_ID_Descriptor

func Free_Container_ID_Descriptor(container_id *Container_ID_Descriptor)

func Free_Device_List

func Free_Device_List(list []Device, unref_devices int)

func Free_SS_Endpoint_Companion_Descriptor

func Free_SS_Endpoint_Companion_Descriptor(ep_comp *SS_Endpoint_Companion_Descriptor)

func Free_SS_USB_Device_Capability_Descriptor

func Free_SS_USB_Device_Capability_Descriptor(ss_usb_device_cap *SS_USB_Device_Capability_Descriptor)

func Free_Streams

func Free_Streams(dev Device_Handle, endpoints []byte) error

func Free_Transfer

func Free_Transfer(transfer *Transfer)

func Free_USB_2_0_Extension_Descriptor

func Free_USB_2_0_Extension_Descriptor(usb_2_0_extension *USB_2_0_Extension_Descriptor)

func Get_Bus_Number

func Get_Bus_Number(dev Device) uint8

func Get_Configuration

func Get_Configuration(hdl Device_Handle) (int, error)

func Get_Descriptor

func Get_Descriptor(hdl Device_Handle, desc_type uint8, desc_index uint8, data []byte) ([]byte, error)

func Get_Device_Address

func Get_Device_Address(dev Device) uint8

func Get_Device_Speed

func Get_Device_Speed(dev Device) int

func Get_Max_ISO_Packet_Size

func Get_Max_ISO_Packet_Size(dev Device, endpoint uint8) int

func Get_Max_Packet_Size

func Get_Max_Packet_Size(dev Device, endpoint uint8) int

func Get_Port_Number

func Get_Port_Number(dev Device) uint8

func Get_Port_Numbers

func Get_Port_Numbers(dev Device, ports []byte) ([]byte, error)

func Get_String_Descriptor

func Get_String_Descriptor(hdl Device_Handle, desc_index uint8, langid uint16, data []byte) ([]byte, error)

func Get_String_Descriptor_ASCII

func Get_String_Descriptor_ASCII(hdl Device_Handle, desc_index uint8, data []byte) ([]byte, error)

func Init

func Init(ctx *Context) error

func Interface_str

func Interface_str(x *Interface) string

return a string for an Interface

func Interrupt_Transfer

func Interrupt_Transfer(hdl Device_Handle, endpoint uint8, data []byte, timeout uint) ([]byte, error)

func Kernel_Driver_Active

func Kernel_Driver_Active(hdl Device_Handle, interface_number int) (bool, error)

func Release_Interface

func Release_Interface(hdl Device_Handle, interface_number int) error

func Reset_Device

func Reset_Device(hdl Device_Handle) error

func SetLogWriter

func SetLogWriter(l io.Writer)

func Set_Auto_Detach_Kernel_Driver

func Set_Auto_Detach_Kernel_Driver(hdl Device_Handle, enable bool) error

func Set_Configuration

func Set_Configuration(hdl Device_Handle, configuration int) error

func Set_Debug

func Set_Debug(ctx Context, level int)

func Set_Interface_Alt_Setting

func Set_Interface_Alt_Setting(hdl Device_Handle, interface_number int, alternate_setting int) error

func Strerror

func Strerror(errcode int) string

func Submit_Transfer

func Submit_Transfer(transfer *Transfer) error

func Transfer_Get_Stream_ID

func Transfer_Get_Stream_ID(transfer *Transfer) uint32

func Transfer_Set_Stream_ID

func Transfer_Set_Stream_ID(transfer *Transfer, stream_id uint32)

func Unref_Device

func Unref_Device(dev Device)

Types

type BOS_Descriptor

type BOS_Descriptor struct {
	BLength         uint8
	BDescriptorType uint8
	WTotalLength    uint16
	Dev_capability  []*BOS_Dev_Capability_Descriptor
	// contains filtered or unexported fields
}

A structure representing the Binary Device Object Store (BOS) descriptor. This descriptor is documented in section 9.6.2 of the USB 3.0 specification. All multiple-byte fields are represented in host-endian format.

func Get_BOS_Descriptor

func Get_BOS_Descriptor(hdl Device_Handle) (*BOS_Descriptor, error)

type BOS_Dev_Capability_Descriptor

type BOS_Dev_Capability_Descriptor struct {
	BLength             uint8
	BDescriptorType     uint8
	BDevCapabilityType  uint8
	Dev_capability_data []byte
	// contains filtered or unexported fields
}

A generic representation of a BOS Device Capability descriptor. It is advised to check BDevCapabilityType and call the matching Get_*_Descriptor function to get a structure fully matching the type.

type Config_Descriptor

type Config_Descriptor struct {
	BLength             uint8
	BDescriptorType     uint8
	WTotalLength        uint16
	BNumInterfaces      uint8
	BConfigurationValue uint8
	IConfiguration      uint8
	BmAttributes        uint8
	MaxPower            uint8
	Interface           []*Interface
	Extra               []byte
	// contains filtered or unexported fields
}

A structure representing the standard USB configuration descriptor. This descriptor is documented in section 9.6.3 of the USB 3.0 specification. All multiple-byte fields are represented in host-endian format.

func Get_Active_Config_Descriptor

func Get_Active_Config_Descriptor(dev Device) (*Config_Descriptor, error)

func Get_Config_Descriptor

func Get_Config_Descriptor(dev Device, config_index uint8) (*Config_Descriptor, error)

func Get_Config_Descriptor_By_Value

func Get_Config_Descriptor_By_Value(dev Device, bConfigurationValue uint8) (*Config_Descriptor, error)

func (*Config_Descriptor) String

func (x *Config_Descriptor) String() string

return a string for a Config_Descriptor

type Container_ID_Descriptor

type Container_ID_Descriptor struct {
	BLength            uint8
	BDescriptorType    uint8
	BDevCapabilityType uint8
	BReserved          uint8
	ContainerID        []byte
	// contains filtered or unexported fields
}

A structure representing the Container ID descriptor. This descriptor is documented in section 9.6.2.3 of the USB 3.0 specification. All multiple-byte fields, except UUIDs, are represented in host-endian format.

func Get_Container_ID_Descriptor

func Get_Container_ID_Descriptor(ctx Context, dev_cap *BOS_Dev_Capability_Descriptor) (*Container_ID_Descriptor, error)

type Context

type Context *C.struct_libusb_context

Structure representing a libusb session.

type Device

type Device *C.struct_libusb_device

Structure representing a USB device detected on the system.

func Get_Device

func Get_Device(hdl Device_Handle) Device

func Get_Device_List

func Get_Device_List(ctx Context) ([]Device, error)

func Ref_Device

func Ref_Device(dev Device) Device

type Device_Descriptor

type Device_Descriptor struct {
	BLength            uint8
	BDescriptorType    uint8
	BcdUSB             uint16
	BDeviceClass       uint8
	BDeviceSubClass    uint8
	BDeviceProtocol    uint8
	BMaxPacketSize0    uint8
	IdVendor           uint16
	IdProduct          uint16
	BcdDevice          uint16
	IManufacturer      uint8
	IProduct           uint8
	ISerialNumber      uint8
	BNumConfigurations uint8
	// contains filtered or unexported fields
}

A structure representing the standard USB device descriptor. This descriptor is documented in section 9.6.1 of the USB 3.0 specification. All multiple-byte fields are represented in host-endian format.

func Get_Device_Descriptor

func Get_Device_Descriptor(dev Device) (*Device_Descriptor, error)

func (*Device_Descriptor) String

func (x *Device_Descriptor) String() string

return a string for a Device_Descriptor

type Device_Handle

type Device_Handle *C.struct_libusb_device_handle

Structure representing a handle on a USB device.

func Open

func Open(dev Device) (Device_Handle, error)

func Open_Device_With_VID_PID

func Open_Device_With_VID_PID(ctx Context, vendor_id uint16, product_id uint16) Device_Handle

type Endpoint_Descriptor

type Endpoint_Descriptor struct {
	BLength          uint8
	BDescriptorType  uint8
	BEndpointAddress uint8
	BmAttributes     uint8
	WMaxPacketSize   uint16
	BInterval        uint8
	BRefresh         uint8
	BSynchAddress    uint8
	Extra            []byte
	// contains filtered or unexported fields
}

A structure representing the standard USB endpoint descriptor. This descriptor is documented in section 9.6.6 of the USB 3.0 specification. All multiple-byte fields are represented in host-endian format.

func (*Endpoint_Descriptor) String

func (x *Endpoint_Descriptor) String() string

return a string for an Endpoint_Descriptor

type Interface

type Interface struct {
	Num_altsetting int
	Altsetting     []*Interface_Descriptor
	// contains filtered or unexported fields
}

A collection of alternate settings for a particular USB interface.

type Interface_Descriptor

type Interface_Descriptor struct {
	BLength            uint8
	BDescriptorType    uint8
	BInterfaceNumber   uint8
	BAlternateSetting  uint8
	BNumEndpoints      uint8
	BInterfaceClass    uint8
	BInterfaceSubClass uint8
	BInterfaceProtocol uint8
	IInterface         uint8
	Endpoint           []*Endpoint_Descriptor
	Extra              []byte
	// contains filtered or unexported fields
}

A structure representing the standard USB interface descriptor. This descriptor is documented in section 9.6.5 of the USB 3.0 specification. All multiple-byte fields are represented in host-endian format.

func (*Interface_Descriptor) String

func (x *Interface_Descriptor) String() string

return a string for an Interface_Descriptor

type SS_Endpoint_Companion_Descriptor

type SS_Endpoint_Companion_Descriptor struct {
	BLength           uint8
	BDescriptorType   uint8
	BMaxBurst         uint8
	BmAttributes      uint8
	WBytesPerInterval uint16
	// contains filtered or unexported fields
}

A structure representing the superspeed endpoint companion descriptor. This descriptor is documented in section 9.6.7 of the USB 3.0 specification. All multiple-byte fields are represented in host-endian format.

func Get_SS_Endpoint_Companion_Descriptor

func Get_SS_Endpoint_Companion_Descriptor(ctx Context, endpoint *Endpoint_Descriptor) (*SS_Endpoint_Companion_Descriptor, error)

type SS_USB_Device_Capability_Descriptor

type SS_USB_Device_Capability_Descriptor struct {
	BLength               uint8
	BDescriptorType       uint8
	BDevCapabilityType    uint8
	BmAttributes          uint8
	WSpeedSupported       uint16
	BFunctionalitySupport uint8
	BU1DevExitLat         uint8
	BU2DevExitLat         uint16
	// contains filtered or unexported fields
}

A structure representing the SuperSpeed USB Device Capability descriptor This descriptor is documented in section 9.6.2.2 of the USB 3.0 specification. All multiple-byte fields are represented in host-endian format.

type Transfer

type Transfer struct {
	// contains filtered or unexported fields
}

The generic USB transfer structure. The user populates this structure and then submits it in order to request a transfer. After the transfer has completed, the library populates the transfer with the results and passes it back to the user.

func Alloc_Transfer

func Alloc_Transfer(iso_packets int) (*Transfer, error)

func (*Transfer) String

func (x *Transfer) String() string

return a string for a Device_Descriptor

type USB_2_0_Extension_Descriptor

type USB_2_0_Extension_Descriptor struct {
	BLength            uint8
	BDescriptorType    uint8
	BDevCapabilityType uint8
	BmAttributes       uint32
	// contains filtered or unexported fields
}

A structure representing the USB 2.0 Extension descriptor This descriptor is documented in section 9.6.2.1 of the USB 3.0 specification. All multiple-byte fields are represented in host-endian format.

func Get_USB_2_0_Extension_Descriptor

func Get_USB_2_0_Extension_Descriptor(ctx Context, dev_cap *BOS_Dev_Capability_Descriptor) (*USB_2_0_Extension_Descriptor, error)

type Version

type Version struct {
	Major    uint16
	Minor    uint16
	Micro    uint16
	Nano     uint16
	Rc       string
	Describe string
	// contains filtered or unexported fields
}

Structure providing the version of the libusb runtime.

func Get_Version

func Get_Version() *Version

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL