Class PortHandlerLinux

Inheritance Relationships

Base Type

Class Documentation

class PortHandlerLinux : public dynamixel::PortHandler

The class for control port in Linux.

Public Functions

PortHandlerLinux(const char *port_name)

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

inline virtual ~PortHandlerLinux()

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

virtual bool openPort()

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

Returns:

communication results which come from PortHandlerLinux::setBaudRate()

virtual void closePort()

The function that closes the port @description The function closes the port.

virtual void clearPort()

The function that clears the port @description The function clears the port.

virtual void setPortName(const char *port_name)

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

Parameters:

port_name – Port name

virtual char *getPortName()

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

Returns:

Port name

virtual bool setBaudRate(const int baudrate)

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

Parameters:

baudrate – Baudrate

Returns:

false

Returns:

when error was occurred during port opening

Returns:

or true

virtual int getBaudRate()

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

Returns:

Baudrate

virtual int getBytesAvailable()

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

Returns:

Length of read-able bytes in the port buffer

virtual int readPort(uint8_t *packet, int length)

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

Parameters:
  • packet – Buffer for the packet received

  • length – Length of the buffer for read

Returns:

-1

Returns:

when error was occurred

Returns:

or Length of bytes read

virtual int writePort(uint8_t *packet, int length)

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

Parameters:
  • packet – Buffer which would be written on the port buffer

  • length – Length of the buffer for write

Returns:

-1

Returns:

when error was occurred

Returns:

or Length of bytes written

virtual void setPacketTimeout(uint16_t packet_length)

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

Parameters:

packet_length – Length of the packet expected to be received

virtual void setPacketTimeout(double msec)

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

Parameters:

packet_length – Length of the packet expected to be received

virtual bool isPacketTimeout()

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