View Source usb (usb v0.2.0)
Link to this section Summary
Types
close_device/1
.Indicates the speed at which the device is operating.
Functions
Claim an interface on a given device handle. You must claim the interface you wish to use before you can perform I/O on any of its endpoints.
Clear the halt/stall condition for an endpoint.
Equivalent to monitor_hotplug([]).
start listening for hotplug events. The owner process will start receiving the following hotplug events
Release an interface previously claimed with claim_interface/2
.
Link to this section Types
-type alt_setting() :: #{interface_number := non_neg_integer(), setting_number := non_neg_integer(), class_code := non_neg_integer(), sub_class_code := non_neg_integer(), protocol_code := non_neg_integer(), description_string_index := non_neg_integer(), endpoints := [endpoint()], extra := binary()}.
-type config_descriptor() :: #{configuration_number := byte(), num_interfaces := byte(), description_string_index := byte(), attributes := byte(), max_power := byte(), interfaces := [interface_descriptor()], extra := binary()}.
-opaque device()
-type device_descriptor() ::
#{usb_version := 0..65535,
class_code := byte(),
sub_class_code := byte(),
protocol_code := byte(),
max_packet_size0 := byte(),
vendor_id := 0..65535,
product_id := 0..65535,
device_version := 0..65535,
manufacturer_string_index := byte(),
product_string_index := byte(),
serial_number_string_index := byte(),
num_configurations := byte()}.
-opaque device_handle()
close_device/1
.
-type device_speed() :: unknown | low | full | high | super | super_plus.
Indicates the speed at which the device is operating.
unknown
- The OS doesn't report or know the device speed.
low
- The device is operating at low speed (1.5MBit/s).
full
- The device is operating at full speed (12MBit/s).
high
- The device is operating at high speed (480MBit/s).
super
- The device is operating at super speed (5000MBit/s).
super_plus
- The device is operating at super speed plus (10000MBit/s).
-type endpoint() ::
#{address := non_neg_integer(),
attributes := non_neg_integer(),
max_packet_size := non_neg_integer(),
interval := non_neg_integer(),
refresh := non_neg_integer(),
synch_address := non_neg_integer(),
extra := binary()}.
-opaque hotplug_monitor()
-type interface_descriptor() :: #{alt_settings := [alt_setting()]}.
-type monitor_hotplug_flag() :: enumerate.
Link to this section Functions
-spec attach_kernel_driver(device_handle(), integer()) -> ok | {error, term()}.
-spec claim_interface(device_handle(), non_neg_integer()) -> ok | {error, term()}.
Claim an interface on a given device handle. You must claim the interface you wish to use before you can perform I/O on any of its endpoints.
It is legal to attempt to claim an already-claimed interface, in which case this function just returns ok
without doing anything.
-spec clear_halt(device_handle(), byte()) -> ok | {error, term()}.
Clear the halt/stall condition for an endpoint.
Endpoints with halt status are unable to receive or transmit data until the halt condition is stalled.
You should cancel all pending transfers before attempting to clear the halt condition.-spec close_device(device_handle()) -> ok | {error, term()}.
-spec demonitor_hotplug(hotplug_monitor()) -> ok | {error, term()}.
-spec detach_kernel_driver(device_handle(), integer()) -> ok | {error, term()}.
-spec get_bus_number(device()) -> {ok, 0..255} | {error, term()}.
-spec get_config_descriptor(device(), byte()) -> {ok, config_descriptor()} | {error, term()}.
-spec get_device_address(device()) -> {ok, 0..255} | {error, term()}.
-spec get_device_descriptor(device()) -> {ok, device_descriptor()} | {error, term()}.
-spec get_device_list() -> {ok, [device()]} | {error, term()}.
-spec get_device_speed(device()) -> {ok, device_speed()} | {error, term()}.
-spec get_port_number(device()) -> {ok, 0..255} | {error, term()}.
-spec get_port_numbers(device()) -> {ok, [0..255]} | {error, term()}.
-spec monitor_hotplug() -> {ok, hotplug_monitor()} | {error, term()}.
Equivalent to monitor_hotplug([]).
start listening for hotplug events.-spec monitor_hotplug([monitor_hotplug_flag()]) -> {ok, hotplug_monitor()} | {error, term()}.
start listening for hotplug events. The owner process will start receiving the following hotplug events:
{usb, device_arrived, Device}
and {usb, device_left, Device}
.
enumerate
flag is provided, the owner process will received device_arrived
events for all devices already plugged into the host.
-spec open_device(device()) -> {ok, device_handle()} | {error, term()}.
-spec read_bulk(device_handle(), byte(), integer(), timeout()) -> {ok, binary()} | {error, timeout, binary()} | {error, term()}.
read_control(DeviceHandle, RequestType, Request, Value, Index, ReadLen, Timeout)
View Source-spec read_control(device_handle(), byte(), byte(), non_neg_integer(), non_neg_integer(), non_neg_integer(), timeout()) -> {ok, binary()} | {error, term()}.
-spec read_interrupt(device_handle(), byte(), integer(), timeout()) -> {ok, binary()} | {error, timeout, binary()} | {error, term()}.
-spec release_interface(device_handle(), non_neg_integer()) -> ok | {error, term()}.
Release an interface previously claimed with claim_interface/2
.
-spec set_configuration(device_handle(), integer()) -> ok | {error, term()}.
-spec write_bulk(device_handle(), byte(), binary(), timeout()) -> {ok, integer()} | {error, timeout, non_neg_integer()} | {error, term()}.
write_control(DeviceHandle, RequestType, Request, Value, Index, Data, Timeout)
View Source-spec write_control(device_handle(), byte(), byte(), non_neg_integer(), non_neg_integer(), binary(), timeout()) -> {ok, integer()} | {error, term()}.
-spec write_interrupt(device_handle(), byte(), binary(), timeout()) -> {ok, integer()} | {error, timeout, non_neg_integer()} | {error, term()}.