Aria  2.7.5.2
ArSerialConnection Class Reference

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

#include <ArSerialConnection.h>

Inherits ArDeviceConnection.

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 Types inherited from ArDeviceConnection
enum  Status {
  STATUS_NEVER_OPENED = 1, STATUS_OPEN, STATUS_OPEN_FAILED, STATUS_CLOSED_NORMALLY,
  STATUS_CLOSED_ERROR
}
 

Public Member Functions

 ArSerialConnection (bool is422=false)
 Constructor.
 
virtual bool close (void)
 
int getBaud (void)
 Gets what the current baud rate is set to. More...
 
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. More...
 
virtual const char * getOpenMessage (int messageNumber)
 
const char * getPort (void)
 
bool getRing (void)
 Sees how the Ring line is set (true = high)
 
virtual int getStatus (void)
 
virtual ArTime getTimeRead (int index)
 
int internalOpen (void)
 
virtual bool isTimeStamping (void)
 
int open (const char *port=NULL)
 
virtual bool openSimple (void)
 
virtual int read (const char *data, unsigned int size, unsigned int msWait=0)
 
bool setBaud (int baud)
 
bool setHardwareControl (bool hardwareControl)
 Sets whether to enable or disable the hardware control lines. More...
 
void setPort (const char *port=NULL)
 
virtual int write (const char *data, unsigned int size)
 
virtual ~ArSerialConnection ()
 Destructor also closes the connection.
 
- Public Member Functions inherited from ArDeviceConnection
 ArDeviceConnection ()
 constructor
 
const char * getStatusMessage (int messageNumber) const
 Gets the description string associated with the status. More...
 
virtual int writePacket (ArBasePacket *packet)
 Writes data to connection. More...
 
virtual ~ArDeviceConnection ()
 destructor also forces a close on the connection
 

Protected Member Functions

int baudToRate (int baud)
 
void buildStrMap (void)
 
int rateToBaud (int rate)
 
void startTimeStamping (void)
 
- Protected Member Functions inherited from ArDeviceConnection
void buildStrMap (void)
 

Protected Attributes

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

Additional Inherited Members

- Static Protected Attributes inherited from ArDeviceConnection
static ArStrMap ourStrMap
 
static bool ourStrMapInited = false
 

Detailed Description

For connecting to devices through a serial port.

Examples:
dpptuExample.cpp, rvisionCameraExample.cpp, sonyPTZDemo.cpp, and vcc4CameraExample.cpp.

Member Enumeration Documentation

Enumerator
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

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
const char * ArSerialConnection::getPort ( void  )

Gets the port this is using

See Also
ArUtil::COM1, ArUtil::COM2, ArUtil::COM3, ArUtil::COM4
Returns
The serial port to connect to
The seiral port to connect to
int ArSerialConnection::open ( const char *  port = NULL)

Opens the serial port

Returns
0 on success. Return one of the error codes in the ArSerialConnection::Open enumeration on error.
See Also
ArUtil::COM1, ArUtil::COM2, ArUtil::COM3, ArUtil::COM4
Parameters
portThe 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
Examples:
sonyPTZDemo.cpp.
bool ArSerialConnection::setBaud ( int  baud)

Sets the BAUD rate to use when connection is opened, or change the baud rate if already opened

Parameters
baudthe baud rate to set the connection to
Returns
true if rate was sucessfully set, false otherwise (unsupported rate, system error changing rate on port, etc.)
See Also
getBaud()
bool ArSerialConnection::setHardwareControl ( bool  hardwareControl)

Sets whether to enable or disable the hardware control lines.

Parameters
hardwareControltrue to enable hardware control of lines
Returns
true if the set succeeded
void ArSerialConnection::setPort ( const char *  port = NULL)

Sets the port this connection will use

See Also
ArUtil::COM1, ArUtil::COM2, ArUtil::COM3, ArUtil::COM4
Parameters
portThe serial port to connect to, or NULL which defaults to COM1 for windows and /dev/ttyS0 for linux
See Also
getOpenMessage
Parameters
portThe 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
Examples:
vcc4CameraExample.cpp.

The documentation for this class was generated from the following files: