Documentation
¶
Overview ¶
Package usb is a generated GoMock package.
Index ¶
- type Config
- type Context
- type Device
- type InEndpoint
- type Interface
- type MockConfig
- type MockConfigMockRecorder
- type MockContext
- type MockContextMockRecorder
- type MockDevice
- func (m *MockDevice) Close() error
- func (m *MockDevice) Config(configNumber int) (Config, error)
- func (m *MockDevice) Control(bmRequestType, bRequest uint8, wValue, wIndex uint16, data []byte) (int, error)
- func (m *MockDevice) Descriptor() *gousb.DeviceDesc
- func (m *MockDevice) EXPECT() *MockDeviceMockRecorder
- func (m *MockDevice) GetStringDescriptor(index int) (string, error)
- func (m *MockDevice) Manufacturer() (string, error)
- func (m *MockDevice) Product() (string, error)
- func (m *MockDevice) SerialNumber() (string, error)
- func (m *MockDevice) SetAutoDetach(autoDetach bool) error
- type MockDeviceMockRecorder
- func (mr *MockDeviceMockRecorder) Close() *gomock.Call
- func (mr *MockDeviceMockRecorder) Config(configNumber any) *gomock.Call
- func (mr *MockDeviceMockRecorder) Control(bmRequestType, bRequest, wValue, wIndex, data any) *gomock.Call
- func (mr *MockDeviceMockRecorder) Descriptor() *gomock.Call
- func (mr *MockDeviceMockRecorder) GetStringDescriptor(index any) *gomock.Call
- func (mr *MockDeviceMockRecorder) Manufacturer() *gomock.Call
- func (mr *MockDeviceMockRecorder) Product() *gomock.Call
- func (mr *MockDeviceMockRecorder) SerialNumber() *gomock.Call
- func (mr *MockDeviceMockRecorder) SetAutoDetach(autoDetach any) *gomock.Call
- type MockInEndpoint
- type MockInEndpointMockRecorder
- type MockInterface
- type MockInterfaceMockRecorder
- type MockOutEndpoint
- type MockOutEndpointMockRecorder
- type MockStreamReader
- type MockStreamReaderMockRecorder
- type MockStreamWriter
- type MockStreamWriterMockRecorder
- type OutEndpoint
- type StreamReader
- type StreamWriter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config interface {
// Get interface by given number and alt
Interface(num, alt int) (Interface, error)
// Un-claim USB device's configuration and release associated resources
Close() error
}
func NewGOUSBConfiguration ¶
type Context ¶
type Context interface {
// Iterate through list of connected USB devices and get their descriptors from the devices
IterateDevices(reader func(desc *gousb.DeviceDesc)) error
// Open a USB device by given vendor ID and product ID
OpenDevice(vid, pid gousb.ID) (Device, error)
// Close context and release all associated resources
Close() error
}
Context represents connections between this library and USB devices. It is capable of providing a list of connected USB devices, open USB devices, etc.
func NewGOUSBContext ¶
func NewGOUSBContext() Context
type Device ¶
type Device interface {
// Allow this library to automatically detach this device from kernel when need to claim device's resource,
// such as device interfaces, and attach back when the resource is released
SetAutoDetach(autoDetach bool) error
// Claim a configuration of USB device
Config(configNumber int) (Config, error)
// Get device descriptor
Descriptor() *gousb.DeviceDesc
// Send a USB device request via control endpoint
Control(bmRequestType, bRequest uint8, wValue, wIndex uint16, data []byte) (int, error)
// Get string descriptor of USB device by sending GET_DESCRIPTOR request.
// The requerst is sent via control endpoint.
GetStringDescriptor(index int) (string, error)
// Get manufacturer string by getting string descriptor from USB device
Manufacturer() (string, error)
// Get product name string by getting string descriptor from USB device
Product() (string, error)
// Get device serial number string by getting string descriptor from USB device
SerialNumber() (string, error)
// Close USB device connection and release resources
Close() error
}
Device represents an opened connection of a USB device.
func NewGOUSBDevice ¶
type InEndpoint ¶
type InEndpoint interface {
// Get endpoint descriptor
Descriptor() gousb.EndpointDesc
// Create stream reader to read data from IN endpoint
NewStream(count int) (StreamReader, error)
}
OutEndpoint represents endpoint IN of USB device
func NewGOUSBInEndpoint ¶
func NewGOUSBInEndpoint(ep *gousb.InEndpoint) InEndpoint
type Interface ¶
type Interface interface {
// Un-claim USB device's interface and release associated resources
Close() error
// Get IN endpoint by endpoint number
InEndpoint(num int) (InEndpoint, error)
// Get OUT endpoint by endpoint number
OutEndpoint(num int) (OutEndpoint, error)
}
Interface represents interface of USB device located under USB device's configuration
func NewGOUSBInterface ¶
type MockConfig ¶
type MockConfig struct {
// contains filtered or unexported fields
}
MockConfig is a mock of Config interface.
func NewMockConfig ¶
func NewMockConfig(ctrl *gomock.Controller) *MockConfig
NewMockConfig creates a new mock instance.
func (*MockConfig) EXPECT ¶
func (m *MockConfig) EXPECT() *MockConfigMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
type MockConfigMockRecorder ¶
type MockConfigMockRecorder struct {
// contains filtered or unexported fields
}
MockConfigMockRecorder is the mock recorder for MockConfig.
func (*MockConfigMockRecorder) Close ¶
func (mr *MockConfigMockRecorder) Close() *gomock.Call
Close indicates an expected call of Close.
type MockContext ¶
type MockContext struct {
// contains filtered or unexported fields
}
MockContext is a mock of Context interface.
func NewMockContext ¶
func NewMockContext(ctrl *gomock.Controller) *MockContext
NewMockContext creates a new mock instance.
func (*MockContext) EXPECT ¶
func (m *MockContext) EXPECT() *MockContextMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockContext) IterateDevices ¶
func (m *MockContext) IterateDevices(reader func(*gousb.DeviceDesc)) error
IterateDevices mocks base method.
func (*MockContext) OpenDevice ¶
func (m *MockContext) OpenDevice(vid, pid gousb.ID) (Device, error)
OpenDevice mocks base method.
type MockContextMockRecorder ¶
type MockContextMockRecorder struct {
// contains filtered or unexported fields
}
MockContextMockRecorder is the mock recorder for MockContext.
func (*MockContextMockRecorder) Close ¶
func (mr *MockContextMockRecorder) Close() *gomock.Call
Close indicates an expected call of Close.
func (*MockContextMockRecorder) IterateDevices ¶
func (mr *MockContextMockRecorder) IterateDevices(reader any) *gomock.Call
IterateDevices indicates an expected call of IterateDevices.
func (*MockContextMockRecorder) OpenDevice ¶
func (mr *MockContextMockRecorder) OpenDevice(vid, pid any) *gomock.Call
OpenDevice indicates an expected call of OpenDevice.
type MockDevice ¶
type MockDevice struct {
// contains filtered or unexported fields
}
MockDevice is a mock of Device interface.
func NewMockDevice ¶
func NewMockDevice(ctrl *gomock.Controller) *MockDevice
NewMockDevice creates a new mock instance.
func (*MockDevice) Config ¶
func (m *MockDevice) Config(configNumber int) (Config, error)
Config mocks base method.
func (*MockDevice) Control ¶
func (m *MockDevice) Control(bmRequestType, bRequest uint8, wValue, wIndex uint16, data []byte) (int, error)
Control mocks base method.
func (*MockDevice) Descriptor ¶
func (m *MockDevice) Descriptor() *gousb.DeviceDesc
Descriptor mocks base method.
func (*MockDevice) EXPECT ¶
func (m *MockDevice) EXPECT() *MockDeviceMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockDevice) GetStringDescriptor ¶
func (m *MockDevice) GetStringDescriptor(index int) (string, error)
GetStringDescriptor mocks base method.
func (*MockDevice) Manufacturer ¶
func (m *MockDevice) Manufacturer() (string, error)
Manufacturer mocks base method.
func (*MockDevice) Product ¶
func (m *MockDevice) Product() (string, error)
Product mocks base method.
func (*MockDevice) SerialNumber ¶
func (m *MockDevice) SerialNumber() (string, error)
SerialNumber mocks base method.
func (*MockDevice) SetAutoDetach ¶
func (m *MockDevice) SetAutoDetach(autoDetach bool) error
SetAutoDetach mocks base method.
type MockDeviceMockRecorder ¶
type MockDeviceMockRecorder struct {
// contains filtered or unexported fields
}
MockDeviceMockRecorder is the mock recorder for MockDevice.
func (*MockDeviceMockRecorder) Close ¶
func (mr *MockDeviceMockRecorder) Close() *gomock.Call
Close indicates an expected call of Close.
func (*MockDeviceMockRecorder) Config ¶
func (mr *MockDeviceMockRecorder) Config(configNumber any) *gomock.Call
Config indicates an expected call of Config.
func (*MockDeviceMockRecorder) Control ¶
func (mr *MockDeviceMockRecorder) Control(bmRequestType, bRequest, wValue, wIndex, data any) *gomock.Call
Control indicates an expected call of Control.
func (*MockDeviceMockRecorder) Descriptor ¶
func (mr *MockDeviceMockRecorder) Descriptor() *gomock.Call
Descriptor indicates an expected call of Descriptor.
func (*MockDeviceMockRecorder) GetStringDescriptor ¶
func (mr *MockDeviceMockRecorder) GetStringDescriptor(index any) *gomock.Call
GetStringDescriptor indicates an expected call of GetStringDescriptor.
func (*MockDeviceMockRecorder) Manufacturer ¶
func (mr *MockDeviceMockRecorder) Manufacturer() *gomock.Call
Manufacturer indicates an expected call of Manufacturer.
func (*MockDeviceMockRecorder) Product ¶
func (mr *MockDeviceMockRecorder) Product() *gomock.Call
Product indicates an expected call of Product.
func (*MockDeviceMockRecorder) SerialNumber ¶
func (mr *MockDeviceMockRecorder) SerialNumber() *gomock.Call
SerialNumber indicates an expected call of SerialNumber.
func (*MockDeviceMockRecorder) SetAutoDetach ¶
func (mr *MockDeviceMockRecorder) SetAutoDetach(autoDetach any) *gomock.Call
SetAutoDetach indicates an expected call of SetAutoDetach.
type MockInEndpoint ¶
type MockInEndpoint struct {
// contains filtered or unexported fields
}
MockInEndpoint is a mock of InEndpoint interface.
func NewMockInEndpoint ¶
func NewMockInEndpoint(ctrl *gomock.Controller) *MockInEndpoint
NewMockInEndpoint creates a new mock instance.
func (*MockInEndpoint) Descriptor ¶
func (m *MockInEndpoint) Descriptor() gousb.EndpointDesc
Descriptor mocks base method.
func (*MockInEndpoint) EXPECT ¶
func (m *MockInEndpoint) EXPECT() *MockInEndpointMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockInEndpoint) NewStream ¶
func (m *MockInEndpoint) NewStream(count int) (StreamReader, error)
NewStream mocks base method.
type MockInEndpointMockRecorder ¶
type MockInEndpointMockRecorder struct {
// contains filtered or unexported fields
}
MockInEndpointMockRecorder is the mock recorder for MockInEndpoint.
func (*MockInEndpointMockRecorder) Descriptor ¶
func (mr *MockInEndpointMockRecorder) Descriptor() *gomock.Call
Descriptor indicates an expected call of Descriptor.
type MockInterface ¶
type MockInterface struct {
// contains filtered or unexported fields
}
MockInterface is a mock of Interface interface.
func NewMockInterface ¶
func NewMockInterface(ctrl *gomock.Controller) *MockInterface
NewMockInterface creates a new mock instance.
func (*MockInterface) EXPECT ¶
func (m *MockInterface) EXPECT() *MockInterfaceMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockInterface) InEndpoint ¶
func (m *MockInterface) InEndpoint(num int) (InEndpoint, error)
InEndpoint mocks base method.
func (*MockInterface) OutEndpoint ¶
func (m *MockInterface) OutEndpoint(num int) (OutEndpoint, error)
OutEndpoint mocks base method.
type MockInterfaceMockRecorder ¶
type MockInterfaceMockRecorder struct {
// contains filtered or unexported fields
}
MockInterfaceMockRecorder is the mock recorder for MockInterface.
func (*MockInterfaceMockRecorder) Close ¶
func (mr *MockInterfaceMockRecorder) Close() *gomock.Call
Close indicates an expected call of Close.
func (*MockInterfaceMockRecorder) InEndpoint ¶
func (mr *MockInterfaceMockRecorder) InEndpoint(num any) *gomock.Call
InEndpoint indicates an expected call of InEndpoint.
func (*MockInterfaceMockRecorder) OutEndpoint ¶
func (mr *MockInterfaceMockRecorder) OutEndpoint(num any) *gomock.Call
OutEndpoint indicates an expected call of OutEndpoint.
type MockOutEndpoint ¶
type MockOutEndpoint struct {
// contains filtered or unexported fields
}
MockOutEndpoint is a mock of OutEndpoint interface.
func NewMockOutEndpoint ¶
func NewMockOutEndpoint(ctrl *gomock.Controller) *MockOutEndpoint
NewMockOutEndpoint creates a new mock instance.
func (*MockOutEndpoint) Descriptor ¶
func (m *MockOutEndpoint) Descriptor() gousb.EndpointDesc
Descriptor mocks base method.
func (*MockOutEndpoint) EXPECT ¶
func (m *MockOutEndpoint) EXPECT() *MockOutEndpointMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockOutEndpoint) NewStream ¶
func (m *MockOutEndpoint) NewStream(count int) (StreamWriter, error)
NewStream mocks base method.
type MockOutEndpointMockRecorder ¶
type MockOutEndpointMockRecorder struct {
// contains filtered or unexported fields
}
MockOutEndpointMockRecorder is the mock recorder for MockOutEndpoint.
func (*MockOutEndpointMockRecorder) Descriptor ¶
func (mr *MockOutEndpointMockRecorder) Descriptor() *gomock.Call
Descriptor indicates an expected call of Descriptor.
type MockStreamReader ¶
type MockStreamReader struct {
// contains filtered or unexported fields
}
MockStreamReader is a mock of StreamReader interface.
func NewMockStreamReader ¶
func NewMockStreamReader(ctrl *gomock.Controller) *MockStreamReader
NewMockStreamReader creates a new mock instance.
func (*MockStreamReader) EXPECT ¶
func (m *MockStreamReader) EXPECT() *MockStreamReaderMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockStreamReader) ReadContext ¶
ReadContext mocks base method.
type MockStreamReaderMockRecorder ¶
type MockStreamReaderMockRecorder struct {
// contains filtered or unexported fields
}
MockStreamReaderMockRecorder is the mock recorder for MockStreamReader.
func (*MockStreamReaderMockRecorder) Close ¶
func (mr *MockStreamReaderMockRecorder) Close() *gomock.Call
Close indicates an expected call of Close.
func (*MockStreamReaderMockRecorder) ReadContext ¶
func (mr *MockStreamReaderMockRecorder) ReadContext(ctx, data any) *gomock.Call
ReadContext indicates an expected call of ReadContext.
type MockStreamWriter ¶
type MockStreamWriter struct {
// contains filtered or unexported fields
}
MockStreamWriter is a mock of StreamWriter interface.
func NewMockStreamWriter ¶
func NewMockStreamWriter(ctrl *gomock.Controller) *MockStreamWriter
NewMockStreamWriter creates a new mock instance.
func (*MockStreamWriter) EXPECT ¶
func (m *MockStreamWriter) EXPECT() *MockStreamWriterMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockStreamWriter) WriteContext ¶
WriteContext mocks base method.
type MockStreamWriterMockRecorder ¶
type MockStreamWriterMockRecorder struct {
// contains filtered or unexported fields
}
MockStreamWriterMockRecorder is the mock recorder for MockStreamWriter.
func (*MockStreamWriterMockRecorder) Close ¶
func (mr *MockStreamWriterMockRecorder) Close() *gomock.Call
Close indicates an expected call of Close.
func (*MockStreamWriterMockRecorder) WriteContext ¶
func (mr *MockStreamWriterMockRecorder) WriteContext(ctx, data any) *gomock.Call
WriteContext indicates an expected call of WriteContext.
type OutEndpoint ¶
type OutEndpoint interface {
// Get endpoint descriptor
Descriptor() gousb.EndpointDesc
// Create stream writer to write data to OUT endpoint
NewStream(count int) (StreamWriter, error)
}
OutEndpoint represents endpoint OUT of USB device
func NewGOUSBOutEndpoint ¶
func NewGOUSBOutEndpoint(ep *gousb.OutEndpoint) OutEndpoint
type StreamReader ¶
type StreamReader interface {
// Read data from USB device via endpoint IN
ReadContext(ctx context.Context, data []byte) (int, error)
// Close stream reader system
Close() error
}
StreamReader provides ability to read data from USB device via endpoint with higher throughput
func NewGOUSBStreamReader ¶
func NewGOUSBStreamReader(stream *gousb.ReadStream) StreamReader
type StreamWriter ¶
type StreamWriter interface {
// Write data to USB device via endpoint OUT
WriteContext(ctx context.Context, data []byte) (int, error)
// Close stream writer system
Close() error
}
StreamReader provides ability to write data to USB device via endpoint with higher throughput
func NewGOUSBStreamWriter ¶
func NewGOUSBStreamWriter(stream *gousb.WriteStream) StreamWriter