#include <ArVersalogicIO.h>
This class is a basic set of calls to use the Linux device driver, amrio
, which reads and writes data to VersaLogic's Opto22 and analog interfaces. The amrio
driver must be built into the Linux kernel or its module loaded. Contact MobileRobots for information about obtaining this driver. It currently supports the Versalogic VSBC-8d, VSBC-8k, and EBX12 (Cobra) motherboards.
The digital portion of the Opto22 consists of two banks of 8 pins on the VSBC8 and four banks of 8 pins on the EBX12. Each bank can be set as either inputs or outputs. The banks are zero-indexed, so bank0 is the first one.
The analog inputs require a separate chip. There are 8 inputs, only one of which can be read at a time. It currently returns a value between 0 and 4096 or a decimal value in the range of 0-5V. The constructor will attempt an analog conversion, and if it fails will assume that the chip is not present and will disable the analog function.
See the motherboard manual for information about physical connections and specifications of the analog input and Opto22 digital IO. Computer motherboard manuals are available at http://robots.mobilerobots.com/docs .
The SPECIAL_CONTROL_REGISTER contains a few bits of information, the one of importance at the moment is the CPU_OVERTEMPERATURE bit, which will be set high if the CPU temp is over the warning temp as set in the BIOS. Bitwise AND the special_control_register output with 0x20 to find the temperature bit.
The destructor closes the device, so just delete the ArVersalogicIO instance to close the device.
Public Types | |
enum | Direction { DIGITAL_INPUT, DIGITAL_OUTPUT } |
Public Member Functions | |
ArVersalogicIO (const char *dev="/dev/amrio") | |
Constructor. | |
bool | closeIO (void) |
tries to close the device. Returns false if operation failed | |
bool | getAnalogValue (int port, double *val) |
bool | getAnalogValueRaw (int port, int *val) |
Direction | getDigitalBankDirection (int bank) |
returns the direction (input or output) for the given bank | |
bool | getDigitalBankInputs (int bank, unsigned char *val) |
get the current value of the digital inputs on a certain bank | |
bool | getDigitalBankOutputs (int bank, unsigned char *val) |
get the current value of the digital outputs bits on a certain bank | |
bool | getSpecialControlRegister (unsigned char *val) |
gets the special register of the motherboard. | |
bool | isAnalogSupported (void) |
returns true if analog values are supported | |
bool | isEnabled (void) |
returns true if the device is opened and operational | |
int | lock (void) |
lock the amrio device instance | |
bool | setDigitalBankDirection (int bank, Direction dir) |
set direction for a particular digital I/O bank | |
bool | setDigitalBankOutputs (int bank, unsigned char val) |
set the value of the digital outputs bits | |
int | tryLock () |
Try to lock the device instance without blocking. | |
int | unlock (void) |
unlock the amrio device instance | |
virtual | ~ArVersalogicIO (void) |
Destructor. | |
Protected Attributes | |
bool | myAnalogEnabled |
unsigned char | myDigitalBank0 |
unsigned char | myDigitalBank1 |
unsigned char | myDigitalBank2 |
unsigned char | myDigitalBank3 |
ArRetFunctorC< bool, ArVersalogicIO > | myDisconnectCB |
bool | myEnabled |
int | myFD |
int | myNumBanks |
Static Protected Attributes | |
static ArMutex | myMutex |
bool ArVersalogicIO::getAnalogValue | ( | int | port, | |
double * | val | |||
) |
Take an analog reading from a port number from 0-7. This returns a conversion of the bits to a decimal value, currently assumed to be in the 0-5V range
bool ArVersalogicIO::getAnalogValueRaw | ( | int | port, | |
int * | val | |||
) |
Take an analog reading from a port number from 0-7. This returns the actual reading from the chip, which is 12-bits