Main Page   Class Hierarchy   Compound List   Compound Members  

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 Methods

 ArSerialConnection (void)
 Constructor.

virtual ~ArSerialConnection (void)
 Destructor also closes the connection.

int open (const char *port=NULL)
 Opens the serial port. More...

void setPort (const char *port=NULL)
 Sets the port this will use. More...

const char * getPort (void)
 Gets the port this is using. More...

virtual bool openSimple (void)
 Opens the connection again, using the values from setLocation or.

virtual int getStatus (void)
 Gets the status of the connection, which is one of the enum status. More...

virtual bool close (void)
 Closes the connection. More...

virtual int read (const char *data, unsigned int size, unsigned int msWait=0)
 Reads data from connection. More...

virtual int write (const char *data, unsigned int size)
 Writes data to connection. More...

virtual std::string getOpenMessage (int messageNumber)
 Gets the string of the message associated with opening the device. More...

bool setBaud (int baud)
 Sets the baud rate on the connection. More...

int getBaud (void)
 Gets what the current baud rate is set to. More...

bool setHardwareControl (bool hardwareControl)
 Sets whether to enable or disable the hardware control lines. More...

bool getHardwareControl (void)
 Gets whether the hardware control lines are enabled or disabled. More...

virtual ArTime getTimeRead (int index)
 Gets the time data was read in. More...

virtual bool isTimeStamping (void)
 sees if timestamping is really going on or not. More...


Detailed Description

For connecting to devices through a serial port.


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.


Member Function Documentation

bool ArSerialConnection::close void    [virtual]
 

Closes the connection.

Returns:
whether the close succeeded or not

Reimplemented from ArDeviceConnection.

int ArSerialConnection::getBaud void   
 

Gets what the current baud rate is set to.

Returns:
the current baud rate of the connection

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

std::string 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

Reimplemented from ArDeviceConnection.

const char * ArSerialConnection::getPort void   
 

Gets the port this is using.

Returns:
The seiral port to connect to

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

Reimplemented from ArDeviceConnection.

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

Reimplemented from ArDeviceConnection.

bool ArSerialConnection::isTimeStamping void    [virtual]
 

sees if timestamping is really going on or not.

Returns:
true if real timestamping is happening, false otherwise

Reimplemented from ArDeviceConnection.

int ArSerialConnection::open const char *    port = NULL
 

Opens the serial port.

Parameters:
port  The serial port to connect to, or NULL which defaults to COM1 for windows and /dev/ttyS0 for linux
Returns:
0 for success, otherwise one of the open enums
See also:
getOpenMessage

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

Reimplemented from ArDeviceConnection.

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

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

void ArSerialConnection::setPort const char *    port = NULL
 

Sets the port this will use.

Parameters:
port  The serial port to connect to, or NULL which defaults to COM1 for windows and /dev/ttyS0 for linux
See also:
getOpenMessage

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

Reimplemented from ArDeviceConnection.


The documentation for this class was generated from the following files:
Generated on Tue Nov 12 17:44:04 2002 for Aria by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001