Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00021
00022 #ifndef DYNAMIXEL_SDK_INCLUDE_DYNAMIXEL_SDK_PORTHANDLER_H_
00023 #define DYNAMIXEL_SDK_INCLUDE_DYNAMIXEL_SDK_PORTHANDLER_H_
00024
00025 #if defined(__linux__)
00026 #define WINDECLSPEC
00027 #elif defined(__APPLE__)
00028 #define WINDECLSPEC
00029 #elif defined(_WIN32) || defined(_WIN64)
00030 #ifdef WINDLLEXPORT
00031 #define WINDECLSPEC __declspec(dllexport)
00032 #else
00033 #define WINDECLSPEC __declspec(dllimport)
00034 #endif
00035 #elif defined(ARDUINO) || defined(__OPENCR__) || defined(__OPENCM904__)
00036 #define WINDECLSPEC
00037 #endif
00038
00039 #ifdef __GNUC__
00040 #define DEPRECATED __attribute__((deprecated))
00041 #elif defined(_MSC_VER)
00042 #define DEPRECATED __declspec(deprecated)
00043 #else
00044 #pragma message("WARNING: You need to implement DEPRECATED for this compiler")
00045 #define DEPRECATED
00046 #endif
00047
00048 #include <stdint.h>
00049
00050 namespace dynamixel
00051 {
00052
00056 class WINDECLSPEC PortHandler
00057 {
00058 public:
00059 static const int DEFAULT_BAUDRATE_ = 57600;
00060
00065 static PortHandler *getPortHandler(const char *port_name);
00066
00067 bool is_using_;
00068
00069 virtual ~PortHandler() { }
00070
00076 virtual bool openPort() = 0;
00077
00082 virtual void closePort() = 0;
00083
00088 virtual void clearPort() = 0;
00089
00095 virtual void setPortName(const char* port_name) = 0;
00096
00102 virtual char *getPortName() = 0;
00103
00112 virtual bool setBaudRate(const int baudrate) = 0;
00113
00119 virtual int getBaudRate() = 0;
00120
00127 virtual int getBytesAvailable() = 0;
00128
00139 virtual int readPort(uint8_t *packet, int length) = 0;
00140
00151 virtual int writePort(uint8_t *packet, int length) = 0;
00152
00158 virtual void setPacketTimeout(uint16_t packet_length) = 0;
00159
00165 virtual void setPacketTimeout(double msec) = 0;
00166
00171 virtual bool isPacketTimeout() = 0;
00172 };
00173
00174 }
00175
00176
00177 #endif