Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

ArVersalogicIO Class Reference

#include <ArVersalogicIO.h>

List of all members.

Public Types

enum  Direction { DIGITAL_INPUT, DIGITAL_OUTPUT }

Public Member Functions

 ArVersalogicIO (const char *dev="/dev/amrio")
 Constructor.
bool getAnalogValue (int port, double *val)
 take an analog reading from a port number from 0-7
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
bool myEnabled
int myFD
int myNumBanks

Static Protected Attributes

static ArMutex myMutex


Detailed Description

This class is a basic set of calls to use the device driver, amrio, which reads and writes data to VersaLogic's Opto22 and analog interfaces. It is currently supported on the VSBC-8d, VSBC-8k, and EBX12 (Cobra)

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 4960, and operates 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.

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.

Definition at line 59 of file ArVersalogicIO.h.


Constructor & Destructor Documentation

ArVersalogicIO::~ArVersalogicIO void   )  [virtual]
 

Destructor.

Destructor. Attempt to close the device if it was opened

Definition at line 105 of file ArVersalogicIO.cpp.

References ArLog::log().


Member Function Documentation

bool ArVersalogicIO::getAnalogValue int  port,
double *  val
 

take an analog reading from a port number from 0-7

Currently not very well tested. Returns a double of the analog value for a given port.

Parameters:
port the port number, between 0 and 7
Returns:
true if a reading was acquired. false otherwise

Definition at line 121 of file ArVersalogicIO.cpp.

References ArLog::log().

bool ArVersalogicIO::getDigitalBankInputs int  bank,
unsigned char *  val
 

get the current value of the digital inputs on a certain bank

Returns the bits of the digital input bank. A zero is 'on' for the hardware side of things, so this function negates it to make it more intuitive.

Returns:
true if the ioctl call was succcessfull, false otherwise

Definition at line 176 of file ArVersalogicIO.cpp.

bool ArVersalogicIO::getDigitalBankOutputs int  bank,
unsigned char *  val
 

get the current value of the digital outputs bits on a certain bank

Returns the state of the bits as they are currently set in the outputs. It doesn't reconfirm with the hardware, but instead keeps track of how it last set them.

Parameters:
bank which bank to check
val the byte to write the values into
Returns:
true if the request was satisfied, false otherwise

Definition at line 220 of file ArVersalogicIO.cpp.

bool ArVersalogicIO::getSpecialControlRegister unsigned char *  val  ) 
 

gets the special register of the motherboard.

The special_control_register contains various status bits, of which can be found in the manuals for the motherboards. One interesting bit is the temperature bit, which gets set high if the CPU is over the specified threshold as set in the BIOS

Definition at line 300 of file ArVersalogicIO.cpp.

bool ArVersalogicIO::setDigitalBankOutputs int  bank,
unsigned char  val
 

set the value of the digital outputs bits

The bits on the hardware side of the digital I/O ports are inverse-logic. The bit must be set high in the register for the output to be off, and be set low to be turned on. This function negates that so that it is more intuitive.

Parameters:
bank the bank number to use. 0 is the lowest bank
val the status of the 8-bits in a single byte.

Definition at line 256 of file ArVersalogicIO.cpp.


Member Data Documentation

ArMutex ArVersalogicIO::myMutex [static, protected]
 

Constructor for the ArVersalogicIO class. This will open the name dev. It will find the number of digital banks and set the to inputs. It will also attempt to take an analog reading, which will fail if there is not analog chip present. If the conversion fails it will disable the analog portion of the code.

Check isEnabled() to see if the device was properly opened

Definition at line 63 of file ArVersalogicIO.cpp.

Referenced by lock(), tryLock(), and unlock().


The documentation for this class was generated from the following files:
Generated on Wed Oct 19 12:56:56 2005 for Aria by  doxygen 1.4.0