MercurySDK
Software development kit for Mercury digital servos
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
mercury::PacketHandler Class Referenceabstract

The class that inherits Protocol1PacketHandler class or Protocol2PacketHandler class. More...

#include <packet_handler.h>

Inheritance diagram for mercury::PacketHandler:
mercury::Protocol2PacketHandler

Public Member Functions

virtual ~PacketHandler ()
 
virtual float getProtocolVersion ()=0
 The function that returns Protocol version. More...
 
virtual const char * getTxRxResult (int result)=0
 The function that gets description of communication result. More...
 
virtual const char * getRxPacketError (uint8_t error)=0
 The function that gets description of hardware error. More...
 
virtual int txPacket (PortHandler *port, uint8_t *txpacket)=0
 The function that transmits the instruction packet txpacket via PortHandler port. @description The function clears the port buffer by PortHandler::clearPort() function, @description then transmits txpacket by PortHandler::writePort() function. @description The function activates only when the port is not busy and when the packet is already written on the port buffer. More...
 
virtual int rxPacket (PortHandler *port, uint8_t *rxpacket)=0
 The function that receives packet (rxpacket) during designated time via PortHandler port @description The function repeatedly tries to receive rxpacket by PortHandler::readPort() function. @description It breaks out @description when PortHandler::isPacketTimeout() shows the timeout, @description when rxpacket seemed as corrupted, or @description when nothing received. More...
 
virtual int txRxPacket (PortHandler *port, uint8_t *txpacket, uint8_t *rxpacket, uint8_t *error=0)=0
 The function that transmits packet (txpacket) and receives packet (rxpacket) during designated time via PortHandler port @description The function calls PacketHandler::txPacket(), @description and calls PacketHandler::rxPacket() if it succeeds PacketHandler::txPacket(). @description It breaks out @description when it fails PacketHandler::txPacket(), @description when txpacket is called by PacketHandler::broadcastPing() / PacketHandler::syncWriteTxOnly() / PacketHandler::regWriteTxOnly / PacketHandler::action. More...
 
virtual int ping (PortHandler *port, uint8_t id, uint8_t *error=0)=0
 The function that pings Mercury but doesn't take its model number @description The function calls PacketHandler::ping() which gets Mercury model number, @description but doesn't carry the model number. More...
 
virtual int ping (PortHandler *port, uint8_t id, uint16_t *model_number, uint8_t *error=0)=0
 The function that pings Mercury and takes its model number @description The function makes an instruction packet with INST_PING, @description transmits the packet with PacketHandler::txRxPacket(), @description and call PacketHandler::readTxRx to read model_number in the rx buffer. @description It breaks out @description when it tries to transmit to BROADCAST_ID. More...
 
virtual int broadcastPing (PortHandler *port, std::vector< uint8_t > &id_list)=0
 (Available only in Protocol 2.0) The function that pings all connected Mercury More...
 
virtual int action (PortHandler *port, uint8_t id)=0
 The function that makes Mercurys run as written in the Mercury register @description The function makes an instruction packet with INST_ACTION, @description transmits the packet with PacketHandler::txRxPacket(). @description To use this function, Mercury register should be set by PacketHandler::regWriteTxOnly() or PacketHandler::regWriteTxRx() More...
 
virtual int reboot (PortHandler *port, uint8_t id, uint8_t *error=0)=0
 The function that makes Mercury reboot @description The function makes an instruction packet with INST_REBOOT, @description transmits the packet with PacketHandler::txRxPacket(), @description then Mercury reboots. @description During reboot, its LED will blink. More...
 
virtual int clearMultiTurn (PortHandler *port, uint8_t id, uint8_t *error=0)=0
 The function that resets the multi-turn revolution count @description The function makes an instruction packet with INST_CLEAR, @description transmits the packet with Protocol2PacketHandler::txRxPacket(). More...
 
virtual int factoryReset (PortHandler *port, uint8_t id, uint8_t option=0, uint8_t *error=0)=0
 The function that makes Mercury reset as it was produced in the factory @description The function makes an instruction packet with INST_FACTORY_RESET, @description transmits the packet with PacketHandler::txRxPacket(). @description Be careful of the use. More...
 
virtual int readTx (PortHandler *port, uint8_t id, uint16_t address, uint16_t length)=0
 The function that transmits INST_READ instruction packet @description The function makes an instruction packet with INST_READ, @description transmits the packet with PacketHandler::txPacket(). @description It breaks out @description when it tries to transmit to BROADCAST_ID. More...
 
virtual int readRx (PortHandler *port, uint8_t id, uint16_t length, uint8_t *data, uint8_t *error=0)=0
 The function that receives the packet and reads the data in the packet @description The function receives the packet which might be come by previous INST_READ instruction packet transmission, @description gets the data from the packet. More...
 
