Public Member Functions | Private Member Functions | Private Attributes
icl_comm::serial::Serial Class Reference

Enables acces to serial devices. More...

#include <Serial.h>

List of all members.

Public Member Functions

int ChangeBaudrate (SerialFlags::BaudRate speed)
int ClearReceiveBuffer ()
int ClearSendBuffer ()
void Close ()
const char * DeviceName () const
int FileDescriptor ()
bool IsOpen () const
bool Open (const SerialFlags &flags)
bool Open ()
ssize_t Read (void *data, ssize_t size, unsigned long time=100, bool return_on_less_data=true)
 Serial (const char *dev_name, const SerialFlags &flags)
 Serial (const char *dev_name, SerialFlags::BaudRate baud_rate, const SerialFlags &flags)
int Status () const
std::string StatusText () const
ssize_t Write (const void *data, ssize_t size)
 ~Serial ()

Private Member Functions

void DumpData (void *data, size_t length)
Serialoperator= (const Serial &)
 Serial (const Serial &)

Private Attributes

char * m_dev_name
SerialFlags m_serial_flags
int m_status

Detailed Description

Enables acces to serial devices.

Open a serial device, change baudrates, read from and write to the device. Status-information after calling the functions get be

Definition at line 60 of file Serial.h.


Constructor & Destructor Documentation

icl_comm::serial::Serial::Serial ( const char *  dev_name,
const SerialFlags flags 
)

Opens the device (if possible) with the given flags.

Parameters:
flagscan be values of the following values ORed together
  • CS5, CS6, CS7, or CS8 databits
  • CSTOPB set two stop bits, rather than one.
  • CREAD enable receiver.
  • PARENB enable parity generation on output and parity checking for input.
  • PARODD parity for input and output is odd.
  • HUPCL lower modem control lines after last process closes the device (hang up).
  • CLOCAL ignore modem control lines
  • B50, B75, B110, B134, B150, B200, B300, B600, B1200, B1800, B2400, B4800, B9600, B19200, B38400, B57600, B115200, B230400, B921600 Baudrates
  • CRTSCTS flow control.

Definition at line 72 of file Serial.cpp.

icl_comm::serial::Serial::Serial ( const char *  dev_name,
SerialFlags::BaudRate  baud_rate,
const SerialFlags flags 
)

This is an overloaded constructor, provided for convenience. buad_rate overwrites the baud rate set in flags.

Definition at line 86 of file Serial.cpp.

Restore old serial settings and close device

Definition at line 983 of file Serial.cpp.

icl_comm::serial::Serial::Serial ( const Serial ) [private]

Member Function Documentation

speed is one of the followind values :

  • B50, B75, B110, B134, B150, B200, B300, B600, B1200, B1800, B2400, B4800, B9600, B19200, B38400, B57600, B115200, B230400, B921600 Returns 0 on success. Returns -status on failure.

Definition at line 353 of file Serial.cpp.

Clears the serial port's receive buffer.

Definition at line 467 of file Serial.cpp.

Clears the serial port's send buffer.

Definition at line 501 of file Serial.cpp.

Close the serial interface.

Definition at line 924 of file Serial.cpp.

const char* icl_comm::serial::Serial::DeviceName ( ) const [inline]

Definition at line 165 of file Serial.h.

void icl_comm::serial::Serial::DumpData ( void *  data,
size_t  length 
) [private]

Definition at line 342 of file Serial.cpp.

Return the file descriptor of the serial class

Definition at line 170 of file Serial.h.

Returns true if the serial interface is opened. false otherwhise.

Definition at line 913 of file Serial.cpp.

bool icl_comm::serial::Serial::Open ( const SerialFlags flags) [inline]

Opens the serial interface with the given flags

Definition at line 115 of file Serial.h.

Opens the serial interface.

Definition at line 101 of file Serial.cpp.

Serial& icl_comm::serial::Serial::operator= ( const Serial ) [private]
ssize_t icl_comm::serial::Serial::Read ( void *  data,
ssize_t  size,
unsigned long  time = 100,
bool  return_on_less_data = true 
)

Read data from device. This function waits until

Parameters:
timeus passed or the respected number of bytes are received via serial line. if (
return_on_less_datais true (default value), the number of bytes that have been receives are returned and the data is stored in
data.If the parameter is false, data is only read from serial line, if at least
sizebytes are available.

Definition at line 621 of file Serial.cpp.

int icl_comm::serial::Serial::Status ( ) const [inline]

All routines return a negavtiv number on error. Then the global errno is stored into a private variable. Use this funtion to ask for this value. Especially the constructor cannot return an error-value. Check the succesful opening of the device by calling this function. It returns 0, if no error occured.

Definition at line 158 of file Serial.h.

std::string icl_comm::serial::Serial::StatusText ( ) const

Definition at line 884 of file Serial.cpp.

ssize_t icl_comm::serial::Serial::Write ( const void *  data,
ssize_t  size 
)

Write data to serial out.

Definition at line 535 of file Serial.cpp.


Member Data Documentation

Definition at line 203 of file Serial.h.

Definition at line 204 of file Serial.h.

Definition at line 205 of file Serial.h.


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


fzi_icl_comm
Author(s):
autogenerated on Thu Jun 6 2019 21:31:31