Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Member Functions | Protected Attributes | List of all members
BIAS::SerialPortIO Class Reference

Communication over the serial port, use OpenPort with e.g. More...

#include <Utils/SerialPortIO.hh>

Public Member Functions

bool ClosePort ()
 Close port. More...
 
bool GetPetScanRFIDFromString (std::string message, std::string &rfid)
 parses values of PetScan RT100 V5 format Start Chip Value *Control U FDXB945 000000869846*FFA9 More...
 
bool OpenPort (std::string port)
 Open port, e.g. More...
 
int ReadBytes (unsigned char *message, int nrBytes, bool waitForMessage=true)
 Read bytes from the port, port has to be open. More...
 
bool ReadString (std::string &message, bool waitForMessage=true)
 Read a string from port, port has to be open. More...
 
 SerialPortIO (bool verbose=true)
 standard constructor More...
 
bool SetOptions (unsigned baudrate=9600, SerialPortParityMode parity=SPPM_NoParity, bool hardwareFlowControl=false, bool canonicalInput=true, bool softwareFlowControl=false, int stopbits=1)
 Set Options for opened port, use OpenPort before. More...
 
bool SetTimeOuts (int ReadIntervalTimeout, int ReadTotalTimeoutMultiplier, int ReadTotalTimeoutConstant, int WriteTotalTimeoutMultiplier, int WriteTotalTimeoutConstant)
 in linux all exept ReadTotalTimeoutConstant is ignored More...
 
bool WriteBytes (unsigned char *message, int nrBytes)
 Write bytes to the port, port has to be open. More...
 
bool WriteString (std::string message)
 Write a string to the port, port has to be open. More...
 
virtual ~SerialPortIO ()
 standard destructor More...
 

Protected Attributes

bool bIsOpen_
 
int serialFD_
 File descriptor for the port. More...
 
bool verbose_
 

Detailed Description

Communication over the serial port, use OpenPort with e.g.

/dev/ttyUSB0 or COM0 to open a port for communication. Default Options will be set when opening the port. if you need other options use the set SetOptions function You can read or write a string to the port. For the PetScan RT100 V5 format a function to get the RFID tag from a read string is given.

Date
Nov 23, 2010
Author
: ischiller
Examples:
ExampleSerialIO.cpp.

Definition at line 63 of file SerialPortIO.hh.

Constructor & Destructor Documentation

SerialPortIO::SerialPortIO ( bool  verbose = true)

standard constructor

Parameters
verbosePrint messages if port cannot be opened

Definition at line 46 of file SerialPortIO.cpp.

SerialPortIO::~SerialPortIO ( )
virtual

standard destructor

Definition at line 52 of file SerialPortIO.cpp.

Member Function Documentation

bool SerialPortIO::ClosePort ( )

Close port.

Returns
true on success, false on failure to close

Definition at line 99 of file SerialPortIO.cpp.

bool SerialPortIO::GetPetScanRFIDFromString ( std::string  message,
std::string &  rfid 
)

parses values of PetScan RT100 V5 format Start Chip Value *Control U FDXB945 000000869846*FFA9

Parameters
message[in],:the message to extract the RFID from
rfig[out],:the rfid extracted from the message string
Returns
true on success, false on failure to close
Examples:
ExampleSerialIO.cpp.

Definition at line 534 of file SerialPortIO.cpp.

bool SerialPortIO::OpenPort ( std::string  port)

Open port, e.g.

/dev/ttyUSB0, or COM0

Returns
true on success, false on failure to open

LINUX

Examples:
ExampleSerialIO.cpp.

Definition at line 58 of file SerialPortIO.cpp.

int SerialPortIO::ReadBytes ( unsigned char *  message,
int  nrBytes,
bool  waitForMessage = true 
)

Read bytes from the port, port has to be open.

\param waitForMessage[in]: if this parameter is true the call
to this function will block until something is read from the port
if it is false it will return immediately
\param message[out]: the preallocated buffer of size nrBytes to write message to
\param nrBytes[out]: the number of bytes which are read from the port
Returns
number of bytes read

Definition at line 433 of file SerialPortIO.cpp.

bool SerialPortIO::ReadString ( std::string &  message,
bool  waitForMessage = true 
)

Read a string from port, port has to be open.

\param waitForMessage[in]: if this parameter is true the call
to this function will block until something is read from the port
if it is false it will return immediately
Parameters
message[in],:the read string
Examples:
ExampleSerialIO.cpp.

Definition at line 378 of file SerialPortIO.cpp.

bool SerialPortIO::SetOptions ( unsigned  baudrate = 9600,
SerialPortParityMode  parity = SPPM_NoParity,
bool  hardwareFlowControl = false,
bool  canonicalInput = true,
bool  softwareFlowControl = false,
int  stopbits = 1 
)

Set Options for opened port, use OpenPort before.

Returns
true on success, false on failure to close
Parameters
canonicalInput[in],:set Canonical input (line oriented)

Definition at line 113 of file SerialPortIO.cpp.

References BIAS::SPPM_EvenParity, BIAS::SPPM_NoParity, BIAS::SPPM_OddParity, and BIAS::SPPM_SpaceParity.

bool SerialPortIO::SetTimeOuts ( int  ReadIntervalTimeout,
int  ReadTotalTimeoutMultiplier,
int  ReadTotalTimeoutConstant,
int  WriteTotalTimeoutMultiplier,
int  WriteTotalTimeoutConstant 
)

in linux all exept ReadTotalTimeoutConstant is ignored

Parameters
ReadIntervalTimeout[in],:tenths of seconds to wait for message
ReadTotalTimeoutMultiplier[in],:multiplicative factor for ReadTotalTimeoutConstant
ReadTotalTimeoutConstant[in],:constant to time wait for message
WriteTotalTimeoutMultiplier[in],:multiplicative factor for WriteTotalTimeoutConstant
WriteTotalTimeoutConstant[in],:tenths of seconds to wait befor writing message

Definition at line 344 of file SerialPortIO.cpp.

bool SerialPortIO::WriteBytes ( unsigned char *  message,
int  nrBytes 
)

Write bytes to the port, port has to be open.

Parameters
message[in],:the message to write to the port
nrBytes[in],:the number of bytes to write to the port
Returns
true on success, false on failure to close

Definition at line 506 of file SerialPortIO.cpp.

bool SerialPortIO::WriteString ( std::string  message)

Write a string to the port, port has to be open.

Parameters
message[in],:the message to write to the port
Returns
true on success, false on failure to close

Definition at line 477 of file SerialPortIO.cpp.

Member Data Documentation

bool BIAS::SerialPortIO::bIsOpen_
protected

Definition at line 147 of file SerialPortIO.hh.

int BIAS::SerialPortIO::serialFD_
protected

File descriptor for the port.

Definition at line 145 of file SerialPortIO.hh.

bool BIAS::SerialPortIO::verbose_
protected

Definition at line 149 of file SerialPortIO.hh.


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