Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/connorrigby/elixir-libusb
LibUSB wrapper for Elixir
https://github.com/connorrigby/elixir-libusb
Last synced: 3 months ago
JSON representation
LibUSB wrapper for Elixir
- Host: GitHub
- URL: https://github.com/connorrigby/elixir-libusb
- Owner: ConnorRigby
- Created: 2020-07-03T06:18:19.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2020-07-06T04:04:52.000Z (over 4 years ago)
- Last Synced: 2024-06-11T21:56:02.341Z (7 months ago)
- Language: C
- Size: 9.77 KB
- Stars: 7
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# LibUSB
## Usage
This project is still very much a work in progress.
### get_device_list
```elixir
iex(1)> LibUSB.Nif.get_device_list()
[
%{
bDescriptorType: 1,
bDeviceClass: 0,
bDeviceProtocol: 0,
bDeviceSubClass: 0,
bLength: 18,
bMaxPacketSize0: 64,
bNumConfigurations: 1,
bcdDevice: 257,
bcdUSB: 272,
bus_number: 2,
configurations: [
%{
MaxPower: 50,
bConfigurationValue: 0,
bDescriptorType: 2,
bLength: 9,
bNumInterfaces: 4,
bmAttributes: 224,
iConfiguration: 0,
wTotalLength: 269
}
],
device_address: 5,
iManufacturer: 1,
iProduct: 2,
iSerialNumber: 3,
idProduct: 22532,
idVendor: 2652
}
]
```### control_transfer read/write
```elixir
iex(1)> {:ok, usb} = LibUSB.Nif.open(0x1915, 0x7777)
{:ok, #Reference<0.2476641389.3169189905.136487>}
iex(2)>
```### bulk_transfer read/write
```elixir
iex(1)> {:ok, usb} = LibUSB.Nif.open(0x1915, 0x7777)
{:ok, #Reference<0.2476641389.3169189905.136487>}
iex(2)> LibUSB.Nif.bulk_transfer(usb, 1, <<0x00>>, 1000)
{:ok, 1}
iex(3)> LibUSB.Nif.bulk_transfer(usb, 0x81, 64, 1000)
{:ok,
<<0, 5, 0, 0, 0, 0, 0, 0, 177, 134, 126, 152, 243, 127, 0, 0, 47, 4, 0, 0, 0,
0, 0, 0, 193, 134, 126, 152, 243, 127, 0, 0, 255, 5, 0, 0, 0, 0, 0, 0, 209,
134, 126, 152, 243, 127, 0, 0, ...>>}
iex(4)>
```## Installation
If [available in Hex](https://hex.pm/docs/publish), the package can be installed
by adding `libusb` to your list of dependencies in `mix.exs`:```elixir
def deps do
[
{:libusb, "~> 0.1.0"}
]
end
```Documentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc)
and published on [HexDocs](https://hexdocs.pm). Once published, the docs can
be found at [https://hexdocs.pm/libusb](https://hexdocs.pm/libusb).