SerialPort.h
Go to the documentation of this file.
1 
6 #pragma once
7 #include <string>
8 #include <boost/asio.hpp>
9 
15 {
16 public:
18  SerialPort(std::string device, int baud);
19 
20  ~SerialPort();
21 
23  bool isOpen();
24 
26  void write(std::string msg);
27 
29  void write(char *buffer, int length);
30 
32  void write(unsigned char *buffer, int length);
33 
37  char read();
38 
42  char* read(int numBytes);
43 
47  std::string readln();
48 
52  std::string devicePath();
53 
54 private:
55  boost::asio::io_service ioservice;
56  boost::asio::serial_port port;
57  std::string path;
58 
59 };
char read()
Reads a single byte from the serial port.
Definition: SerialPort.cpp:58
boost::asio::serial_port port
Definition: SerialPort.h:56
std::string readln()
Reads bytes from the serial port until or is found.
Definition: SerialPort.cpp:84
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...
Definition: SerialPort.cpp:7
bool isOpen()
Returns true if the serial port is connected and open.
Definition: SerialPort.cpp:36
void write(std::string msg)
Writes the given string to the serial port.
std::string devicePath()
Returns the path to the device this port is connected to.
Definition: SerialPort.cpp:98
boost::asio::io_service ioservice
Definition: SerialPort.h:55
Helper class to simplify interfacing with serial port hardware.
Definition: SerialPort.h:14
std::string path
Definition: SerialPort.h:57


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