Behaviour for the USB plumbing underneath NetMD.Device.
NetMD devices speak vendor-specific control transfers on the default
endpoint plus one bulk IN and one bulk OUT endpoint. Implemented by
NetMD.Transport.Usb for real hardware and by a scripted mock in the
test suite.
Summary
Callbacks
Read from the bulk IN endpoint.
Write to the bulk OUT endpoint.
Release the device.
Vendor-interface control IN transfer.
Vendor-interface control OUT transfer.
List the connected NetMD devices without opening any of them.
Open a device, prepare it for I/O and return a handle plus info.
Types
@type handle() :: term()
Implementation-specific device handle.
@type info() :: %{vendor_id: 0..65535, product_id: 0..65535}
Identifying info returned from open/1.
@type location() :: %{ vendor_id: 0..65535, product_id: 0..65535, bus: pos_integer() | nil, address: pos_integer() | nil }
A device found by list/1, located on the bus.
Callbacks
@callback bulk_in(handle(), length :: non_neg_integer(), timeout()) :: {:ok, binary()} | {:error, term()}
Read from the bulk IN endpoint.
Write to the bulk OUT endpoint.
@callback close(handle()) :: :ok
Release the device.
@callback control_in( handle(), request :: 0..255, value :: 0..65535, index :: 0..65535, length :: non_neg_integer() ) :: {:ok, binary()} | {:error, term()}
Vendor-interface control IN transfer.
@callback control_out( handle(), request :: 0..255, value :: 0..65535, index :: 0..65535, data :: binary() ) :: :ok | {:error, term()}
Vendor-interface control OUT transfer.
List the connected NetMD devices without opening any of them.
Enumeration is best-effort and does not fail: a device that cannot be read is simply left out. Optional; transports that model a single fixed device need not implement it.
Open a device, prepare it for I/O and return a handle plus info.