#include <SerialDevice.h>
Public Member Functions | |
int | ClosePort () |
int | Flush () |
Clean port buffer. | |
char * | GetDevice () |
Returns opened device. | |
int | OpenPort1 (void) |
int | OpenPort2 (void) |
int | ReadPort (char *result) |
Reads serial port. | |
int | ReadPort (char *result, int num_bytes) |
Reads serial port. | |
int | ReadPort (char *result, int *read_bytes, int num_bytes) |
Reads serial port. | |
int | ReceiveMessage (char *msg) |
int | SendMessage (char *msg, int length) |
SerialDevice (void) | |
SerialDevice (const char *device, int baudrate, const char *parity, int datasize) | |
void | SetCanonicalInput (bool value) |
Sets the Canonical input. False by default. | |
int | WritePort (char *chars, int length) |
Sends commands to the Serial port. | |
int | WritePort (char *chars, int *written_bytes, int length) |
Sends data to the serial port. | |
~SerialDevice (void) | |
Private Member Functions | |
int | GetBaud (void) |
int | InitPort (void) |
int | SetTermSpeed (int speed) |
Set serial communication speed. | |
Private Attributes | |
bool | bCanon |
bool | bReady |
char | cDevice [DEFAULT_SIZE_ARRAY] |
char | cParity [DEFAULT_SIZE_ARRAY] |
int | fd |
int | iBaudRate |
int | iBitDataSize |
unsigned char | RecBuf [BUFFER] |
unsigned char | SendBuf [BUFFER] |
Definition at line 46 of file SerialDevice.h.
SerialDevice::SerialDevice | ( | void | ) |
Constructor by default
Definition at line 47 of file SerialDevice.cc.
SerialDevice::SerialDevice | ( | const char * | device, |
int | baudrate, | ||
const char * | parity, | ||
int | datasize | ||
) |
Definition at line 61 of file SerialDevice.cc.
SerialDevice::~SerialDevice | ( | void | ) |
Destructor by default
Definition at line 76 of file SerialDevice.cc.
int SerialDevice::ClosePort | ( | void | ) |
Closes serial port
Definition at line 316 of file SerialDevice.cc.
int SerialDevice::Flush | ( | ) |
Clean port buffer.
Clean port buffer
Definition at line 592 of file SerialDevice.cc.
int SerialDevice::GetBaud | ( | void | ) | [private] |
Definition at line 466 of file SerialDevice.cc.
char * SerialDevice::GetDevice | ( | ) |
Returns opened device.
Definition at line 598 of file SerialDevice.cc.
int SerialDevice::InitPort | ( | void | ) | [private] |
Set serial communication speed. Valid values: 9600, 19200, 38400, 115200
Initialize port
Definition at line 84 of file SerialDevice.cc.
int SerialDevice::OpenPort1 | ( | void | ) |
Opens serial port for communication
Definition at line 220 of file SerialDevice.cc.
int SerialDevice::OpenPort2 | ( | void | ) |
Opens serial port for communication
Definition at line 245 of file SerialDevice.cc.
int SerialDevice::ReadPort | ( | char * | result | ) |
Reads serial port.
result | as char *, output buffer |
Definition at line 398 of file SerialDevice.cc.
int SerialDevice::ReadPort | ( | char * | result, |
int | num_bytes | ||
) |
Reads serial port.
result | as char *, output buffer |
Definition at line 420 of file SerialDevice.cc.
int SerialDevice::ReadPort | ( | char * | result, |
int * | read_bytes, | ||
int | num_bytes | ||
) |
Reads serial port.
result | as char *, output buffer |
read_bytes | as int, number of read bytes |
num_bytes | as *int, number of desired bytes to read |
Definition at line 446 of file SerialDevice.cc.
int SerialDevice::ReceiveMessage | ( | char * | msg | ) |
Receives commands from SerialDevice
Definition at line 330 of file SerialDevice.cc.
int SerialDevice::SendMessage | ( | char * | msg, |
int | length | ||
) |
Sends commands to the SerialDevice
Definition at line 497 of file SerialDevice.cc.
void SerialDevice::SetCanonicalInput | ( | bool | value | ) |
Sets the Canonical input. False by default.
Definition at line 602 of file SerialDevice.cc.
int SerialDevice::SetTermSpeed | ( | int | speed | ) | [private] |
Set serial communication speed.
Set serial communication speed. Valid values: 9600, 19200, 38400, 115200
std::cout << "SerialDevice::SetTermSpeed: Failed to set serial baud rate" << std::endl;
Definition at line 524 of file SerialDevice.cc.
int SerialDevice::WritePort | ( | char * | chars, |
int | length | ||
) |
Sends commands to the Serial port.
chars | as char*, string for sending |
length | as int, length of the string |
Definition at line 352 of file SerialDevice.cc.
int SerialDevice::WritePort | ( | char * | chars, |
int * | written_bytes, | ||
int | length | ||
) |
Sends data to the serial port.
chars | as char*, string for sending |
written_bytes | as int*, number of written bytes |
length | as int, length of the string |
Definition at line 374 of file SerialDevice.cc.
bool SerialDevice::bCanon [private] |
Definition at line 68 of file SerialDevice.h.
bool SerialDevice::bReady [private] |
Definition at line 54 of file SerialDevice.h.
char SerialDevice::cDevice[DEFAULT_SIZE_ARRAY] [private] |
Definition at line 60 of file SerialDevice.h.
char SerialDevice::cParity[DEFAULT_SIZE_ARRAY] [private] |
Definition at line 62 of file SerialDevice.h.
int SerialDevice::fd [private] |
File descriptor
Definition at line 52 of file SerialDevice.h.
int SerialDevice::iBaudRate [private] |
Definition at line 64 of file SerialDevice.h.
int SerialDevice::iBitDataSize [private] |
Definition at line 66 of file SerialDevice.h.
unsigned char SerialDevice::RecBuf[BUFFER] [private] |
Definition at line 58 of file SerialDevice.h.
unsigned char SerialDevice::SendBuf[BUFFER] [private] |
Definition at line 56 of file SerialDevice.h.