virtual int readTxRx (PortHandler *port, uint8_t id, uint16_t address, uint16_t length, uint8_t *data, uint8_t *error=0)=0
 The function that transmits INST_READ instruction packet, and read data from received packet @description The function makes an instruction packet with INST_READ, @description transmits and receives the packet with PacketHandler::txRxPacket(), @description gets the data from the packet. @description It breaks out @description when it tries to transmit to BROADCAST_ID. More...
 
virtual int read1ByteTx (PortHandler *port, uint8_t id, uint16_t address)=0
 The function that calls PacketHandler::readTx() function for reading 1 byte data @description The function calls PacketHandler::readTx() function for reading 1 byte data. More...
 
virtual int read1ByteRx (PortHandler *port, uint8_t id, uint8_t *data, uint8_t *error=0)=0
 The function that calls PacketHandler::readRx() function and reads 1 byte data on the packet @description The function calls PacketHandler::readRx() function, @description gets 1 byte data from the packet. More...
 
virtual int read1ByteTxRx (PortHandler *port, uint8_t id, uint16_t address, uint8_t *data, uint8_t *error=0)=0
 The function that calls PacketHandler::readTxRx() function for reading 1 byte data @description The function calls PacketHandler::readTxRx(), @description gets 1 byte data from the packet. More...
 
virtual int read2ByteTx (PortHandler *port, uint8_t id, uint16_t address)=0
 The function that calls PacketHandler::readTx() function for reading 2 byte data @description The function calls PacketHandler::readTx() function for reading 2 byte data. More...
 
virtual int read2ByteRx (PortHandler *port, uint8_t id, uint16_t *data, uint8_t *error=0)=0
 The function that calls PacketHandler::readRx() function and reads 2 byte data on the packet @description The function calls PacketHandler::readRx() function, @description gets 2 byte data from the packet. More...
 
virtual int read2ByteTxRx (PortHandler *port, uint8_t id, uint16_t address, uint16_t *data, uint8_t *error=0)=0
 The function that calls PacketHandler::readTxRx() function for reading 2 byte data @description The function calls PacketHandler::readTxRx(), @description gets 2 byte data from the packet. More...
 
virtual int read4ByteTx (PortHandler *port, uint8_t id, uint16_t address)=0
 The function that calls PacketHandler::readTx() function for reading 4 byte data @description The function calls PacketHandler::readTx() function for reading 4 byte data. More...
 
virtual int read4ByteRx (PortHandler *port, uint8_t id, uint32_t *data, uint8_t *error=0)=0
 The function that calls PacketHandler::readRx() function and reads 4 byte data on the packet @description The function calls PacketHandler::readRx() function, @description gets 4 byte data from the packet. More...
 
virtual int read4ByteTxRx (PortHandler *port, uint8_t id, uint16_t address, uint32_t *data, uint8_t *error=0)=0
 The function that calls PacketHandler::readTxRx() function for reading 4 byte data @description The function calls PacketHandler::readTxRx(), @description gets 4 byte data from the packet. More...
 
virtual int writeTxOnly (PortHandler *port, uint8_t id, uint16_t address, uint16_t length, uint8_t *data)=0
 The function that transmits INST_WRITE instruction packet with the data for write @description The function makes an instruction packet with INST_WRITE and the data for write, @description transmits the packet with PacketHandler::txPacket(). More...
 
virtual int writeTxRx (PortHandler *port, uint8_t id, uint16_t address, uint16_t length, uint8_t *data, uint8_t *error=0)=0
 The function that transmits INST_WRITE instruction packet with the data for write, and receives the packet @description The function makes an instruction packet with INST_WRITE and the data for write, @description transmits and receives the packet with PacketHandler::txRxPacket(), @description gets the error from the packet. More...
 
virtual int write1ByteTxOnly (PortHandler *port, uint8_t id, uint16_t address, uint8_t data)=0
 The function that calls PacketHandler::writeTxOnly() for writing 1 byte data @description The function calls PacketHandler::writeTxOnly() for writing 1 byte data. More...
 
virtual int write1ByteTxRx (PortHandler *port, uint8_t id, uint16_t address, uint8_t data, uint8_t *error=0)=0
 The function that calls PacketHandler::writeTxRx() for writing 1 byte data and receives the packet @description The function calls PacketHandler::writeTxRx() for writing 1 byte data and receves the packet, @description gets the error from the packet. More...
 
virtual int write2ByteTxOnly (PortHandler *port, uint8_t id, uint16_t address, uint16_t data)=0
 The function that calls PacketHandler::writeTxOnly() for writing 2 byte data @description The function calls PacketHandler::writeTxOnly() for writing 2 byte data. More...
 
