Software for the AX10410
I decided not to write a device driver, because that will cause to much overhead. To
access the I/O space I used the Linux ioperm function and the macro's in asm/io.h.
Although this is very fast, it has a drawback: only root (or suid root) programs may call
ioperm. (As a kind of workaround I wrote the CtrlUnlock
program.) I also decided not to use any kind of synchronization or protection, also to
keep the speed as high as possible. The accompanying drawback is that all accesses should
take place in one thread, to avoid problems with concurrent accesses.
After some experiments I made 5 functions:
- int CtrlInit(void)
- This function checks the presence of the AX10410 card and the jumper/switch settings as
far as possible. It expects the AX10410 to be set at I/O base 0x310, 16-channel, unipolar
analog input mode. If anything is wrong, it reports an error on stderr and returns -1.
When everything is OK, it returns 0.
- int CtrlAin(int channel)
- This functions reads the specified analog input channel. The channel parameter must
between 0 and 15 (including 0 and 15). It returns a integer where 0 represents 0 Volt and
4095 represents 10 Volts. If the channel parameter is out of bounds, the function returns
-1. After conversion, the result is checked. If something went wrong, an error is reported
on stderr and the function returns -1.
- int CtrlAout(int channel, int value)
- This functions sets the value of an analog output. The channel parameter must be 0 or 1,
the value parameter must be between 0 and 4095 (representing 0 and 10 Volts). If the
channel parameter is out of bounds the function returns -1. If the value parameter is out
of bounds, the value is set to the appropriate limit. If no errors occured, the function
returns the value as written to the analog output.
- int CtrlDin(int bitmask)
- This function returns TRUE if any of the digital inputs in parameter bitmask is
active, else it returns FALSE (0). The least significant bit in bitmask represents digital
- int CtrlDout(int bitmask, int value)
- The digital outputs are set to parameter value. Outputs with corresponding bits clear in
parameter bitmask are not affected. In boolean terms that is : new_outputs = (old_outputs
AND NOT(bitmask)) OR (value AND bitmask). The function returns the new value of all
Because it isn't feasable to run every program as root, I wrote CtrlUnlock. This
executable must be installed SETUID root. You must specify a program to run on the
CtrlUnlock command-line. This program will be given access to the AX10410 I/O space.
Subprocesses started by the program will not get access. All arguments after the program
to run will be passed to the program. An example:
will start wish with access to the I/O space. In wish the Ctrl*
routines can be used now (again: not in any subprocesses started by wish!).
The sources and installation
The current version is 1.1 of 21 June 1999. The sources are distributed as one gzipped
tar file: ctrl-1.1.tar.gz. Unpacking it will create a
subdirectory ctrl. Included in the distribution is a Makefile to compile c.q. build the
object file with the routines and the CtrlUnlock program. Any user may do this. To make
CtrlUnlock SETUID, root must run make install. To use the Ctrl* routines, just
link your program with the Ctrl.o object file.