port_handler.h
Go to the documentation of this file.
00001 /*******************************************************************************
00002 * Copyright 2017 ROBOTIS CO., LTD.
00003 *
00004 * Licensed under the Apache License, Version 2.0 (the "License");
00005 * you may not use this file except in compliance with the License.
00006 * You may obtain a copy of the License at
00007 *
00008 *     http://www.apache.org/licenses/LICENSE-2.0
00009 *
00010 * Unless required by applicable law or agreed to in writing, software
00011 * distributed under the License is distributed on an "AS IS" BASIS,
00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013 * See the License for the specific language governing permissions and
00014 * limitations under the License.
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 /* DYNAMIXEL_SDK_INCLUDE_DYNAMIXEL_SDK_PORTHANDLER_H_ */


ros
Author(s): Pyo , Zerom , Leon
autogenerated on Sat Jun 8 2019 18:32:11