virtual int write2ByteTxRx (PortHandler *port, uint8_t id, uint16_t address, uint16_t data, uint8_t *error=0)=0
 The function that calls PacketHandler::writeTxRx() for writing 2 byte data and receives the packet @description The function calls PacketHandler::writeTxRx() for writing 2 byte data and receves the packet, @description gets the error from the packet. More...
 
virtual int write4ByteTxOnly (PortHandler *port, uint8_t id, uint16_t address, uint32_t data)=0
 The function that calls PacketHandler::writeTxOnly() for writing 4 byte data @description The function calls PacketHandler::writeTxOnly() for writing 4 byte data. More...
 
virtual int write4ByteTxRx (PortHandler *port, uint8_t id, uint16_t address, uint32_t data, uint8_t *error=0)=0
 The function that calls PacketHandler::writeTxRx() for writing 4 byte data and receives the packet @description The function calls PacketHandler::writeTxRx() for writing 4 byte data and receves the packet, @description gets the error from the packet. More...
 
virtual int regWriteTxOnly (PortHandler *port, uint8_t id, uint16_t address, uint16_t length, uint8_t *data)=0
 The function that transmits INST_REG_WRITE instruction packet with the data for writing on the Mercury register @description The function makes an instruction packet with INST_REG_WRITE and the data for writing on the Mercury register, @description transmits the packet with PacketHandler::txPacket(). @description The data written in the register will act when INST_ACTION instruction packet is transmitted to the Mercury. More...
 
virtual int regWriteTxRx (PortHandler *port, uint8_t id, uint16_t address, uint16_t length, uint8_t *data, uint8_t *error=0)=0
 The function that transmits INST_REG_WRITE instruction packet with the data for writing on the Mercury register, and receives the packet @description The function makes an instruction packet with INST_REG_WRITE and the data for writing on the Mercury register, @description transmits and receives the packet with PacketHandler::txRxPacket(), @description gets the error from the packet. @description The data written in the register will act when INST_ACTION instruction packet is transmitted to the Mercury. More...
 
virtual int syncReadTx (PortHandler *port, uint16_t start_address, uint16_t data_length, uint8_t *param, uint16_t param_length)=0
 The function that transmits INST_SYNC_READ instruction packet @description The function makes an instruction packet with INST_SYNC_READ, @description transmits the packet with PacketHandler::txPacket(). More...
 
virtual int syncWriteTxOnly (PortHandler *port, uint16_t start_address, uint16_t data_length, uint8_t *param, uint16_t param_length)=0
 The function that transmits INST_SYNC_WRITE instruction packet @description The function makes an instruction packet with INST_SYNC_WRITE, @description transmits the packet with PacketHandler::txRxPacket(). More...
 
virtual int synchronise (PortHandler *port, uint8_t id, uint8_t *error=0)=0
 The function that synchronises the servo @description This function will synchronise the target Mercury servo. @description transmits the packet with PacketHandler::txRxPacket(). More...
 

Static Public Member Functions

static PacketHandlergetPacketHandler ()
 The function that returns PacketHandler instance. More...
 

Protected Member Functions

 PacketHandler ()
 

Detailed Description

The class that inherits Protocol1PacketHandler class or Protocol2PacketHandler class.

Definition at line 84 of file packet_handler.h.

Constructor & Destructor Documentation

◆ PacketHandler()

mercury::PacketHandler::PacketHandler ( )
inlineprotected

Definition at line 87 of file packet_handler.h.

◆ ~PacketHandler()

virtual mercury::PacketHandler::~PacketHandler ( )
inlinevirtual

Definition at line 96 of file packet_handler.h.

Member Function Documentation

◆ action()

virtual int mercury::PacketHandler::action ( PortHandler port,
uint8_t  id 
)
pure virtual

The function that makes Mercurys run as written in the Mercury register @description The function makes an instruction packet with INST_ACTION, @description transmits the packet with PacketHandler::txRxPacket(). @description To use this function, Mercury register should be set by PacketHandler::regWriteTxOnly() or PacketHandler::regWriteTxRx()

Parameters
portPortHandler instance
idMercury ID
Returns
communication results which come from PacketHandler::txRxPacket()

Implemented in mercury::Protocol2PacketHandler.

◆ broadcastPing()

virtual int mercury::PacketHandler::broadcastPing ( PortHandler port,
std::vector< uint8_t > &  id_list 
)
pure virtual

(Available only in Protocol 2.0) The function that pings all connected Mercury

Parameters
portPortHandler instance
id_listID list of Mercurys which are found by broadcast ping
Returns
COMM_NOT_AVAILABLE

Implemented in mercury::Protocol2PacketHandler.

