Main MRPT website > C++ reference for MRPT 1.9.9
win32/net_serial.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 /*
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions are met:
12  *
13  * 1. Redistributions of source code must retain the above copyright notice,
14  * this list of conditions and the following disclaimer.
15  *
16  * 2. Redistributions in binary form must reproduce the above copyright notice,
17  * this list of conditions and the following disclaimer in the documentation
18  * and/or other materials provided with the distribution.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  *
32  */
33 
34 #pragma once
35 
36 #include "hal/abs_rxtx.h"
37 
38 namespace rp
39 {
40 namespace arch
41 {
42 namespace net
43 {
44 class raw_serial : public rp::hal::serial_rxtx
45 {
46  public:
47  enum
48  {
53  };
54 
55  raw_serial();
56  virtual ~raw_serial();
57  virtual bool bind(const char* portname, _u32 baudrate, _u32 flags = 0);
58  virtual bool open();
59  virtual void close();
60  virtual void flush(_u32 flags);
61 
62  virtual int waitfordata(
63  size_t data_count, _u32 timeout = -1, size_t* returned_size = nullptr);
64 
65  virtual int senddata(const unsigned char* data, size_t size);
66  virtual int recvdata(unsigned char* data, size_t size);
67 
68  virtual int waitforsent(_u32 timeout = -1, size_t* returned_size = nullptr);
69  virtual int waitforrecv(_u32 timeout = -1, size_t* returned_size = nullptr);
70 
71  virtual size_t rxqueue_count();
72 
73  virtual void setDTR();
74  virtual void clearDTR();
75 
76  protected:
77  bool open(const char* portname, _u32 baudrate, _u32 flags);
78  void _init();
79 
80  char _portName[20];
83 
84  OVERLAPPED _ro, _wo;
85  OVERLAPPED _wait_o;
86  volatile HANDLE _serial_handle;
87  DCB _dcb;
88  COMMTIMEOUTS _co;
89 };
90 }
91 }
92 }
rp::arch::net::raw_serial::_wait_o
OVERLAPPED _wait_o
Definition: win32/net_serial.h:85
rp::arch::net::raw_serial::~raw_serial
virtual ~raw_serial()
Definition: linux/net_serial.cpp:51
rp::arch::net::raw_serial::_co
COMMTIMEOUTS _co
Definition: win32/net_serial.h:88
rp::arch::net::raw_serial::waitforrecv
virtual int waitforrecv(_u32 timeout=-1, size_t *returned_size=nullptr)
Definition: linux/net_serial.cpp:172
rp::arch::net::raw_serial::_baudrate
uint32_t _baudrate
Definition: linux/net_serial.h:82
rp::arch::net::raw_serial::_wo
OVERLAPPED _wo
Definition: win32/net_serial.h:84
rp::arch::net::raw_serial::rxqueue_count
virtual size_t rxqueue_count()
Definition: linux/net_serial.cpp:250
rp::arch::net::raw_serial::SERIAL_RX_TIMEOUT
@ SERIAL_RX_TIMEOUT
Definition: win32/net_serial.h:51
rp::arch::net::raw_serial::_init
void _init()
Definition: linux/net_serial.cpp:275
rp::arch::net::raw_serial::_portName
char _portName[200]
Definition: linux/net_serial.h:81
rp::arch::net::raw_serial::SERIAL_RX_BUFFER_SIZE
@ SERIAL_RX_BUFFER_SIZE
Definition: linux/net_serial.h:49
rp::arch::net::raw_serial::open
virtual bool open()
Definition: linux/net_serial.cpp:52
data
GLsizei GLsizei GLenum GLenum const GLvoid * data
Definition: glext.h:3547
rp::arch::net::raw_serial::_ro
OVERLAPPED _ro
Definition: win32/net_serial.h:84
rp::arch::net::raw_serial::_flags
uint32_t _flags
Definition: linux/net_serial.h:83
rp::arch::net::raw_serial::senddata
virtual int senddata(const unsigned char *data, size_t size)
Definition: linux/net_serial.cpp:132
rp::arch::net::raw_serial::clearDTR
virtual void clearDTR()
Definition: linux/net_serial.cpp:267
rp::arch::net::raw_serial::_dcb
DCB _dcb
Definition: win32/net_serial.h:87
rp::arch::net::raw_serial::bind
virtual bool bind(const char *portname, uint32_t baudrate, uint32_t flags=0)
Definition: linux/net_serial.cpp:53
rp::arch::net::raw_serial::_serial_handle
volatile HANDLE _serial_handle
Definition: win32/net_serial.h:86
rp::arch::net::raw_serial::waitfordata
virtual int waitfordata(size_t data_count, _u32 timeout=-1, size_t *returned_size=nullptr)
Definition: linux/net_serial.cpp:180
rp::arch::net::raw_serial::close
virtual void close()
Definition: linux/net_serial.cpp:124
rp::arch::net::raw_serial::recvdata
virtual int recvdata(unsigned char *data, size_t size)
Definition: linux/net_serial.cpp:154
rp::arch::net::raw_serial::SERIAL_TX_TIMEOUT
@ SERIAL_TX_TIMEOUT
Definition: win32/net_serial.h:52
abs_rxtx.h
rp::arch::net::raw_serial::setDTR
virtual void setDTR()
Definition: linux/net_serial.cpp:259
rp::arch::net::raw_serial::flush
virtual void flush(_u32 flags)
Definition: linux/net_serial.cpp:165
rp::arch::net::raw_serial::waitforsent
virtual int waitforsent(_u32 timeout=-1, size_t *returned_size=nullptr)
Definition: linux/net_serial.cpp:166
rp::hal::serial_rxtx
Definition: abs_rxtx.h:42
rp
Definition: rplidar_driver.h:40
rp::arch::net::raw_serial::raw_serial
raw_serial()
Definition: linux/net_serial.cpp:45
_u32
uint32_t _u32
Definition: rptypes.h:66
size
GLsizeiptr size
Definition: glext.h:3923
uint32_t
unsigned __int32 uint32_t
Definition: rptypes.h:47
rp::arch::net::raw_serial::SERIAL_TX_BUFFER_SIZE
@ SERIAL_TX_BUFFER_SIZE
Definition: linux/net_serial.h:50



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST