Public Member Functions | Private Member Functions | Private Attributes | List of all members
dynamixel::PortHandlerLinux Class Reference

The class for control port in Linux. More...

#include <port_handler_linux.h>

Inheritance diagram for dynamixel::PortHandlerLinux:
Inheritance graph
[legend]

Public Member Functions

void clearPort ()
 The function that clears the port The function clears the port. More...
 
void closePort ()
 The function that closes the port The function closes the port. More...
 
int getBaudRate ()
 The function that returns current baudrate set into the port handler The function returns current baudrate set into the port handler. More...
 
int getBytesAvailable ()
 The function that checks how much bytes are able to be read from the port buffer The function checks how much bytes are able to be read from the port buffer and returns the number. More...
 
char * getPortName ()
 The function that returns port name set into the port handler The function returns current port name set into the port handler. More...
 
bool isPacketTimeout ()
 The function that checks whether packet timeout is occurred The function checks whether current time is passed by the time of packet timeout from the time set by PortHandlerLinux::setPacketTimeout(). More...
 
bool openPort ()
 The function that opens the port The function calls PortHandlerLinux::setBaudRate() to open the port. More...
 
 PortHandlerLinux (const char *port_name)
 The function that initializes instance of PortHandler and gets port_name The function initializes instance of PortHandler and gets port_name. More...
 
int readPort (uint8_t *packet, int length)
 The function that reads bytes from the port buffer The function gets bytes from the port buffer, and returns a number of bytes read. More...
 
bool setBaudRate (const int baudrate)
 The function that sets baudrate into the port handler The function sets baudrate into the port handler. More...
 
void setPacketTimeout (uint16_t packet_length)
 The function that sets and starts stopwatch for watching packet timeout The function sets the stopwatch by getting current time and the time of packet timeout with packet_length. More...
 
void setPacketTimeout (double msec)
 The function that sets and starts stopwatch for watching packet timeout The function sets the stopwatch by getting current time and the time of packet timeout with msec. More...
 
void setPortName (const char *port_name)
 The function that sets port name into the port handler The function sets port name into the port handler. More...
 
int writePort (uint8_t *packet, int length)
 The function that writes bytes on the port buffer The function writes bytes on the port buffer, and returns a number of bytes which are successfully written. More...
 
virtual ~PortHandlerLinux ()
 The function that closes the port The function calls PortHandlerLinux::closePort() to close the port. More...
 
- Public Member Functions inherited from dynamixel::PortHandler
virtual ~PortHandler ()
 

Private Member Functions

int getCFlagBaud (const int baudrate)
 
double getCurrentTime ()
 
double getTimeSinceStart ()
 
bool setCustomBaudrate (int speed)
 
bool setupPort (const int cflag_baud)
 

Private Attributes

int baudrate_
 
double packet_start_time_
 
double packet_timeout_
 
char port_name_ [100]
 
int socket_fd_
 
double tx_time_per_byte
 

Additional Inherited Members