◆ clearMultiTurn()

virtual int mercury::PacketHandler::clearMultiTurn ( PortHandler port,
uint8_t  id,
uint8_t *  error = 0 
)
pure virtual

The function that resets the multi-turn revolution count @description The function makes an instruction packet with INST_CLEAR, @description transmits the packet with Protocol2PacketHandler::txRxPacket().

Parameters
portPortHandler instance
idMercury ID
errorMercury hardware error or Result Fail (0x01) or 0 (success)
Returns
communication results which come from Protocol2PacketHandler::txRxPacket()

Implemented in mercury::Protocol2PacketHandler.

◆ factoryReset()

virtual int mercury::PacketHandler::factoryReset ( PortHandler port,
uint8_t  id,
uint8_t  option = 0,
uint8_t *  error = 0 
)
pure virtual

The function that makes Mercury reset as it was produced in the factory @description The function makes an instruction packet with INST_FACTORY_RESET, @description transmits the packet with PacketHandler::txRxPacket(). @description Be careful of the use.

Parameters
portPortHandler instance
idMercury ID
optionReset option
errorMercury hardware error
Returns
communication results which come from PacketHandler::txRxPacket()

Implemented in mercury::Protocol2PacketHandler.

◆ getPacketHandler()

PacketHandler * PacketHandler::getPacketHandler ( )
static

The function that returns PacketHandler instance.

Returns
PacketHandler instance

Definition at line 36 of file packet_handler.cpp.

◆ getProtocolVersion()

virtual float mercury::PacketHandler::getProtocolVersion ( )
pure virtual

The function that returns Protocol version.

Returns
protocol version

Implemented in mercury::Protocol2PacketHandler.

◆ getRxPacketError()

virtual const char* mercury::PacketHandler::getRxPacketError ( uint8_t  error)
pure virtual

The function that gets description of hardware error.

Parameters
errorMercury hardware error which might be gotten by the tx rx functions
Returns
description of hardware error in const char* (string)

Implemented in mercury::Protocol2PacketHandler.

◆ getTxRxResult()

virtual const char* mercury::PacketHandler::getTxRxResult ( int  result)
pure virtual

The function that gets description of communication result.

Parameters
resultCommunication result which might be gotten by the tx rx functions
Returns
description of communication result in const char* (string)

Implemented in mercury::Protocol2PacketHandler.

◆ ping() [1/2]

virtual int mercury::PacketHandler::ping ( PortHandler port,
uint8_t  id,
uint16_t *  model_number,
uint8_t *  error = 0 
)
pure virtual

The function that pings Mercury and takes its model number @description The function makes an instruction packet with INST_PING, @description transmits the packet with PacketHandler::txRxPacket(), @description and call PacketHandler::readTxRx to read model_number in the rx buffer. @description It breaks out @description when it tries to transmit to BROADCAST_ID.

Parameters
portPortHandler instance
idMercury ID
errorMercury hardware error
Returns
COMM_NOT_AVAILABLE
when it tries to transmit to BROADCAST_ID
COMM_SUCCESS
when it succeeds to ping Mercury and get model_number from it
or the other communication results which come from PacketHandler::txRxPacket() and PacketHandler::readTxRx()

Implemented in mercury::Protocol2PacketHandler.

◆ ping() [2/2]

virtual int mercury::PacketHandler::ping ( PortHandler port,
uint8_t  id,
uint8_t *  error = 0 
)
pure virtual

The function that pings Mercury but doesn't take its model number @description The function calls PacketHandler::ping() which gets Mercury model number, @description but doesn't carry the model number.

Parameters
portPortHandler instance
idMercury ID
errorMercury hardware error
Returns
communication results which come from PacketHandler::ping()

Implemented in mercury::Protocol2PacketHandler.

◆ read1ByteRx()

virtual int mercury::PacketHandler::read1ByteRx ( PortHandler port,
uint8_t  id,
uint8_t *  data,
uint8_t *  error = 0 
)
pure virtual

The function that calls PacketHandler::readRx() function and reads 1 byte data on the packet @description The function calls PacketHandler::readRx() function, @description gets 1 byte data from the packet.

Parameters
portPortHandler instance
dataData extracted from the packet
errorMercury hardware error
Returns
communication results which come from PacketHandler::readRx()

Implemented in mercury::Protocol2PacketHandler.

◆ read1ByteTx()

virtual int mercury::PacketHandler::read1ByteTx ( PortHandler port,
uint8_t  id,
uint16_t  address 
)
pure virtual

The function that calls PacketHandler::readTx() function for reading 1 byte data @description The function calls PacketHandler::readTx() function for reading 1 byte data.

