Public Member Functions | Private Attributes | List of all members
SerialPort Class Reference

Helper class to simplify interfacing with serial port hardware. More...

#include <igvc/SerialPort.h>

Public Member Functions

std::string devicePath ()
 Returns the path to the device this port is connected to. More...
 
bool isOpen ()
 Returns true if the serial port is connected and open. More...
 
char read ()
 Reads a single byte from the serial port. More...
 
char * read (int numBytes)
 Reads numBytes bytes from the serial port. More...
 
std::string readln ()
 Reads bytes from the serial port until
or is found. More...
 
 SerialPort (std::string device, int baud)
 The constructor takes in the path to the port (eg. "/dev/ttyUSB0") and a baud rate for the connection and opens the connection. More...
 
void write (std::string msg)
 Writes the given string to the serial port. More...
 
void write (char *buffer, int length)
 Writes the given array of chars to the serial port. More...
 
void write (unsigned char *buffer, int length)
 Writes the given array of unsigned chars to the serial port. More...
 
 ~SerialPort ()
 

Private Attributes

boost::asio::io_service ioservice
 
std::string path
 
boost::asio::serial_port port
 

Detailed Description

Helper class to simplify interfacing with serial port hardware.

Definition at line 14 of file SerialPort.h.

Constructor & Destructor Documentation

SerialPort::SerialPort ( std::string  device,
int  baud 
)

The constructor takes in the path to the port (eg. "/dev/ttyUSB0") and a baud rate for the connection and opens the connection.

Definition at line 7 of file SerialPort.cpp.

SerialPort::~SerialPort ( )

Definition at line 31 of file SerialPort.cpp.

Member Function Documentation

string SerialPort::devicePath ( )

Returns the path to the device this port is connected to.

Returns
String containing path to device.

Definition at line 98 of file SerialPort.cpp.

bool SerialPort::isOpen ( )

Returns true if the serial port is connected and open.

Definition at line 36 of file SerialPort.cpp.

char SerialPort::read ( )

Reads a single byte from the serial port.

Returns
The byte read.

Definition at line 58 of file SerialPort.cpp.

char * SerialPort::read ( int  numBytes)

Reads numBytes bytes from the serial port.

Returns
An array containing the read bytes.

Definition at line 74 of file SerialPort.cpp.

string SerialPort::readln ( )

Reads bytes from the serial port until
or is found.

Returns
String containing the bytes read excluding the newline.

Definition at line 84 of file SerialPort.cpp.

void SerialPort::write ( std::string  msg)

Writes the given string to the serial port.

void SerialPort::write ( char *  buffer,
int  length 
)

Writes the given array of chars to the serial port.

Definition at line 47 of file SerialPort.cpp.

void SerialPort::write ( unsigned char *  buffer,
int  length 
)

Writes the given array of unsigned chars to the serial port.

Definition at line 52 of file SerialPort.cpp.

Member Data Documentation

boost::asio::io_service SerialPort::ioservice
private

Definition at line 55 of file SerialPort.h.

std::string SerialPort::path
private

Definition at line 57 of file SerialPort.h.

boost::asio::serial_port SerialPort::port
private

Definition at line 56 of file SerialPort.h.


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


igvc
Author(s): Matthew Barulic , Al Chaussee
autogenerated on Sun May 10 2015 16:18:45