USB-IIRO-16 Sample Program Release Notes

Table of Contents

Overview

This directory contains several sample programs for the USB-IIRO-16 which demonstrate use of different features and libraries.

C++ Sample

Sample.cpp is a simple program to demonstrate controlling an ACCES I/O model USB-IIRO-16 digital I/O board using the AIOUSB module and the AIOUSB C++ class library. The program is not intended to be a comprehensive demonstration and is limited to demonstrating the following features of the AIOUSB API:

For easy identification, the source code lines prefixed with the comment /*API*/ denote calls to the AIOUSB and C++ class library API.

The C++ class library should be considered beta software and is still being developed. Notice, too, that when using the C++ class library it is not necessary (in fact, it's not permitted) to call AIOUSB_Init() or AIOUSB_Exit(). These are implicitly called by USBDeviceManager::open() and USBDeviceManager::close(). Refer to AIOUSB C++ Class Library Reference for detailed documentation on the C++ class library.

Building

Before building the program, make sure the libusb module is installed. Also refer to the comments at the top of sample.cpp for additional details.

Also, make sure that the ACCES I/O AIOUSB module is installed (see Installing And Using AIOUSB Library).

The simplest way to build the sample program is to type make at the command line. The sample program is the default target in Makefile. Optionally, one can manually compile the program with the command:

g++ sample.cpp -lclassaiousb -laiousbcpp -lusb-1.0 -o sample

This sample program can demonstrate writing to the EEPROM. That demonstration is disabled by default, but if you wish to enable it, simply edit Sample.java and set the variable named DEMO_EEPROM_WRITE to true.

Executing

To execute the program, attach a USB-IIRO-16 analog input board to the USB bus and verify that its LED turns on, indicating that firmware has been successfully uploaded to the board. Then simply type ./sample at the command line. There are no command line arguments to worry about. The program will search for the first USB-IIRO-16 analog input board on the USB bus. If it fails to find such a board, it will print an error message and quit. If it finds such a board, the following output will appear:

USB-IIRO-16 sample program version: 1.6, 25 December 2009
  AIOUSB C++ library version: 1.7, 23 December 2009
  AIOUSB library version: 1.84, 22 December 2009
  This program demonstrates controlling a USB-IIRO-16 device on
  the USB bus. For simplicity, it uses the first such device found
  on the bus.
ACCES devices found:
  Device at index 0:
    Product ID: 0x8010
    Product name: USB-IIRO-16
    Serial number: 0x40e399d4e1215a84
    Number of digital I/O ports: 4
    Number of digital I/O channels: 32
    Number of tristate groups: 0
    Number of tristate channels: 0
  Device at index 1:
    Product ID: 0x8040
    Product name: USB-AI16-16A
    Serial number: 0x40e38f15d5c94894
    Number of A/D channels: 16
    Number of MUXed A/D channels: 16
    Number of digital I/O ports: 2
    Number of digital I/O channels: 16
    Number of tristate groups: 0
    Number of tristate channels: 0
    Number of counter blocks: 1
    Number of counters: 3
EEPROM contents:
[ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff,
 ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff,
 ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff,
 ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff,
 ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff,
 ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff,
 ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff,
 ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff,
 ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff,
 ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff,
 ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff,
 ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff,
 ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff,
 ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff,
 ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff,
 ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff,
 ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff,
 ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff,
 ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff,
 ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff,
 ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff,
 ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff,
 ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff,
 ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff,
 ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff,
 ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff,
 ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff,
 ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff,
 ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff,
 ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff,
 ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff,
 ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff]
Configuring digital I/O ... successful
In the following demonstrations, you should hear the relays click
and see the LED on the device blink.
  CLosing relays: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
  Opening relays: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Closing all relays ... successful
Opening all relays ... successful
CLosing every other relay: 0 2 4 6 8 10 12 14
Reading back relays:
  Channel 0 = 0
  Channel 1 = 1
  Channel 2 = 0
  Channel 3 = 1
  Channel 4 = 0
  Channel 5 = 1
  Channel 6 = 0
  Channel 7 = 1
  Channel 8 = 0
  Channel 9 = 1
  Channel 10 = 0
  Channel 11 = 1
  Channel 12 = 0
  Channel 13 = 1
  Channel 14 = 0
  Channel 15 = 1
Reading isolated inputs:
  Channel 16 = 0
  Channel 17 = 0
  Channel 18 = 0
  Channel 19 = 0
  Channel 20 = 0
  Channel 21 = 0
  Channel 22 = 0
  Channel 23 = 0
  Channel 24 = 0
  Channel 25 = 0
  Channel 26 = 0
  Channel 27 = 0
  Channel 28 = 0
  Channel 29 = 0
  Channel 30 = 0
  Channel 31 = 0

Java Sample

Sample.java is a Java implementation of the above sample program. It demonstrates use of the Java class library, which is nearly identical to the C++ class library. Refer to AIOUSB Java Class Library Reference for detailed documentation on the Java class library.

Building

The prerequisites for building Sample.class are that the Java Development Kit (JDK) must be installed. In addition, the AIOUSB Java library (aiousb.jar) must be installed somewhere on your system. To compile the program, either use the supplied Makefile or use the command:

javac -cp ../../java/aiousb.jar Sample.java

This sample program can demonstrate writing to the EEPROM. That demonstration is disabled by default, but if you wish to enable it, simply edit Sample.java and set the variable named DEMO_EEPROM_WRITE to true.

Executing

To execute the program, attach a USB-IIRO-16 analog input board to the USB bus and verify that its LED turns on, indicating that firmware has been successfully uploaded to the board. Then type the command:

java -cp ../../java/aiousb.jar:. Sample

Notice that multiple class paths are specified in the above command: the path to aiousb.jar and ".", which represents the class path of Sample.class (assuming that it is the current directory).

Alternatively, assuming you used the make file to build the program, you can run it with the command:

java -jar Sample.jar

There are no command line arguments to worry about. The program will search for the first USB-IIRO-16 analog input board on the USB bus. If it fails to find such a board, it will print an error message and quit. If it finds such a board, the following output will appear:

USB-IIRO-16 sample program version: 1.4, 25 December 2009
  AIOUSB Java library version: 1.6, 17 December 2009     
  AIOUSB library version: 1.84, 22 December 2009         
  JRE version: 1.6.0_17 
  OS version: Linux amd64 2.6.31.5-0.1-custom            
  This program demonstrates controlling a USB-IIRO-16 device on                           
  the USB bus. For simplicity, it uses the first such device found                        
  on the bus.
ACCES devices found:
  Device at index 0
    Product ID: 0x8010
    Product name: USB-IIRO-16
    Serial number: 0x40e399d4e1215a84
    Number of digital I/O ports: 4
    Number of digital I/O channels: 32
    Number of tristate groups: 0                         
    Number of tristate channels: 0                       
  Device at index 1
    Product ID: 0x8040
    Product name: USB-AI16-16A
    Serial number: 0x40e38f15d5c94894
    Number of A/D channels: 16
    Number of MUXed A/D channels: 16
    Number of digital I/O ports: 2
    Number of digital I/O channels: 16
    Number of tristate groups: 0
    Number of tristate channels: 0                       
    Number of counter blocks: 1
    Number of counters: 3
EEPROM contents:
[-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
Configuring digital I/O ... successful
In the following demonstrations, you should hear the relays click
and see the LED on the device blink.
  CLosing relays: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
  Opening relays: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Closing all relays ... successful
Opening all relays ... successful
CLosing every other relay: 0 2 4 6 8 10 12 14
Reading back relays:
  Channel 0 = false
  Channel 1 = true
  Channel 2 = false
  Channel 3 = true
  Channel 4 = false
  Channel 5 = true
  Channel 6 = false
  Channel 7 = true
  Channel 8 = false
  Channel 9 = true
  Channel 10 = false
  Channel 11 = true
  Channel 12 = false
  Channel 13 = true
  Channel 14 = false
  Channel 15 = true
Reading isolated inputs:
  Channel 16 = false
  Channel 17 = false
  Channel 18 = false
  Channel 19 = false
  Channel 20 = false
  Channel 21 = false
  Channel 22 = false
  Channel 23 = false
  Channel 24 = false
  Channel 25 = false
  Channel 26 = false
  Channel 27 = false
  Channel 28 = false
  Channel 29 = false
  Channel 30 = false
  Channel 31 = false