- Static Public Member Functions inherited from dynamixel::PortHandler
static PortHandlergetPortHandler (const char *port_name)
 The function that gets PortHandler class inheritance The function gets class inheritance (PortHandlerLinux / PortHandlerWindows / PortHandlerMac / PortHandlerArduino. More...
 
- Public Attributes inherited from dynamixel::PortHandler
bool is_using_
 shows whether the port is in use More...
 
- Static Public Attributes inherited from dynamixel::PortHandler
static const int DEFAULT_BAUDRATE_ = 57600
 Default Baudrate. More...
 

Detailed Description

The class for control port in Linux.

Definition at line 34 of file port_handler_linux.h.

Constructor & Destructor Documentation

dynamixel::PortHandlerLinux::PortHandlerLinux ( const char *  port_name)

The function that initializes instance of PortHandler and gets port_name The function initializes instance of PortHandler and gets port_name.

virtual dynamixel::PortHandlerLinux::~PortHandlerLinux ( )
inlinevirtual

The function that closes the port The function calls PortHandlerLinux::closePort() to close the port.

Definition at line 63 of file port_handler_linux.h.

Member Function Documentation

void dynamixel::PortHandlerLinux::clearPort ( )
virtual

The function that clears the port The function clears the port.

Implements dynamixel::PortHandler.

void dynamixel::PortHandlerLinux::closePort ( )
virtual

The function that closes the port The function closes the port.

Implements dynamixel::PortHandler.

int dynamixel::PortHandlerLinux::getBaudRate ( )
virtual

The function that returns current baudrate set into the port handler The function returns current baudrate set into the port handler.

Returns
Baudrate

Implements dynamixel::PortHandler.

int dynamixel::PortHandlerLinux::getBytesAvailable ( )
virtual

The function that checks how much bytes are able to be read from the port buffer The function checks how much bytes are able to be read from the port buffer and returns the number.

Returns
Length of read-able bytes in the port buffer

Implements dynamixel::PortHandler.

int dynamixel::PortHandlerLinux::getCFlagBaud ( const int  baudrate)
private
double dynamixel::PortHandlerLinux::getCurrentTime ( )
private
char* dynamixel::PortHandlerLinux::getPortName ( )
virtual

The function that returns port name set into the port handler The function returns current port name set into the port handler.

Returns
Port name

Implements dynamixel::PortHandler.

double dynamixel::PortHandlerLinux::getTimeSinceStart ( )
private
bool dynamixel::PortHandlerLinux::isPacketTimeout ( )
virtual

The function that checks whether packet timeout is occurred The function checks whether current time is passed by the time of packet timeout from the time set by PortHandlerLinux::setPacketTimeout().

Implements dynamixel::PortHandler.

bool dynamixel::PortHandlerLinux::openPort ( )
virtual

The function that opens the port The function calls PortHandlerLinux::setBaudRate() to open the port.

Returns
communication results which come from PortHandlerLinux::setBaudRate()

Implements dynamixel::PortHandler.

int dynamixel::PortHandlerLinux::readPort ( uint8_t *  packet,
int  length 
)
virtual

The function that reads bytes from the port buffer The function gets bytes from the port buffer, and returns a number of bytes read.

Parameters
packetBuffer for the packet received
lengthLength of the buffer for read
Returns
-1
when error was occurred
or Length of bytes read

Implements dynamixel::PortHandler.

bool dynamixel::PortHandlerLinux::setBaudRate ( const int  baudrate)
virtual

The function that sets baudrate into the port handler The function sets baudrate into the port handler.

Parameters
baudrateBaudrate
Returns
false
when error was occurred during port opening
or true

Implements dynamixel::PortHandler.

bool dynamixel::PortHandlerLinux::setCustomBaudrate ( int  speed)
private
void dynamixel::PortHandlerLinux::setPacketTimeout ( uint16_t  packet_length)
virtual

The function that sets and starts stopwatch for watching packet timeout The function sets the stopwatch by getting current time and the time of packet timeout with packet_length.

Parameters
packet_lengthLength of the packet expected to be received

Implements dynamixel::PortHandler.

void dynamixel::PortHandlerLinux::setPacketTimeout ( double  msec)
virtual

The function that sets and starts stopwatch for watching packet timeout The function sets the stopwatch by getting current time and the time of packet timeout with msec.

Parameters
packet_lengthLength of the packet expected to be received

Implements dynamixel::PortHandler.

void dynamixel::PortHandlerLinux::setPortName ( const char *  port_name)
virtual

The function that sets port name into the port handler The function sets port name into the port handler.

Parameters
port_namePort name

Implements dynamixel::PortHandler.

bool dynamixel::PortHandlerLinux::setupPort ( const int  cflag_baud)
private
int dynamixel::PortHandlerLinux::writePort ( uint8_t *  packet,
int  length 
)
virtual

The function that writes bytes on the port buffer The function writes bytes on the port buffer, and returns a number of bytes which are successfully written.

Parameters
packetBuffer which would be written on the port buffer
lengthLength of the buffer for write
Returns
-1
when error was occurred
or Length of bytes written

Implements dynamixel::PortHandler.

Member Data Documentation

int dynamixel::PortHandlerLinux::baudrate_
private

Definition at line 38 of file port_handler_linux.h.

double dynamixel::PortHandlerLinux::packet_start_time_
private

Definition at line 41 of file port_handler_linux.h.

double dynamixel::PortHandlerLinux::packet_timeout_
private

Definition at line 42 of file port_handler_linux.h.

char dynamixel::PortHandlerLinux::port_name_[100]
private

Definition at line 39 of file port_handler_linux.h.

int dynamixel::PortHandlerLinux::socket_fd_
private

Definition at line 37 of file port_handler_linux.h.

double dynamixel::PortHandlerLinux::tx_time_per_byte
private

Definition at line 43 of file port_handler_linux.h.


The documentation for this class was generated from the following file:


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