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 : public 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)
HidDevice(const std::string& deviceName);
Opens the HID device that UsbHostController reported ("/dev/hidraw0").
Properties
ProductName
std::string ProductName() const;
The device's name ("Microchip Technology Inc. MCP2221 USB-I2C/UART Combo")
Returns string
Methods
GetFeatureReport(Span<byte> buffer)
int32_t GetFeatureReport(Span<uint8_t> buffer);
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()
std::vector<uint8_t> GetReportDescriptor();
The report descriptor: what reports the device has and what is in them.
Returns byte[]
Read(Span<byte> buffer, int timeout)
int32_t Read(Span<uint8_t> buffer, int32_t timeout);
Reads an input report (its first byte is its report ID if the device numbers its reports).
| Parameter | Type | Description |
|---|---|---|
buffer | Span<byte> | Where the report goes. |
timeout | int | How 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)
void SendFeatureReport(ReadOnlySpan<uint8_t> report);
Sends a feature report. Its first byte is the report ID (0 if the device has none).
Write(ReadOnlySpan<byte> report)
int32_t Write(ReadOnlySpan<uint8_t> report);
Sends an output report. Its first byte is the report ID (0 if the device has none).
Returns int: The number of bytes written.