rplidar_driver_serial.h
Go to the documentation of this file.
1 /*
2  * RPLIDAR SDK
3  *
4  * Copyright (c) 2009 - 2014 RoboPeak Team
5  * http://www.robopeak.com
6  * Copyright (c) 2014 - 2019 Shanghai Slamtec Co., Ltd.
7  * http://www.slamtec.com
8  *
9  */
10 /*
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions are met:
13  *
14  * 1. Redistributions of source code must retain the above copyright notice,
15  * this list of conditions and the following disclaimer.
16  *
17  * 2. Redistributions in binary form must reproduce the above copyright notice,
18  * this list of conditions and the following disclaimer in the documentation
19  * and/or other materials provided with the distribution.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
23  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
25  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
26  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
28  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
30  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
31  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  *
33  */
34 
35 #pragma once
36 
37 namespace rp { namespace standalone{ namespace rplidar {
38 
40 {
41 public:
44 
45  SerialChannelDevice():_rxtxSerial(rp::hal::serial_rxtx::CreateRxTx()){}
46 
47  bool bind(const char * portname, uint32_t baudrate)
48  {
49  _closePending = false;
50  return _rxtxSerial->bind(portname, baudrate);
51  }
52  bool open()
53  {
54  return _rxtxSerial->open();
55  }
56  void close()
57  {
58  _closePending = true;
59  _rxtxSerial->cancelOperation();
60  _rxtxSerial->close();
61  }
62  void flush()
63  {
64  _rxtxSerial->flush(0);
65  }
66  bool waitfordata(size_t data_count,_u32 timeout = -1, size_t * returned_size = NULL)
67  {
68  if (_closePending) return false;
69  return (_rxtxSerial->waitfordata(data_count, timeout, returned_size) == rp::hal::serial_rxtx::ANS_OK);
70  }
71  int senddata(const _u8 * data, size_t size)
72  {
73  return _rxtxSerial->senddata(data, size) ;
74  }
75  int recvdata(unsigned char * data, size_t size)
76  {
77  size_t lenRec = 0;
78  lenRec = _rxtxSerial->recvdata(data, size);
79  return lenRec;
80  }
81  void setDTR()
82  {
83  _rxtxSerial->setDTR();
84  }
85  void clearDTR()
86  {
87  _rxtxSerial->clearDTR();
88  }
89  void ReleaseRxTx()
90  {
92  }
93 };
94 
96 {
97 public:
98 
100  virtual ~RPlidarDriverSerial();
101  virtual u_result connect(const char * port_path, _u32 baudrate, _u32 flag = 0);
102  virtual void disconnect();
103 
104 };
105 
106 }}}
virtual int recvdata(unsigned char *data, size_t size)=0
virtual void cancelOperation()
Definition: abs_rxtx.h:74
virtual bool bind(const char *portname, _u32 baudrate, _u32 flags=0)=0
_u8 flag
Definition: rplidar_cmd.h:2
int senddata(const _u8 *data, size_t size)
_u8 size
virtual void setDTR()=0
virtual int senddata(const unsigned char *data, size_t size)=0
static void ReleaseRxTx(serial_rxtx *)
uint8_t _u8
Definition: rptypes.h:63
virtual bool open()=0
virtual void close()=0
int recvdata(unsigned char *data, size_t size)
virtual void clearDTR()=0
virtual int waitfordata(size_t data_count, _u32 timeout=-1, size_t *returned_size=NULL)=0
uint32_t _u32
Definition: rptypes.h:69
virtual void flush(_u32 flags)=0
_u8 data[0]
bool bind(const char *portname, uint32_t baudrate)
bool waitfordata(size_t data_count, _u32 timeout=-1, size_t *returned_size=NULL)
uint32_t u_result
Definition: rptypes.h:100


rplidar_ros
Author(s):
autogenerated on Wed Mar 20 2019 07:54:15