Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

included setRS485 method in port_handler_linux.h #362

Open
wants to merge 1 commit into
base: kinetic-devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion c++/include/dynamixel_sdk/port_handler_linux.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#ifndef DYNAMIXEL_SDK_INCLUDE_DYNAMIXEL_SDK_LINUX_PORTHANDLERLINUX_H_
#define DYNAMIXEL_SDK_INCLUDE_DYNAMIXEL_SDK_LINUX_PORTHANDLERLINUX_H_


#include <linux/serial.h>
#include "port_handler.h"

namespace dynamixel
Expand Down Expand Up @@ -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);

};

}
Expand Down
12 changes: 12 additions & 0 deletions c++/src/dynamixel_sdk/port_handler_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 9 additions & 1 deletion ros/include/dynamixel_sdk/port_handler_linux.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#ifndef DYNAMIXEL_SDK_INCLUDE_DYNAMIXEL_SDK_LINUX_PORTHANDLERLINUX_H_
#define DYNAMIXEL_SDK_INCLUDE_DYNAMIXEL_SDK_LINUX_PORTHANDLERLINUX_H_


#include <linux/serial.h>
#include "port_handler.h"

namespace dynamixel
Expand Down Expand Up @@ -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);


};

}
Expand Down
12 changes: 12 additions & 0 deletions ros/src/dynamixel_sdk/port_handler_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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