Skip to main content

BaseDevice Class

Namespace: GHIElectronics.TinyCLR.Devices.UsbHost · Assembly: GHIElectronics.TinyCLR.Devices.UsbHost

Represents a USB device connected.

public abstract class BaseDevice : IDisposable

Constructors

BaseDevice(uint id, byte interfaceIndex, DeviceType type)

protected BaseDevice(uint id, byte interfaceIndex, DeviceType type)

No description available.

ParameterTypeDescription
iduint
interfaceIndexbyte
typeDeviceType

Properties

Connected

public bool Connected { get; }

Whether or not the device is connected.

Id

public uint Id { get; }

The device id.

InterfaceIndex

public byte InterfaceIndex { get; }

The logical device interface index.

Type

public DeviceType Type { get; }

The device's type.

VendorId

public ushort VendorId { get; }

The device's vendor id.

ProductId

public ushort ProductId { get; }

The device's product id.

PortNumber

public byte PortNumber { get; }

The device's USB port number.

WorkerInterval

public virtual int WorkerInterval { get; set; }

How often the internal worker callback is called.

Methods

Dispose()

public void Dispose()

Disconnects and disposes the device.

CheckEvents(object sender)

protected virtual void CheckEvents(object sender)

Repeatedly called with a period defined by WorkerInterval. Used to poll the device for data and raise any desired events.

ParameterTypeDescription
senderobjectAlways null.

Dispose(bool disposing)

protected virtual void Dispose(bool disposing)

Disconnects and disposes the device.

ParameterTypeDescription
disposingboolWhether or not this is called from Dispose.

CheckObjectState(bool throwOnInvalid)

protected bool CheckObjectState(bool throwOnInvalid = true)

Verifies that the object is connected and not disposed.

ParameterTypeDescription
throwOnInvalidboolIf the object is connected or disposed, whether or not to throw an exception.

Returns bool — True if the object is connected and not disposed, false otherwise.

Events

Disconnected

public event DisconnectedEventHandler Disconnected

The event is fired when the device disconnects.

Fields

disposed

protected bool disposed

Whether or not the object has been disposed.