Skip to main content

RawDevice Class

NuGet: GHIElectronics.TinyCLR.Devices.UsbClient
Assembly: GHIElectronics.TinyCLR.Devices.UsbClient
Namespace: GHIElectronics.TinyCLR.Devices.UsbClient

Represent a USB device.

public class RawDevice

Constructors

RawDevice(UsbClientController usbClientController, UsbClientSetting usbClientSetting)

public RawDevice(UsbClientController usbClientController, UsbClientSetting usbClientSetting)

Creates a new raw device.

ParameterTypeDescription
usbClientControllerUsbClientControllerUsbClient controller.
usbClientSettingUsbClientSettingUsbClient setting

Properties

MaxEndpoint

public static int MaxEndpoint { get; }

The maximum number of endpoints.

MaxStreams

public static int MaxStreams { get; }

The maximum number of streams.

VendorId

public ushort VendorId { get; }

The vendor id of the device.

ProductId

public ushort ProductId { get; }

The product id of the device.

BcdUsb

public ushort BcdUsb { get; }

The version of the device.

BcdDevice

public ushort BcdDevice { get; }

The version of the device.

MaximumPower

public ushort MaximumPower { get; }

The maximum power the device might need.

Manufacturer

public string Manufacturer { get; }

The manufacturer of the device.

Product

public string Product { get; }

The product name.

SerialNumber

public string SerialNumber { get; }

The serial number of the device.

DeviceState

public DeviceState DeviceState { get; }

The current state of the device.

Methods

ReserveNewEndpoint()

public int ReserveNewEndpoint()

Gets the next available endpoint.

Returns int — The endpoint number.

ReserveNewEndpoint(int endpoint)

public void ReserveNewEndpoint(int endpoint)

Reserves the given endpoint.

ParameterTypeDescription
endpointintThe specific endpoint number to reserve.

AddDescriptor(Configuration.Descriptor descriptor)

public void AddDescriptor(Configuration.Descriptor descriptor)

Adds a descriptor to the device.

ParameterTypeDescription
descriptorConfiguration.DescriptorThe descriptor to add.

AddInterface(Configuration.UsbInterface usbInterface, string interfaceString)

public byte AddInterface(Configuration.UsbInterface usbInterface, string interfaceString)

Adds an interface to the device.

ParameterTypeDescription
usbInterfaceConfiguration.UsbInterfaceThe interface.
interfaceStringstringThe interface name.

Returns byte — The assigned interface index.

Enable()

public virtual void Enable()

Enables the device so the host can communicate with it.

Disable()

public virtual void Disable()

Disables the device.

Dispose()

public void Dispose()

Disposes the device.

CreateStream(int writeEndpoint, int readEndpoint)

public RawStream CreateStream(int writeEndpoint, int readEndpoint)

Creates a steam for reading and writing to the device.

ParameterTypeDescription
writeEndpointintThe write endpoint. Use RawStream.NullEndpoint if not available.
readEndpointintThe read endpoint. Use RawStream.NullEndpoint if not available.

Returns RawStream — The new stream.

SetInterfaceMap(byte interfaceIndex, byte data1, byte data2, byte data3)

public void SetInterfaceMap(byte interfaceIndex, byte data1, byte data2, byte data3)

Maps additional data to the given interface index.

CreateStream(int index, RawDevice parent)

protected virtual RawStream CreateStream(int index, RawDevice parent)

Creates a new instance of the stream type for this device type.

ParameterTypeDescription
indexintThe index of the stream
parentRawDeviceThe owning raw device.

Returns RawStream — The new stream.

Events

DeviceStateChanged

public event DeviceStateChangedEventHandler DeviceStateChanged

Raised when the device state changes.

Fields

MAX_POWER

public const ushort MAX_POWER

The default maximum power, in 2 mA units.

GHI_VID

public const ushort GHI_VID

The GHI Electronics vendor id.