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

ArSerialConnection Class Reference

For connecting to devices through a serial port. More...

#include <ArSerialConnection.h>

Inheritance diagram for ArSerialConnection:

ArDeviceConnection List of all members.

Public Types

enum  Open {
  OPEN_COULD_NOT_OPEN_PORT = 1, OPEN_COULD_NOT_SET_UP_PORT, OPEN_INVALID_BAUD_RATE, OPEN_COULD_NOT_SET_BAUD,
  OPEN_ALREADY_OPEN
}

Public Member Functions

 ArSerialConnection ()
 Constructor.
virtual bool close (void)
 Closes the connection.
int getBaud (void)
 Gets what the current baud rate is set to.
bool getCTS (void)
 Sees how the CTS line is set (true = high).
bool getDCD (void)
 Sees how the DCD line is set (true = high).
bool getDSR (void)
 Sees how the DSR line is set (true = high).
bool getHardwareControl (void)
 Gets whether the hardware control lines are enabled or disabled.
virtual const char * getOpenMessage (int messageNumber)
 Gets the string of the message associated with opening the device.
const char * getPort (void)
bool getRing (void)
 Sees how the Ring line is set (true = high).
virtual int getStatus (void)
 Gets the status of the connection, which is one of the enum status.
virtual ArTime getTimeRead (int index)
 Gets the time data was read in.
int internalOpen (void)
virtual bool isTimeStamping (void)
 sees if timestamping is really going on or not
int open (const char *port=NULL)
virtual bool openSimple (void)
 Opens the connection again, using the values from setLocation or.
virtual int read (const char *data, unsigned int size, unsigned int msWait=0)
 Reads data from connection.
bool setBaud (int baud)
 Sets the baud rate on the connection.
bool setHardwareControl (bool hardwareControl)
 Sets whether to enable or disable the hardware control lines.
void setPort (const char *port=NULL)
virtual int write (const char *data, unsigned int size)
 Writes data to connection.
virtual ~ArSerialConnection ()
 Destructor also closes the connection.

Protected Member Functions

int baudToRate (int baud)
void buildStrMap (void)
int rateToBaud (int rate)
void startTimeStamping (void)

Protected Attributes

int myBaudRate
bool myHardwareControl
int myPort
std::string myPortName
int myStatus
ArStrMap myStrMap
bool myTakingTimeStamps

Detailed Description

For connecting to devices through a serial port.

Definition at line 40 of file ArSerialConnection.h.


Member Enumeration Documentation

enum ArSerialConnection::Open
 

Enumeration values:
OPEN_COULD_NOT_OPEN_PORT  Could not open the port.
OPEN_COULD_NOT_SET_UP_PORT  Could not set up the port.
OPEN_INVALID_BAUD_RATE  Baud rate is not valid.
OPEN_COULD_NOT_SET_BAUD  Baud rate valid, but could not set it.
OPEN_ALREADY_OPEN  Connection was already open.

Definition at line 96 of file ArSerialConnection.h.


Member Function Documentation

bool ArSerialConnection::close void   )  [virtual]
 

Closes the connection.

Returns:
whether the close succeeded or not

Reimplemented from ArDeviceConnection.

Definition at line 201 of file ArSerialConnection_LIN.cpp.

References ArLog::log().

Referenced by ~ArSerialConnection().

int ArSerialConnection::getBaud void   ) 
 

Gets what the current baud rate is set to.

Returns:
the current baud rate of the connection

Definition at line 287 of file ArSerialConnection_LIN.cpp.

Referenced by ArRobot::asyncConnectHandler().

bool ArSerialConnection::getHardwareControl void   ) 
 

Gets whether the hardware control lines are enabled or disabled.

Returns:
true if hardware control of lines is enabled, false otherwise

Definition at line 364 of file ArSerialConnection_LIN.cpp.

const char * ArSerialConnection::getOpenMessage int  messageNumber  )  [virtual]
 

Gets the string of the message associated with opening the device.

Each class inherited from this one has an open method which returns 0 for success or an integer which can be passed into this function to obtain a string describing the reason for failure

Parameters:
messageNumber the number returned from the open
Returns:
the error description associated with the messageNumber

