AIOUSB for Linux is a collection of C, C++ and Java libraries for controlling ACCES I/O USB devices, as summarized in the diagram below.
C++ application programs | Java application programs |
C++ Class Library | Java Class Library |
AIOUSB C Library | |
libusb |
The AIOUSB C language library implements the core functionality of the entire suite of libraries, supporting the capabilities of all of ACCES' USB products. (The only deficiency is that the D/A streaming functions in the USB-DA12-8A product are not currently implemented, although they will be eventually.) This library is written in C and compiled for both C (gcc) and C++ (g++) and may be used as-is with C and C++ programs. This library utilizes libusb (preferred version 1.0.6) for all USB communications.
Assuming you’re starting from the root directory of the distribution, installing AIOUSB consists of performing these few simple steps (logged in as 'root', of course).
mkdir /usr/local/include/aiousb
cp -p lib/aiousb.h /usr/local/include/aiousb
cp -p lib/libaiousb*.a /usr/local/lib
export CPATH=/usr/local/include/libusb-1.0/:/usr/local/include/aiousb
You can, of course, place the AIOUSB files (aiousb.h, libaiousb*.a) elsewhere, such as in the local directory of the application program that will use AIOUSB. The above steps are suggested in order to conform to the usual Linux conventions and make the AIOUSB files available to all users and all application programs.
If you do locate the libraries and header files somewhere else, there is an environment variable you can set which is used by the sample program make files:
export AIOUSBLIBDIR="path to the AIOUSB libraries"
There are several variations of the AIOUSB C library. They all begin with "libaiousb" and have an extension of ".a". There are currently no shared versions of the AIOUSB C library. The library files which contain the string "cpp" contain object modules that are compiled for use with C++ (using "g++"). They are not C++ class libraries (see below for information about the genuine C++ class library). The library files which contain the string "dbg" are compiled for source level debugging with the "-ggdb" compiler option. At present, there are four variations of the AIOUSB C library: C or C++, and release or debug.
Complete documentation for the AIOUSB C library may be found in AIOUSB API Reference. This document is based on the USB Software Reference Manual, but adds considerably more detail and includes documentation for the many new functions added to the Linux implementation. This documentation is also intended to be useful as a reference for the Windows implementation of AIOUSB, with differences between the Linux and Windows implementations clearly highlighted.
Assuming you have installed the AIOUSB C library according to the above instructions, compiling a program to use it is as simple as:
g++ -pthread -fPIC sample.cpp -laiousbcpp -lusb-1.0 -o sample (C++)
or
gcc -std=gnu99 -D_GNU_SOURCE -pthread -fPIC sample.c -laiousb -lusb-1.0 -lm -o sample (C)
Residing one level above the AIOUSB C library are two additional object-oriented sister libraries: a C++ class library and a nearly identical Java class library. Although these class libraries should be considered beta software and are still in development, testing so far shows that they are working reliably enough to use. There are a few sample programs in the "samples" directory demonstrating use of both of these class libraries and more such samples will be provided in the future.
The C++ and Java class libraries are designed to be as similar as possible, with the exception of inescapable language and library differences. Otherwise, the structure, functionality, class names, method names and parameter names are identical between the two. As a result, the documentation for either library can largely serve as the documentation for both.
The C++ class library implements the entire functionality of the AIOUSB C library and adds substantial ease-of-use features, in a robust object-oriented class hierarchy.
You may install the C++ class library in the same manner as described for the AIOUSB C library above, using the commands:
cp -p classlib/*.hpp /usr/local/include/aiousb
cp -p classlib/libclassaiousb*.a /usr/local/lib
If you don't wish to copy all those files, then you can use the environment variables (CPATH and AIOUSBCLASSLIBDIR) instead. As for the AIOUSB C library, there is an environment variable that specifies the location of the C++ class libraries for use in the sample program make files:
export AIOUSBCLASSLIBDIR="path to the AIOUSB C++ class libraries"
Complete documentation for the C++ class library may be found in AIOUSB C++ Class Library Reference.
Assuming you have installed the C++ class library according to the above instructions, compiling a program to use it is as simple as:
g++ -pthread -fPIC sample.cpp -lclassaiousb -laiousbcpp -lusb-1.0 -o sample
The Java class library implements the entire functionality of the AIOUSB C library and adds substantial ease-of-use features, in a robust object-oriented class hierarchy.
There really isn't anything to install with the Java class library. The entire library resides within aiousb.jar. You can use this JAR file as a class path when compiling or executing Java application programs, or you can use the directory that contains the actual "*.class" files as the class path, the choice is yours.
As with the C and C++ libraries, the location of the Java library can be specified in an environment variable which is used by the sample program make files:
export AIOUSBJAVALIBDIR="path to the AIOUSB java libraries"
Complete documentation for the Java class library may be found in AIOUSB Java Class Library Reference.
To compile Java programs to use the AIOUSB Java class library, use the command:
javac -cp /path/aiousb.jar Sample.java (where "path" is where you installed the Java class library)
To execute the compiled Java program, use the command:
java -cp /path/aiousb.jar:. Sample