Parameters
portPortHandler instance
idMercury ID
addressAddress of the data for read
Returns
communication results which come from PacketHandler::readTx()

Implemented in mercury::Protocol2PacketHandler.

◆ read1ByteTxRx()

virtual int mercury::PacketHandler::read1ByteTxRx ( PortHandler port,
uint8_t  id,
uint16_t  address,
uint8_t *  data,
uint8_t *  error = 0 
)
pure virtual

The function that calls PacketHandler::readTxRx() function for reading 1 byte data @description The function calls PacketHandler::readTxRx(), @description gets 1 byte data from the packet.

Parameters
portPortHandler instance
idMercury ID
addressAddress of the data for read
lengthLength of the data for read
dataData extracted from the packet
errorMercury hardware error
Returns
communication results which come from PacketHandler::txRxPacket()

Implemented in mercury::Protocol2PacketHandler.

◆ read2ByteRx()

virtual int mercury::PacketHandler::read2ByteRx ( PortHandler port,
uint8_t  id,
uint16_t *  data,
uint8_t *  error = 0 
)
pure virtual

The function that calls PacketHandler::readRx() function and reads 2 byte data on the packet @description The function calls PacketHandler::readRx() function, @description gets 2 byte data from the packet.

Parameters
portPortHandler instance
dataData extracted from the packet
errorMercury hardware error
Returns
communication results which come from PacketHandler::readRx()

Implemented in mercury::Protocol2PacketHandler.

◆ read2ByteTx()

virtual int mercury::PacketHandler::read2ByteTx ( PortHandler port,
uint8_t  id,
uint16_t  address 
)
pure virtual

The function that calls PacketHandler::readTx() function for reading 2 byte data @description The function calls PacketHandler::readTx() function for reading 2 byte data.

Parameters
portPortHandler instance
idMercury ID
addressAddress of the data for read
Returns
communication results which come from PacketHandler::readTx()

Implemented in mercury::Protocol2PacketHandler.

◆ read2ByteTxRx()

virtual int mercury::PacketHandler::read2ByteTxRx ( PortHandler port,
uint8_t  id,
uint16_t  address,
uint16_t *  data,
uint8_t *  error = 0 
)
pure virtual

The function that calls PacketHandler::readTxRx() function for reading 2 byte data @description The function calls PacketHandler::readTxRx(), @description gets 2 byte data from the packet.

Parameters
portPortHandler instance
idMercury ID
addressAddress of the data for read
lengthLength of the data for read
dataData extracted from the packet
errorMercury hardware error
Returns
communication results which come from PacketHandler::txRxPacket()

Implemented in mercury::Protocol2PacketHandler.

◆ read4ByteRx()

virtual int mercury::PacketHandler::read4ByteRx ( PortHandler port,
uint8_t  id,
uint32_t *  data,
uint8_t *  error = 0 
)
pure virtual

The function that calls PacketHandler::readRx() function and reads 4 byte data on the packet @description The function calls PacketHandler::readRx() function, @description gets 4 byte data from the packet.

Parameters
portPortHandler instance
dataData extracted from the packet
errorMercury hardware error
Returns
communication results which come from PacketHandler::readRx()

Implemented in mercury::Protocol2PacketHandler.

◆ read4ByteTx()

virtual int mercury::PacketHandler::read4ByteTx ( PortHandler port,
uint8_t  id,
uint16_t  address 
)
pure virtual

The function that calls PacketHandler::readTx() function for reading 4 byte data @description The function calls PacketHandler::readTx() function for reading 4 byte data.

Parameters
portPortHandler instance
idMercury ID
addressAddress of the data for read
Returns
communication results which come from PacketHandler::readTx()

Implemented in mercury::Protocol2PacketHandler.

◆ read4ByteTxRx()

virtual int mercury::PacketHandler::read4ByteTxRx ( PortHandler port,
uint8_t  id,
uint16_t  address,
uint32_t *  data,
uint8_t *  error = 0 
)
pure virtual

The function that calls PacketHandler::readTxRx() function for reading 4 byte data @description The function calls PacketHandler::readTxRx(), @description gets 4 byte data from the packet.

Parameters
portPortHandler instance
idMercury ID
addressAddress of the data for read
lengthLength of the data for read
dataData extracted from the packet
errorMercury hardware error
Returns
communication results which come from PacketHandler::txRxPacket()

Implemented in mercury::Protocol2PacketHandler.

◆ readRx()

virtual int mercury::PacketHandler::readRx ( PortHandler port,
uint8_t  id,
uint16_t  length,
uint8_t *  data,
uint8_t *  error = 0 
)
pure virtual

The function that receives the packet and reads the data in the packet @description The function receives the packet which might be come by previous INST_READ instruction packet transmission, @description gets the data from the packet.

