port_handler_linux.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_LINUX_PORTHANDLERLINUX_H_
23 #define DYNAMIXEL_SDK_INCLUDE_DYNAMIXEL_SDK_LINUX_PORTHANDLERLINUX_H_
24 
25 
26 #include "port_handler.h"
27 
28 namespace dynamixel
29 {
30 
35 {
36  private:
38  int baudrate_;
39  char port_name_[100];
40 
44 
45  bool setupPort(const int cflag_baud);
46  bool setCustomBaudrate(int speed);
47  int getCFlagBaud(const int baudrate);
48 
49  double getCurrentTime();
50  double getTimeSinceStart();
51 
52  public:
57  PortHandlerLinux(const char *port_name);
58 
63  virtual ~PortHandlerLinux() { closePort(); }
64 
70  bool openPort();
71 
76  void closePort();
77 
82  void clearPort();
83 
89  void setPortName(const char *port_name);
90 
96  char *getPortName();
97 
106  bool setBaudRate(const int baudrate);
107 
113  int getBaudRate();
114 
121  int getBytesAvailable();
122 
133  int readPort(uint8_t *packet, int length);
134 
145  int writePort(uint8_t *packet, int length);
146 
152  void setPacketTimeout(uint16_t packet_length);
153 
159  void setPacketTimeout(double msec);
160 
165  bool isPacketTimeout();
166 };
167 
168 }
169 
170 
171 #endif /* DYNAMIXEL_SDK_INCLUDE_DYNAMIXEL_SDK_LINUX_PORTHANDLERLINUX_H_ */
int writePort(uint8_t *packet, int length)
The function that writes bytes on the port buffer The function writes bytes on the port buffer...
bool isPacketTimeout()
The function that checks whether packet timeout is occurred The function checks whether current time...
char * getPortName()
The function that returns port name set into the port handler The function returns current port name...
bool setCustomBaudrate(int speed)
void setPacketTimeout(uint16_t packet_length)
The function that sets and starts stopwatch for watching packet timeout The function sets the stopwa...
virtual ~PortHandlerLinux()
The function that closes the port The function calls PortHandlerLinux::closePort() to close the port...
bool setBaudRate(const int baudrate)
The function that sets baudrate into the port handler The function sets baudrate into the port handl...
The class for control port in Linux.
void closePort()
The function that closes the port The function closes the port.
PortHandlerLinux(const char *port_name)
The function that initializes instance of PortHandler and gets port_name The function initializes in...
int getBytesAvailable()
The function that checks how much bytes are able to be read from the port buffer The function checks...
int getCFlagBaud(const int baudrate)
The class for port control that inherits PortHandlerLinux, PortHandlerWindows, PortHandlerMac, or PortHandlerArduino.
Definition: port_handler.h:56
int readPort(uint8_t *packet, int length)
The function that reads bytes from the port buffer The function gets bytes from the port buffer...
void setPortName(const char *port_name)
The function that sets port name into the port handler The function sets port name into the port han...
int getBaudRate()
The function that returns current baudrate set into the port handler The function returns current ba...
void clearPort()
The function that clears the port The function clears the port.
bool openPort()
The function that opens the port The function calls PortHandlerLinux::setBaudRate() to open the port...
bool setupPort(const int cflag_baud)


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