Implements ArDeviceConnection.

Definition at line 69 of file ArSerialConnection_LIN.cpp.

const char * ArSerialConnection::getPort void   ) 
 

Gets the port this is using

See also:
ArUtil::COM1, ArUtil::COM2, ArUtil::COM3, ArUtil::COM4

Definition at line 184 of file ArSerialConnection_LIN.cpp.

Referenced by ArSimpleConnector::setupRobot().

int ArSerialConnection::getStatus void   )  [virtual]
 

Gets the status of the connection, which is one of the enum status.

Gets the status of the connection, which is one of the enum status. If you want to get a string to go along with the number, use getStatusMessage

Returns:
the status of the connection
See also:
getStatusMessage

Implements ArDeviceConnection.

Definition at line 447 of file ArSerialConnection_LIN.cpp.

Referenced by setBaud(), and setHardwareControl().

ArTime ArSerialConnection::getTimeRead int  index  )  [virtual]
 

Gets the time data was read in.

Parameters:
index looks like this is the index back in the number of bytes last read in
Returns:
the time the last read data was read in

Implements ArDeviceConnection.

Definition at line 452 of file ArSerialConnection_LIN.cpp.

References ArTime::setMSec(), ArTime::setSec(), and ArTime::setToNow().

bool ArSerialConnection::isTimeStamping void   )  [virtual]
 

sees if timestamping is really going on or not

Returns:
true if real timestamping is happening, false otherwise

Implements ArDeviceConnection.

Definition at line 479 of file ArSerialConnection_LIN.cpp.

int ArSerialConnection::open const char *  port = NULL  ) 
 

Opens the serial port

See also:
ArUtil::COM1, ArUtil::COM2, ArUtil::COM3, ArUtil::COM4

Definition at line 195 of file ArSerialConnection_LIN.cpp.

References setPort().

int ArSerialConnection::read const char *  data,
unsigned int  size,
unsigned int  msWait = 0
[virtual]
 

Reads data from connection.

Reads data from connection

Parameters:
data pointer to a character array to read the data into
size maximum number of bytes to read
msWait read blocks for this many milliseconds (not at all for == 0)
Returns:
number of bytes read, or -1 for failure
See also:
write, writePacket

Implements ArDeviceConnection.

Definition at line 399 of file ArSerialConnection_LIN.cpp.

References ArTime::addMSec(), ArLog::log(), ArTime::mSecTo(), and ArTime::setToNow().

bool ArSerialConnection::setBaud int  baud  ) 
 

Sets the baud rate on the connection.

Parameters:
rate the baud rate to set the connection to
Returns:
whether the set succeeded
See also:
getBaud

Definition at line 231 of file ArSerialConnection_LIN.cpp.

References getStatus(), and ArLog::log().

Referenced by ArRobot::asyncConnectHandler(), ArSick::disconnect(), ArRobot::disconnect(), ArSick::internalConnectHandler(), and ArSimpleConnector::setupRobot().

bool ArSerialConnection::setHardwareControl bool  hardwareControl  ) 
 

Sets whether to enable or disable the hardware control lines.

Parameters:
hardwareControl true to enable hardware control of lines
Returns:
true if the set succeeded

Definition at line 336 of file ArSerialConnection_LIN.cpp.

References getStatus(), and ArLog::log().

void ArSerialConnection::setPort const char *  port = NULL  ) 
 

Sets the port this connection will use

See also:
ArUtil::COM1, ArUtil::COM2, ArUtil::COM3, ArUtil::COM4

Definition at line 173 of file ArSerialConnection_LIN.cpp.

Referenced by open(), ArSimpleConnector::setupLaserArbitrary(), and ArSimpleConnector::setupRobot().

int ArSerialConnection::write const char *  data,
unsigned int  size
[virtual]
 

Writes data to connection.

Writes data to connection

Parameters:
data pointer to a character array to write the data from
size number of bytes to write
Returns:
number of bytes read, or -1 for failure
See also:
read, writePacket

Implements ArDeviceConnection.

Definition at line 369 of file ArSerialConnection_LIN.cpp.

References ArLog::log().


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