Parameters
portPortHandler instance
lengthLength of the data for read
dataData extracted from the packet
errorMercury hardware error
Returns
communication results which come from PacketHandler::rxPacket()

Implemented in mercury::Protocol2PacketHandler.

◆ readTx()

virtual int mercury::PacketHandler::readTx ( PortHandler port,
uint8_t  id,
uint16_t  address,
uint16_t  length 
)
pure virtual

The function that transmits INST_READ instruction packet @description The function makes an instruction packet with INST_READ, @description transmits the packet with PacketHandler::txPacket(). @description It breaks out @description when it tries to transmit to BROADCAST_ID.

Parameters
portPortHandler instance
idMercury ID
addressAddress of the data for read
lengthLength of the data for read
Returns
COMM_NOT_AVAILABLE
when it tries to transmit to BROADCAST_ID
or the other communication results which come from PacketHandler::txPacket()

Implemented in mercury::Protocol2PacketHandler.

◆ readTxRx()

virtual int mercury::PacketHandler::readTxRx ( PortHandler port,
uint8_t  id,
uint16_t  address,
uint16_t  length,
uint8_t *  data,
uint8_t *  error = 0 
)
pure virtual

The function that transmits INST_READ instruction packet, and read data from received packet @description The function makes an instruction packet with INST_READ, @description transmits and receives the packet with PacketHandler::txRxPacket(), @description gets the data from the packet. @description It breaks out @description when it tries to transmit to BROADCAST_ID.

Parameters
portPortHandler instance
idMercury ID
addressAddress of the data for read
lengthLength of the data for read
dataData extracted from the packet
errorMercury hardware error
Returns
COMM_NOT_AVAILABLE
when it tries to transmit to BROADCAST_ID
or the other communication results which come from PacketHandler::txRxPacket()

Implemented in mercury::Protocol2PacketHandler.

◆ reboot()

virtual int mercury::PacketHandler::reboot ( PortHandler port,
uint8_t  id,
uint8_t *  error = 0 
)
pure virtual

The function that makes Mercury reboot @description The function makes an instruction packet with INST_REBOOT, @description transmits the packet with PacketHandler::txRxPacket(), @description then Mercury reboots. @description During reboot, its LED will blink.

Parameters
portPortHandler instance
idMercury ID
errorMercury hardware error
Returns
COMM_NOT_AVAILABLE

Implemented in mercury::Protocol2PacketHandler.

◆ regWriteTxOnly()

virtual int mercury::PacketHandler::regWriteTxOnly ( PortHandler port,
uint8_t  id,
uint16_t  address,
uint16_t  length,
uint8_t *  data 
)
pure virtual

The function that transmits INST_REG_WRITE instruction packet with the data for writing on the Mercury register @description The function makes an instruction packet with INST_REG_WRITE and the data for writing on the Mercury register, @description transmits the packet with PacketHandler::txPacket(). @description The data written in the register will act when INST_ACTION instruction packet is transmitted to the Mercury.

Parameters
portPortHandler instance
idMercury ID
addressAddress of the data for write
lengthLength of the data for write
dataData for write
Returns
communication results which come from PacketHandler::txPacket()

Implemented in mercury::Protocol2PacketHandler.

◆ regWriteTxRx()

virtual int mercury::PacketHandler::regWriteTxRx ( PortHandler port,
uint8_t  id,
uint16_t  address,
uint16_t  length,
uint8_t *  data,
uint8_t *  error = 0 
)
pure virtual

The function that transmits INST_REG_WRITE instruction packet with the data for writing on the Mercury register, and receives the packet @description The function makes an instruction packet with INST_REG_WRITE and the data for writing on the Mercury register, @description transmits and receives the packet with PacketHandler::txRxPacket(), @description gets the error from the packet. @description The data written in the register will act when INST_ACTION instruction packet is transmitted to the Mercury.

Parameters
portPortHandler instance
idMercury ID
addressAddress of the data for write
lengthLength of the data for write
dataData for write
errorMercury hardware error
Returns
communication results which come from PacketHandler::txRxPacket()

Implemented in mercury::Protocol2PacketHandler.

◆ rxPacket()

virtual int mercury::PacketHandler::rxPacket ( PortHandler port,
uint8_t *  rxpacket 
)
pure virtual

The function that receives packet (rxpacket) during designated time via PortHandler port @description The function repeatedly tries to receive rxpacket by PortHandler::readPort() function. @description It breaks out @description when PortHandler::isPacketTimeout() shows the timeout, @description when rxpacket seemed as corrupted, or @description when nothing received.

