Public Member Functions | Private Member Functions | Private Attributes
SerialDevice Class Reference

#include <SerialDevice.h>

List of all members.

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]

Detailed Description

Definition at line 46 of file SerialDevice.h.


Constructor & Destructor Documentation

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.

Destructor by default

Definition at line 76 of file SerialDevice.cc.


Member Function Documentation

int SerialDevice::ClosePort ( void  )

Closes serial port

Definition at line 316 of file SerialDevice.cc.

Clean port buffer.

Clean port buffer

Returns:
SERIAL_OK
SERIAL_ERROR

Definition at line 592 of file SerialDevice.cc.

int SerialDevice::GetBaud ( void  ) [private]

Definition at line 466 of file SerialDevice.cc.

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

Returns:
SERIALDEV_OK
SERIALDEV_ERROR

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.

Parameters:
resultas char *, output buffer
Returns:
number of read bytes

Definition at line 398 of file SerialDevice.cc.

int SerialDevice::ReadPort ( char *  result,
int  num_bytes 
)

Reads serial port.

Parameters:
resultas char *, output buffer
Returns:
number of read bytes

Definition at line 420 of file SerialDevice.cc.

int SerialDevice::ReadPort ( char *  result,
int *  read_bytes,
int  num_bytes 
)

Reads serial port.

Parameters:
resultas char *, output buffer
read_bytesas int, number of read bytes
num_bytesas *int, number of desired bytes to read
Returns:
OK
NOT_INITIALIZED
ERROR

Definition at line 446 of file SerialDevice.cc.

int SerialDevice::ReceiveMessage ( char *  msg)

Receives commands from SerialDevice

Returns:
number of read bytes
SERIAL_ERROR if device is not ready

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

Returns:
SERIAL_OK
SERIAL_ERROR

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.

Parameters:
charsas char*, string for sending
lengthas int, length of the string
Returns:
number of sent bytes

Definition at line 352 of file SerialDevice.cc.

int SerialDevice::WritePort ( char *  chars,
int *  written_bytes,
int  length 
)

Sends data to the serial port.

Parameters:
charsas char*, string for sending
written_bytesas int*, number of written bytes
lengthas int, length of the string
Returns:
operation result

Definition at line 374 of file SerialDevice.cc.


Member Data Documentation

bool SerialDevice::bCanon [private]

Definition at line 68 of file SerialDevice.h.

bool SerialDevice::bReady [private]

Definition at line 54 of file SerialDevice.h.

Definition at line 60 of file SerialDevice.h.

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.

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.


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


s3000_laser
Author(s): Román Navarro
autogenerated on Wed Sep 2 2015 11:43:29