direcs  2012-09-30
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
DirecsSerial Class Reference

Class to read data from and write data to the serial port. More...

#include <direcsSerial.h>

List of all members.

Signals

void message (QString text)

Public Member Functions

int closePort ()
 DirecsSerial ()
int openPort (char *dev_name, int baudrate)
int purgeRx ()
int readData (unsigned char *buf, int nChars, QString callingClassName="none")
int writeData (unsigned char *c, QString callingClassName="none")
 ~DirecsSerial ()

Private Attributes

QString className
int mDev_fd
 this will contain the name of this class at runtime for debug messages

Detailed Description

Class to read data from and write data to the serial port.

Author:
Markus Knapp This class is used to communicate with laser scanners and with the robot (with the microcontroller).

Definition at line 65 of file direcsSerial.h.


Constructor & Destructor Documentation

DirecsSerial::DirecsSerial ( )

Definition at line 24 of file direcsSerial.cpp.

DirecsSerial::~DirecsSerial ( )

Definition at line 33 of file direcsSerial.cpp.


Member Function Documentation

int DirecsSerial::closePort ( )

Closes the serial port.

Returns:
the results reported by close.

Definition at line 299 of file direcsSerial.cpp.

Here is the caller graph for this function:

void DirecsSerial::message ( QString  text)
signal

Emits a info or error message to a slot. This slot can be used to display a text on a splash screen, log file, to print it to a console...

Here is the caller graph for this function:

int DirecsSerial::openPort ( char *  dev_name,
int  baudrate 
)

Open a connection to the serial line.

The serial port settings (8,N,1) for the serial port are set in this method, too!

Parameters:
dev_namethe name of the serial device, e.g. /dev/ttyUSB0 or /dev/ttyS0
baudrThe baud rate can be B0, B300, B600, B1200, B2400, B4800, B9600, B19200, B38400, B57600, B115200 or B500000.
Returns:
the file descriptor if everything is fine, -1 in case of an error.

Set *TERMIOS_P to indicate raw mode.

Definition at line 38 of file direcsSerial.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

int DirecsSerial::purgeRx ( )

Clears the read buffer.

Returns:
Upon successful completion, this function returns zero.

Clears the read buffer. TCIFLUSH = Flush data received but not read.

Definition at line 199 of file direcsSerial.cpp.

Here is the caller graph for this function:

int DirecsSerial::readData ( unsigned char *  buf,
int  nChars,
QString  callingClassName = "none" 
)

Reads data from the serial line

Parameters:
*bufPointer to unsigned char buffer for the data to be read.
nCharsNumber of bytes to be written (<= size of the buffer array).
callingClassNamemay contain the name of the calling class. This is for debug messages only.
Returns:
The number of bytes read.

Definition at line 228 of file direcsSerial.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

int DirecsSerial::writeData ( unsigned char *  c,
QString  callingClassName = "none" 
)

Writes data to the serial line.

Parameters:
*cPointer to unsiged char buffer to the data to be send over the serial line
callingClassNamemay contain the name of the calling class. This is for debug messages only.
Returns:
The number of bytes sent to the serial line.

Definition at line 209 of file direcsSerial.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

QString DirecsSerial::className
private

Definition at line 127 of file direcsSerial.h.

int DirecsSerial::mDev_fd
private

this will contain the name of this class at runtime for debug messages

Definition at line 129 of file direcsSerial.h.


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