Parameters
portPortHandler instance
rxpacketreceived packet
Returns
COMM_RX_CORRUPT
when it received the packet but it couldn't find header in the packet
when it found header in the packet but the id, length or error value is out of range
when it received the packet but it is shorted than expected
COMM_RX_TIMEOUT
when there is no rxpacket received until PortHandler::isPacketTimeout() shows the timeout
COMM_SUCCESS
when rxpacket passes checksum test
or COMM_RX_FAIL

Implemented in mercury::Protocol2PacketHandler.

◆ synchronise()

virtual int mercury::PacketHandler::synchronise ( PortHandler port,
uint8_t  id,
uint8_t *  error = 0 
)
pure virtual

The function that synchronises the servo @description This function will synchronise the target Mercury servo. @description transmits the packet with PacketHandler::txRxPacket().

Parameters
portPortHandler instance
idMercury ID
forcesynchronisation
errorMercury hardware error
Returns
communication results

Implemented in mercury::Protocol2PacketHandler.

◆ syncReadTx()

virtual int mercury::PacketHandler::syncReadTx ( PortHandler port,
uint16_t  start_address,
uint16_t  data_length,
uint8_t *  param,
uint16_t  param_length 
)
pure virtual

The function that transmits INST_SYNC_READ instruction packet @description The function makes an instruction packet with INST_SYNC_READ, @description transmits the packet with PacketHandler::txPacket().

Parameters
portPortHandler instance
start_addressAddress of the data for Sync Read
data_lengthLength of the data for Sync Read
paramParameter for Sync Read
param_lengthLength of the data for Sync Read
Returns
communication results which come from PacketHandler::txPacket()

Implemented in mercury::Protocol2PacketHandler.

◆ syncWriteTxOnly()

virtual int mercury::PacketHandler::syncWriteTxOnly ( PortHandler port,
uint16_t  start_address,
uint16_t  data_length,
uint8_t *  param,
uint16_t  param_length 
)
pure virtual

The function that transmits INST_SYNC_WRITE instruction packet @description The function makes an instruction packet with INST_SYNC_WRITE, @description transmits the packet with PacketHandler::txRxPacket().

Parameters
portPortHandler instance
start_addressAddress of the data for Sync Write
data_lengthLength of the data for Sync Write
paramParameter for Sync Write
param_lengthLength of the data for Sync Write
Returns
communication results which come from PacketHandler::txRxPacket()

Implemented in mercury::Protocol2PacketHandler.

◆ txPacket()

virtual int mercury::PacketHandler::txPacket ( PortHandler port,
uint8_t *  txpacket 
)
pure virtual

The function that transmits the instruction packet txpacket via PortHandler port. @description The function clears the port buffer by PortHandler::clearPort() function, @description then transmits txpacket by PortHandler::writePort() function. @description The function activates only when the port is not busy and when the packet is already written on the port buffer.

Parameters
portPortHandler instance
txpacketpacket for transmission
Returns
COMM_PORT_BUSY
when the port is already in use
COMM_TX_ERROR
when txpacket is out of range described by TXPACKET_MAX_LEN
COMM_TX_FAIL
when written packet is shorter than expected
or COMM_SUCCESS

Implemented in mercury::Protocol2PacketHandler.

◆ txRxPacket()

virtual int mercury::PacketHandler::txRxPacket ( PortHandler port,
uint8_t *  txpacket,
uint8_t *  rxpacket,
uint8_t *  error = 0 
)
pure virtual

The function that transmits packet (txpacket) and receives packet (rxpacket) during designated time via PortHandler port @description The function calls PacketHandler::txPacket(), @description and calls PacketHandler::rxPacket() if it succeeds PacketHandler::txPacket(). @description It breaks out @description when it fails PacketHandler::txPacket(), @description when txpacket is called by PacketHandler::broadcastPing() / PacketHandler::syncWriteTxOnly() / PacketHandler::regWriteTxOnly / PacketHandler::action.

Parameters
portPortHandler instance
txpacketpacket for transmission
rxpacketreceived packet
Returns
COMM_SUCCESS
when it succeeds PacketHandler::txPacket() and PacketHandler::rxPacket()
or the other communication results which come from PacketHandler::txPacket() and PacketHandler::rxPacket()

Implemented in mercury::Protocol2PacketHandler.

◆ write1ByteTxOnly()

virtual int mercury::PacketHandler::write1ByteTxOnly ( PortHandler port,
uint8_t  id,
uint16_t  address,
uint8_t  data 
)
pure virtual

The function that calls PacketHandler::writeTxOnly() for writing 1 byte data @description The function calls PacketHandler::writeTxOnly() for writing 1 byte data.

Parameters
portPortHandler instance
idMercury ID
addressAddress of the data for write
dataData for write
Returns
communication results which come from PacketHandler::writeTxOnly()

