BufferedAsyncSerial.h
Go to the documentation of this file.
1 /**************************************************************************************************
2  Software License Agreement (BSD License)
3 
4  Copyright (c) 2011-2013, LAR toolkit developers - University of Aveiro - http://lars.mec.ua.pt
5  All rights reserved.
6 
7  Redistribution and use in source and binary forms, with or without modification, are permitted
8  provided that the following conditions are met:
9 
10  *Redistributions of source code must retain the above copyright notice, this list of
11  conditions and the following disclaimer.
12  *Redistributions in binary form must reproduce the above copyright notice, this list of
13  conditions and the following disclaimer in the documentation and/or other materials provided
14  with the distribution.
15  *Neither the name of the University of Aveiro nor the names of its contributors may be used to
16  endorse or promote products derived from this software without specific prior written permission.
17 
18  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
19  IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
20  FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
21  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
24  IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 ***************************************************************************************************/
36 // ORIGINAL BELOW
37 /*
38  * File: BufferedAsyncSerial.h
39  * Author: Terraneo Federico
40  * Distributed under the Boost Software License, Version 1.0.
41  * Created on January 6, 2011, 3:31 PM
42  */
43 
45 
46 #ifndef BUFFEREDASYNCSERIAL_H
47 #define BUFFEREDASYNCSERIAL_H
48 
54  public:
56 
68  BufferedAsyncSerial ( const std::string & devname, unsigned int baud_rate,
69  boost::asio::serial_port_base::parity opt_parity =
70  boost::asio::serial_port_base::parity ( boost::
71  asio::serial_port_base::parity::
72  none ),
73  boost::asio::serial_port_base::character_size opt_csize =
74  boost::asio::serial_port_base::character_size ( 8 ),
75  boost::asio::serial_port_base::flow_control opt_flow =
76  boost::asio::serial_port_base::flow_control ( boost::
77  asio::serial_port_base::flow_control::
78  none ),
79  boost::asio::serial_port_base::stop_bits opt_stop =
80  boost::asio::serial_port_base::stop_bits ( boost::
81  asio::serial_port_base::stop_bits::
82  one ) );
83 
90  size_t read ( char *data, size_t size );
91 
96  std::vector < char >read ( );
97 
105  std::string readString ( );
106 
116  std::string readStringUntil ( const std::string delim = "\n" );
117 
118  virtual ~ BufferedAsyncSerial ( );
119 
120  private:
121 
125  void readCallback ( const char *data, size_t len );
126 
134  static std::vector < char >::iterator findStringInVector ( std::vector < char >&v,
135  const std::string & s );
136 
137  std::vector < char >readQueue;
138  boost::mutex readQueueMutex;
139 };
140 
141 #endif //BUFFEREDASYNCSERIAL_H
void readCallback(const char *data, size_t len)
Asyncronous serial class Asyncronous serial class. Intended to be a base class.
Definition: AsyncSerial.h:66
Asynchronous serial class w/ buffer Asynchronous serial class that sends data to buffer after reading...
std::string readStringUntil(const std::string delim="\n")
Class found to work with asyncronous Serial communications ()
std::vector< char > read()
std::vector< char > readQueue
static std::vector< char >::iterator findStringInVector(std::vector< char > &v, const std::string &s)


pressure_cells
Author(s): Emilio Estrelinha
autogenerated on Mon Mar 2 2015 01:32:47