Contents
erlusb might become an Erlang library with a general purpose interface to USB devices some time.
This is my fork of ndim's erlusb project. I like his coding style which is why his code is the basis for this fork. However the gen_server does not store any state so is unnecessary. If the genserver is unnecessary then so is the supervisor, and the code simply becomes a library application.
Run:
$ autoreconf -ivs $ mkdir _b && cd _b $ ../configure --prefix=$PWD/../_i $ make all check install installcheck
This requires that a number of software packages are installed, such as autoconf, automake, erlang, gcc, libtool, GNU make, and more.
It might also be possible to build in the source directory ("./configure && make && make install"), but this is not tested regularly.
No idea (yet). The complex2.erl and stuff are from the Erlang docs, anyway. Strong contenders for the license are LGPL and MIT/Erlang.
As of 2009-01-21, the code is marked as LGPL, but that might change later, depending on many factors internal and external.
- gen_server for USB device access
- One gen_server for each Erlang port / USB device, init/2 will open port.
- handle_info/N being called by behaviour when non-OTP message is received (data from port)
- USB devices being local, the usb server process only makes sense as {local, Foo}
- A gen_fsm for devices might make more sense than a gen_server. Communicating with another device by messages is a classical example for communicating FSMs, after all.
- Make a decision: One Erlang port (one libusb instance per USB host) for all devices, or one Erlang port (one libusb instance per USB device) for each device?
First off, we needed to find out which underlying C API to use. Candidates included libusb-0.1, libusb-1.0, and openusb.
- libusb-0.1 (or libusb-compat-0.1)
- compatible implementation for Win32 exists (libusb-win32)
- no isochronous transfer mode support
- very commonly used
- libusb-1.0
- implementation for Win32 is in the works
- isochronous transfer mode support
- very commonly used
- openusb
- does anyone use this at all?
The safest bet appeared to be libusb-1.0. It is widely used, and supports all transfer modes. So erlusb builds on libusb-1.0.