port_handler.h
Go to the documentation of this file.
1 /*******************************************************************************
2 * Copyright 2017 ROBOTIS CO., LTD.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *******************************************************************************/
16 
21 
22 #ifndef DYNAMIXEL_SDK_INCLUDE_DYNAMIXEL_SDK_PORTHANDLER_H_
23 #define DYNAMIXEL_SDK_INCLUDE_DYNAMIXEL_SDK_PORTHANDLER_H_
24 
25 #if defined(__linux__)
26 #define WINDECLSPEC
27 #elif defined(__APPLE__)
28 #define WINDECLSPEC
29 #elif defined(_WIN32) || defined(_WIN64)
30  #ifdef WINDLLEXPORT
31  #define WINDECLSPEC __declspec(dllexport)
32  #else
33  #define WINDECLSPEC __declspec(dllimport)
34  #endif
35 #elif defined(ARDUINO) || defined(__OPENCR__) || defined(__OPENCM904__)
36 #define WINDECLSPEC
37 #endif
38 
39 #ifdef __GNUC__
40 #define DEPRECATED __attribute__((deprecated))
41 #elif defined(_MSC_VER)
42 #define DEPRECATED __declspec(deprecated)
43 #else
44 #pragma message("WARNING: You need to implement DEPRECATED for this compiler")
45 #define DEPRECATED
46 #endif
47 
48 #include <stdint.h>
49 
50 namespace dynamixel
51 {
52 
56 class WINDECLSPEC PortHandler
57 {
58  public:
59  static const int DEFAULT_BAUDRATE_ = 57600;
60 
65  static PortHandler *getPortHandler(const char *port_name);
66 
67  bool is_using_;
68 
69  virtual ~PortHandler() { }
70 
76  virtual bool openPort() = 0;
77 
82  virtual void closePort() = 0;
83 
88  virtual void clearPort() = 0;
89 
95  virtual void setPortName(const char* port_name) = 0;
96 
102  virtual char *getPortName() = 0;
103 
112  virtual bool setBaudRate(const int baudrate) = 0;
113 
119  virtual int getBaudRate() = 0;
120 
127  virtual int getBytesAvailable() = 0;
128 
139  virtual int readPort(uint8_t *packet, int length) = 0;
140 
151  virtual int writePort(uint8_t *packet, int length) = 0;
152 
158  virtual void setPacketTimeout(uint16_t packet_length) = 0;
159 
165  virtual void setPacketTimeout(double msec) = 0;
166 
171  virtual bool isPacketTimeout() = 0;
172 };
173 
174 }
175 
176 
177 #endif /* DYNAMIXEL_SDK_INCLUDE_DYNAMIXEL_SDK_PORTHANDLER_H_ */
The class for port control that inherits PortHandlerLinux, PortHandlerWindows, PortHandlerMac, or PortHandlerArduino.
Definition: port_handler.h:56
bool is_using_
shows whether the port is in use
Definition: port_handler.h:67


dynamixel_sdk
Author(s): Gilbert , Zerom , Darby Lim , Leon
autogenerated on Fri Apr 16 2021 02:25:55