Skip to main content

HidDevice Class

Package: GHIElectronics.Endpoint.Devices.UsbHost
Namespace: GHIElectronics.Endpoint.Devices.UsbHost

A HID device that is no keyboard, mouse or joystick (a sensor, a USB I/O board, a UPS...): its reports, as hidapi gives them.

class HidDevice(BaseDevice): ...

Remarks​

Open it with the DeviceName of a HID device from UsbHostController ("/dev/hidraw0"). A report's first byte is its report ID: 0 for a device that does not number its reports.

Constructors​

HidDevice(string deviceName)​

def __init__(self, deviceName: str):

Opens the HID device that UsbHostController reported ("/dev/hidraw0").

Properties​

ProductName​

ProductName: str # @property

The device's name ("Microchip Technology Inc. MCP2221 USB-I2C/UART Combo")

Returns string

Methods​

GetFeatureReport(Span<byte> buffer)​

def GetFeatureReport(self, buffer: Span[int]) -> int:

Gets a feature report. buffer[0] is the report ID (0 if the device has none).

Returns int: The report's length, with its report ID.

GetReportDescriptor()​

def GetReportDescriptor(self) -> list[int]:

The report descriptor: what reports the device has and what is in them.

Returns byte[]

Read(Span<byte> buffer, int timeout)​

def Read(self, buffer: Span[int], timeout: int) -> int:

Reads an input report (its first byte is its report ID if the device numbers its reports).

ParameterTypeDescription
bufferSpan<byte>Where the report goes.
timeoutintHow long to wait for one, in milliseconds (Timeout.Infinite: as long as it takes).

Returns int: The report's length, 0 if none came in time.

SendFeatureReport(ReadOnlySpan<byte> report)​

def SendFeatureReport(self, report: ReadOnlySpan[int]) -> None:

Sends a feature report. Its first byte is the report ID (0 if the device has none).

Write(ReadOnlySpan<byte> report)​

def Write(self, report: ReadOnlySpan[int]) -> int:

Sends an output report. Its first byte is the report ID (0 if the device has none).

Returns int: The number of bytes written.