Skip to main content

RawDevice Class

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

Provides low level access functionalities for the connected USB device. This is useful if there is not already a predefined driver for that device.

class RawDevice : public BaseDevice {};

Remarks​

Open it with the DeviceName of an Unknown device from UsbHostController ("/dev/bus/usb/001/005"). An interface that a driver of the board has is taken from it while the program uses it, and given back when the device is disposed.

Nested Types​

TypeKindSummary
RawDevice.PipeClassA USB communication pipe.

Constructors​

RawDevice(string deviceName)​

RawDevice(const std::string& deviceName);

Opens the device that UsbHostController reported ("/dev/bus/usb/001/005").

Properties​

SetupTimeout​

int32_t SetupTimeout() const;
void SetupTimeout(int32_t value);

The timeout of SendSetupPacket in milliseconds (0: none). Defaults to 5000 ms.

Returns int

Methods​

GetConfigurationDescriptor(byte configurationIndex)​

Configuration GetConfigurationDescriptor(uint8_t configurationIndex);

Gets the configuration descriptor.

ParameterTypeDescription
configurationIndexbyteThe configuration index.

Returns Configuration: The configuration descriptor.

GetDeviceDescriptor()​

Device GetDeviceDescriptor();

Gets the device descriptor.

Returns Device: The device descriptor.

GetString(byte index)​

std::string GetString(uint8_t index);

Gets a string descriptor (the product's name...): its text, empty if the device has none.

ParameterTypeDescription
indexbyteThe string's index (Descriptors.Device.ProductIndex...).

Returns string

OpenPipe(Endpoint endpoint)​

Pipe OpenPipe(const Endpoint& endpoint);

Opens a new communication pipe.

ParameterTypeDescription
endpointEndpointThe descriptor for the communication endpoint (bulk or interrupt).

Returns Pipe: The new pipe.

SendSetupPacket(byte requestType, byte request, ushort value, ushort index)​

void SendSetupPacket(uint8_t requestType, uint8_t request, uint16_t value, uint16_t index);

Sends a USB setup packet.

ParameterTypeDescription
requestTypebyteThe request type, recipient, and direction.
requestbyteThe request to make.
valueushortThe value of the request.
indexushortThe index of the request.

SendSetupPacket(byte requestType, byte request, ushort value, ushort index, byte[] data, int dataOffset, int dataCount)​

int32_t SendSetupPacket(uint8_t requestType, uint8_t request, uint16_t value, uint16_t index, const std::vector<uint8_t>& data, int32_t dataOffset, int32_t dataCount);

Sends a USB setup packet.

ParameterTypeDescription
requestTypebyteThe request type, recipient, and direction.
requestbyteThe request to make.
valueushortThe value of the request.
indexushortThe index of the request.
databyte[]The data to send or receive.
dataOffsetintThe offset into data at which to send or receive the data.
dataCountintThe number of bytes to send or receive into data starting at offset.

Returns int: The number of bytes sent or received.