Basic Image AlgorithmS Library
2.8.0
|
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_ |
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.
Definition at line 63 of file SerialPortIO.hh.
SerialPortIO::SerialPortIO | ( | bool | verbose = true | ) |
standard constructor
verbose | Print messages if port cannot be opened |
Definition at line 46 of file SerialPortIO.cpp.
|
virtual |
standard destructor
Definition at line 52 of file SerialPortIO.cpp.
bool SerialPortIO::ClosePort | ( | ) |
Close port.
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
message[in],: | the message to extract the RFID from |
rfig[out],: | the rfid extracted from the message string |
Definition at line 534 of file SerialPortIO.cpp.
bool SerialPortIO::OpenPort | ( | std::string | port | ) |
Open port, e.g.
/dev/ttyUSB0, or COM0
LINUX
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
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
message[in],: | the read string |
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.
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
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.
message[in],: | the message to write to the port |
nrBytes[in],: | the number of bytes to write to the port |
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.
message[in],: | the message to write to the port |
Definition at line 477 of file SerialPortIO.cpp.
|
protected |
Definition at line 147 of file SerialPortIO.hh.
|
protected |
File descriptor for the port.
Definition at line 145 of file SerialPortIO.hh.
|
protected |
Definition at line 149 of file SerialPortIO.hh.