Implemented in mercury::Protocol2PacketHandler.

◆ write1ByteTxRx()

virtual int mercury::PacketHandler::write1ByteTxRx ( PortHandler port,
uint8_t  id,
uint16_t  address,
uint8_t  data,
uint8_t *  error = 0 
)
pure virtual

The function that calls PacketHandler::writeTxRx() for writing 1 byte data and receives the packet @description The function calls PacketHandler::writeTxRx() for writing 1 byte data and receves the packet, @description gets the error from the packet.

Parameters
portPortHandler instance
idMercury ID
addressAddress of the data for write
dataData for write
errorMercury hardware error
Returns
communication results which come from PacketHandler::writeTxRx()

Implemented in mercury::Protocol2PacketHandler.

◆ write2ByteTxOnly()

virtual int mercury::PacketHandler::write2ByteTxOnly ( PortHandler port,
uint8_t  id,
uint16_t  address,
uint16_t  data 
)
pure virtual

The function that calls PacketHandler::writeTxOnly() for writing 2 byte data @description The function calls PacketHandler::writeTxOnly() for writing 2 byte data.

Parameters
portPortHandler instance
idMercury ID
addressAddress of the data for write
dataData for write
Returns
communication results which come from PacketHandler::writeTxOnly()

Implemented in mercury::Protocol2PacketHandler.

◆ write2ByteTxRx()

virtual int mercury::PacketHandler::write2ByteTxRx ( PortHandler port,
uint8_t  id,
uint16_t  address,
uint16_t  data,
uint8_t *  error = 0 
)
pure virtual

The function that calls PacketHandler::writeTxRx() for writing 2 byte data and receives the packet @description The function calls PacketHandler::writeTxRx() for writing 2 byte data and receves the packet, @description gets the error from the packet.

Parameters
portPortHandler instance
idMercury ID
addressAddress of the data for write
dataData for write
errorMercury hardware error
Returns
communication results which come from PacketHandler::writeTxRx()

Implemented in mercury::Protocol2PacketHandler.

◆ write4ByteTxOnly()

virtual int mercury::PacketHandler::write4ByteTxOnly ( PortHandler port,
uint8_t  id,
uint16_t  address,
uint32_t  data 
)
pure virtual

The function that calls PacketHandler::writeTxOnly() for writing 4 byte data @description The function calls PacketHandler::writeTxOnly() for writing 4 byte data.

Parameters
portPortHandler instance
idMercury ID
addressAddress of the data for write
dataData for write
Returns
communication results which come from PacketHandler::writeTxOnly()

Implemented in mercury::Protocol2PacketHandler.

◆ write4ByteTxRx()

virtual int mercury::PacketHandler::write4ByteTxRx ( PortHandler port,
uint8_t  id,
uint16_t  address,
uint32_t  data,
uint8_t *  error = 0 
)
pure virtual

The function that calls PacketHandler::writeTxRx() for writing 4 byte data and receives the packet @description The function calls PacketHandler::writeTxRx() for writing 4 byte data and receves the packet, @description gets the error from the packet.

Parameters
portPortHandler instance
idMercury ID
addressAddress of the data for write
dataData for write
errorMercury hardware error
Returns
communication results which come from PacketHandler::writeTxRx()

Implemented in mercury::Protocol2PacketHandler.

◆ writeTxOnly()

virtual int mercury::PacketHandler::writeTxOnly ( PortHandler port,
uint8_t  id,
uint16_t  address,
uint16_t  length,
uint8_t *  data 
)
pure virtual

The function that transmits INST_WRITE instruction packet with the data for write @description The function makes an instruction packet with INST_WRITE and the data for write, @description transmits the packet with PacketHandler::txPacket().

Parameters
portPortHandler instance
idMercury ID
addressAddress of the data for write
lengthLength of the data for write
dataData for write
Returns
communication results which come from PacketHandler::txPacket()

Implemented in mercury::Protocol2PacketHandler.

◆ writeTxRx()

virtual int mercury::PacketHandler::writeTxRx ( PortHandler port,
uint8_t  id,
uint16_t  address,
uint16_t  length,
uint8_t *  data,
uint8_t *  error = 0 
)
pure virtual

The function that transmits INST_WRITE instruction packet with the data for write, and receives the packet @description The function makes an instruction packet with INST_WRITE and the data for write, @description transmits and receives the packet with PacketHandler::txRxPacket(), @description gets the error from the packet.

Parameters
portPortHandler instance
idMercury ID
addressAddress of the data for write
lengthLength of the data for write
dataData for write
errorMercury hardware error
Returns
communication results which come from PacketHandler::txRxPacket()

Implemented in mercury::Protocol2PacketHandler.


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