From 1ac15ec2bd19a91adcfe028893426ff81218ca45 Mon Sep 17 00:00:00 2001 From: sonelu Date: Fri, 15 Nov 2019 13:30:50 +0000 Subject: [PATCH] included setRS485 method in port_handler_linux.h --- c++/include/dynamixel_sdk/port_handler_linux.h | 10 +++++++++- c++/src/dynamixel_sdk/port_handler_linux.cpp | 12 ++++++++++++ ros/include/dynamixel_sdk/port_handler_linux.h | 10 +++++++++- ros/src/dynamixel_sdk/port_handler_linux.cpp | 12 ++++++++++++ 4 files changed, 42 insertions(+), 2 deletions(-) diff --git a/c++/include/dynamixel_sdk/port_handler_linux.h b/c++/include/dynamixel_sdk/port_handler_linux.h index a690e43c..df5c5c06 100644 --- a/c++/include/dynamixel_sdk/port_handler_linux.h +++ b/c++/include/dynamixel_sdk/port_handler_linux.h @@ -22,7 +22,7 @@ #ifndef DYNAMIXEL_SDK_INCLUDE_DYNAMIXEL_SDK_LINUX_PORTHANDLERLINUX_H_ #define DYNAMIXEL_SDK_INCLUDE_DYNAMIXEL_SDK_LINUX_PORTHANDLERLINUX_H_ - +#include #include "port_handler.h" namespace dynamixel @@ -163,6 +163,14 @@ class PortHandlerLinux : public PortHandler /// @description The function checks whether current time is passed by the time of packet timeout from the time set by PortHandlerLinux::setPacketTimeout(). //////////////////////////////////////////////////////////////////////////////// bool isPacketTimeout(); + + + //////////////////////////////////////////////////////////////////////////////// + /// @brief The function configures the current port in RS485 mode + /// @description The function tries to configure the current port in RS485 mode. + //////////////////////////////////////////////////////////////////////////////// + bool setRS485(struct serial_rs485 *rs485conf); + }; } diff --git a/c++/src/dynamixel_sdk/port_handler_linux.cpp b/c++/src/dynamixel_sdk/port_handler_linux.cpp index 57564a94..f61fb8e6 100644 --- a/c++/src/dynamixel_sdk/port_handler_linux.cpp +++ b/c++/src/dynamixel_sdk/port_handler_linux.cpp @@ -280,4 +280,16 @@ int PortHandlerLinux::getCFlagBaud(int baudrate) } } + +bool PortHandlerLinux::setRS485(struct serial_rs485 *rs485conf) +{ + if (ioctl(socket_fd_, TIOCSRS485, rs485conf) < 0) + { + printf("[PortHandlerLinux::setRS485] TIOCSRS485 failed!\n"); + return false; + } + return true; +} + + #endif diff --git a/ros/include/dynamixel_sdk/port_handler_linux.h b/ros/include/dynamixel_sdk/port_handler_linux.h index a690e43c..1065d417 100644 --- a/ros/include/dynamixel_sdk/port_handler_linux.h +++ b/ros/include/dynamixel_sdk/port_handler_linux.h @@ -22,7 +22,7 @@ #ifndef DYNAMIXEL_SDK_INCLUDE_DYNAMIXEL_SDK_LINUX_PORTHANDLERLINUX_H_ #define DYNAMIXEL_SDK_INCLUDE_DYNAMIXEL_SDK_LINUX_PORTHANDLERLINUX_H_ - +#include #include "port_handler.h" namespace dynamixel @@ -163,6 +163,14 @@ class PortHandlerLinux : public PortHandler /// @description The function checks whether current time is passed by the time of packet timeout from the time set by PortHandlerLinux::setPacketTimeout(). //////////////////////////////////////////////////////////////////////////////// bool isPacketTimeout(); + + //////////////////////////////////////////////////////////////////////////////// + /// @brief The function configures the current port in RS485 mode + /// @description The function tries to configure the current port in RS485 mode. + //////////////////////////////////////////////////////////////////////////////// + bool setRS485(struct serial_rs485 *rs485conf); + + }; } diff --git a/ros/src/dynamixel_sdk/port_handler_linux.cpp b/ros/src/dynamixel_sdk/port_handler_linux.cpp index 57564a94..f61fb8e6 100644 --- a/ros/src/dynamixel_sdk/port_handler_linux.cpp +++ b/ros/src/dynamixel_sdk/port_handler_linux.cpp @@ -280,4 +280,16 @@ int PortHandlerLinux::getCFlagBaud(int baudrate) } } + +bool PortHandlerLinux::setRS485(struct serial_rs485 *rs485conf) +{ + if (ioctl(socket_fd_, TIOCSRS485, rs485conf) < 0) + { + printf("[PortHandlerLinux::setRS485] TIOCSRS485 failed!\n"); + return false; + } + return true; +} + + #endif