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

The class for control Mercury by using Protocol2.0. More...

#include <protocol2_packet_handler.h>

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

Public Member Functions

virtual ~Protocol2PacketHandler ()
 
float getProtocolVersion ()
 The function that returns Protocol version used in Protocol2PacketHandler (2.0) More...
 
const char * getTxRxResult (int result)
 The function that gets description of communication result. More...
 
const char * getRxPacketError (uint8_t error)
 The function that gets description of hardware error. More...
 
int txPacket (PortHandler *port, uint8_t *txpacket)
 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...
 
int rxPacket (PortHandler *port, uint8_t *rxpacket)
 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...
 
int txRxPacket (PortHandler *port, uint8_t *txpacket, uint8_t *rxpacket, uint8_t *error=0)
 The function that transmits packet (txpacket) and receives packet (rxpacket) during designated time via PortHandler port @description The function calls Protocol2PacketHandler::txPacket(), @description and calls Protocol2PacketHandler::rxPacket() if it succeeds Protocol2PacketHandler::txPacket(). @description It breaks out @description when it fails Protocol2PacketHandler::txPacket(), @description when txpacket is called by Protocol2PacketHandler::broadcastPing() / Protocol2PacketHandler::syncWriteTxOnly() / Protocol2PacketHandler::regWriteTxOnly / Protocol2PacketHandler::action. More...
 
int ping (PortHandler *port, uint8_t id, uint8_t *error=0)
 The function that pings Mercury but doesn't take its model number @description The function calls Protocol2PacketHandler::ping() which gets Mercury model number, @description but doesn't carry the model number. More...
 
int ping (PortHandler *port, uint8_t id, uint16_t *model_number, uint8_t *error=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 Protocol2PacketHandler::txRxPacket(), @description and call Protocol2PacketHandler::readTxRx to read model_number in the rx buffer. @description It breaks out @description when it tries to transmit to BROADCAST_ID. More...
 
int broadcastPing (PortHandler *port, std::vector< uint8_t > &id_list)
 (Available only in Protocol 2.0) The function that pings all connected Mercury More...
 
int action (PortHandler *port, uint8_t id)
 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 Protocol2PacketHandler::txRxPacket(). @description To use this function, Mercury register should be set by Protocol2PacketHandler::regWriteTxOnly() or Protocol2PacketHandler::regWriteTxRx() More...
 
int reboot (PortHandler *port, uint8_t id, uint8_t *error=0)
 The function that makes Mercury reboot @description The function makes an instruction packet with INST_REBOOT, @description transmits the packet with Protocol2PacketHandler::txRxPacket(), @description then Mercury reboots. @description During reboot, its LED will blink. More...
 
int clearMultiTurn (PortHandler *port, uint8_t id, uint8_t *error=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...
 
int factoryReset (PortHandler *port, uint8_t id, uint8_t option, uint8_t *error=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 Protocol2PacketHandler::txRxPacket(). @description Be careful of the use. More...
 
int readTx (PortHandler *port, uint8_t id, uint16_t address, uint16_t length)
 The function that transmits INST_READ instruction packet @description The function makes an instruction packet with INST_READ, @description transmits the packet with Protocol2PacketHandler::txPacket(). @description It breaks out @description when it tries to transmit to BROADCAST_ID. More...
 
int readRx (PortHandler *port, uint8_t id, uint16_t length, uint8_t *data, uint8_t *error=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...
 
int readTxRx (PortHandler *port, uint8_t id, uint16_t address, uint16_t length, uint8_t *data, uint8_t *error=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 Protocol2PacketHandler::txRxPacket(), @description gets the data from the packet. @description It breaks out @description when it tries to transmit to BROADCAST_ID. More...
 
int read1ByteTx (PortHandler *port, uint8_t id, uint16_t address)
 The function that calls Protocol2PacketHandler::readTx() function for reading 1 byte data @description The function calls Protocol2PacketHandler::readTx() function for reading 1 byte data. More...
 
int read1ByteRx (PortHandler *port, uint8_t id, uint8_t *data, uint8_t *error=0)
 The function that calls Protocol2PacketHandler::readRx() function and reads 1 byte data on the packet @description The function calls Protocol2PacketHandler::readRx() function, @description gets 1 byte data from the packet. More...
 
int read1ByteTxRx (PortHandler *port, uint8_t id, uint16_t address, uint8_t *data, uint8_t *error=0)
 The function that calls Protocol2PacketHandler::readTxRx() function for reading 1 byte data @description The function calls Protocol2PacketHandler::readTxRx(), @description gets 1 byte data from the packet. More...
 
int read2ByteTx (PortHandler *port, uint8_t id, uint16_t address)
 The function that calls Protocol2PacketHandler::readTx() function for reading 2 byte data @description The function calls Protocol2PacketHandler::readTx() function for reading 2 byte data. More...
 
int read2ByteRx (PortHandler *port, uint8_t id, uint16_t *data, uint8_t *error=0)
 The function that calls Protocol2PacketHandler::readRx() function and reads 2 byte data on the packet @description The function calls Protocol2PacketHandler::readRx() function, @description gets 2 byte data from the packet. More...
 
int read2ByteTxRx (PortHandler *port, uint8_t id, uint16_t address, uint16_t *data, uint8_t *error=0)
 The function that calls Protocol2PacketHandler::readTxRx() function for reading 2 byte data @description The function calls Protocol2PacketHandler::readTxRx(), @description gets 2 byte data from the packet. More...
 
int read4ByteTx (PortHandler *port, uint8_t id, uint16_t address)
 The function that calls Protocol2PacketHandler::readTx() function for reading 4 byte data @description The function calls Protocol2PacketHandler::readTx() function for reading 4 byte data. More...
 
int read4ByteRx (PortHandler *port, uint8_t id, uint32_t *data, uint8_t *error=0)
 The function that calls Protocol2PacketHandler::readRx() function and reads 4 byte data on the packet @description The function calls Protocol2PacketHandler::readRx() function, @description gets 4 byte data from the packet. More...
 
int read4ByteTxRx (PortHandler *port, uint8_t id, uint16_t address, uint32_t *data, uint8_t *error=0)
 The function that calls Protocol2PacketHandler::readTxRx() function for reading 4 byte data @description The function calls Protocol2PacketHandler::readTxRx(), @description gets 4 byte data from the packet. More...
 
int writeTxOnly (PortHandler *port, uint8_t id, uint16_t address, uint16_t length, uint8_t *data)
 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 Protocol2PacketHandler::txPacket(). More...
 
int writeTxRx (PortHandler *port, uint8_t id, uint16_t address, uint16_t length, uint8_t *data, uint8_t *error=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 Protocol2PacketHandler::txRxPacket(), @description gets the error from the packet. More...
 
int write1ByteTxOnly (PortHandler *port, uint8_t id, uint16_t address, uint8_t data)
 The function that calls Protocol2PacketHandler::writeTxOnly() for writing 1 byte data @description The function calls Protocol2PacketHandler::writeTxOnly() for writing 1 byte data. More...
 
int write1ByteTxRx (PortHandler *port, uint8_t id, uint16_t address, uint8_t data, uint8_t *error=0)
 The function that calls Protocol2PacketHandler::writeTxRx() for writing 1 byte data and receives the packet @description The function calls Protocol2PacketHandler::writeTxRx() for writing 1 byte data and receves the packet, @description gets the error from the packet. More...
 
int write2ByteTxOnly (PortHandler *port, uint8_t id, uint16_t address, uint16_t data)
 The function that calls Protocol2PacketHandler::writeTxOnly() for writing 2 byte data @description The function calls Protocol2PacketHandler::writeTxOnly() for writing 2 byte data. More...
 
int write2ByteTxRx (PortHandler *port, uint8_t id, uint16_t address, uint16_t data, uint8_t *error=0)
 The function that calls Protocol2PacketHandler::writeTxRx() for writing 2 byte data and receives the packet @description The function calls Protocol2PacketHandler::writeTxRx() for writing 2 byte data and receves the packet, @description gets the error from the packet. More...
 
int write4ByteTxOnly (PortHandler *port, uint8_t id, uint16_t address, uint32_t data)
 The function that calls Protocol2PacketHandler::writeTxOnly() for writing 4 byte data @description The function calls Protocol2PacketHandler::writeTxOnly() for writing 4 byte data. More...
 
int write4ByteTxRx (PortHandler *port, uint8_t id, uint16_t address, uint32_t data, uint8_t *error=0)
 The function that calls Protocol2PacketHandler::writeTxRx() for writing 4 byte data and receives the packet @description The function calls Protocol2PacketHandler::writeTxRx() for writing 4 byte data and receves the packet, @description gets the error from the packet. More...
 
int regWriteTxOnly (PortHandler *port, uint8_t id, uint16_t address, uint16_t length, uint8_t *data)
 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 Protocol2PacketHandler::txPacket(). @description The data written in the register will act when INST_ACTION instruction packet is transmitted to the Mercury. More...
 
int regWriteTxRx (PortHandler *port, uint8_t id, uint16_t address, uint16_t length, uint8_t *data, uint8_t *error=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 Protocol2PacketHandler::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...
 
int syncReadTx (PortHandler *port, uint16_t start_address, uint16_t data_length, uint8_t *param, uint16_t param_length)
 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 Protocol2PacketHandler::txPacket(). More...
 
int syncWriteTxOnly (PortHandler *port, uint16_t start_address, uint16_t data_length, uint8_t *param, uint16_t param_length)
 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 Protocol2PacketHandler::txRxPacket(). More...
 
int synchronise (PortHandler *port, uint8_t id, uint8_t *error)
 The function that synchronises the servo @description This function will synchronise the target Mercury servo. @description transmits the packet with PacketHandler::txRxPacket(). More...
 
- Public Member Functions inherited from mercury::PacketHandler
virtual ~PacketHandler ()
 

Static Public Member Functions

static Protocol2PacketHandlergetInstance ()
 The function that returns Protocol2PacketHandler instance. More...
 
- Static Public Member Functions inherited from mercury::PacketHandler
static PacketHandlergetPacketHandler ()
 The function that returns PacketHandler instance. More...
 

Additional Inherited Members

- Protected Member Functions inherited from mercury::PacketHandler
 PacketHandler ()
 

Detailed Description

The class for control Mercury by using Protocol2.0.

Definition at line 37 of file protocol2_packet_handler.h.

Constructor & Destructor Documentation

◆ ~Protocol2PacketHandler()

virtual mercury::Protocol2PacketHandler::~Protocol2PacketHandler ( )
inlinevirtual

Definition at line 55 of file protocol2_packet_handler.h.

Member Function Documentation

◆ action()

int Protocol2PacketHandler::action ( PortHandler port,
uint8_t  id 
)
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 Protocol2PacketHandler::txRxPacket(). @description To use this function, Mercury register should be set by Protocol2PacketHandler::regWriteTxOnly() or Protocol2PacketHandler::regWriteTxRx()

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

Implements mercury::PacketHandler.

Definition at line 591 of file protocol2_packet_handler.cpp.

◆ broadcastPing()

int Protocol2PacketHandler::broadcastPing ( PortHandler port,
std::vector< uint8_t > &  id_list 
)
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

Implements mercury::PacketHandler.

Definition at line 495 of file protocol2_packet_handler.cpp.

◆ clearMultiTurn()

int Protocol2PacketHandler::clearMultiTurn ( PortHandler port,
uint8_t  id,
uint8_t *  error = 0 
)
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()

Implements mercury::PacketHandler.

Definition at line 616 of file protocol2_packet_handler.cpp.

◆ factoryReset()

int Protocol2PacketHandler::factoryReset ( PortHandler port,
uint8_t  id,
uint8_t  option,
uint8_t *  error = 0 
)
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 Protocol2PacketHandler::txRxPacket(). @description Be careful of the use.

Parameters
portPortHandler instance
idMercury ID
optionReset option (0xFF for reset all values / 0x01 for reset all values except ID / 0x02 for reset all values except ID and Baudrate)
errorMercury hardware error
Returns
communication results which come from Protocol2PacketHandler::txRxPacket()

Implements mercury::PacketHandler.

Definition at line 634 of file protocol2_packet_handler.cpp.

◆ getInstance()

static Protocol2PacketHandler* mercury::Protocol2PacketHandler::getInstance ( )
inlinestatic

The function that returns Protocol2PacketHandler instance.

Returns
Protocol2PacketHandler instance

Definition at line 53 of file protocol2_packet_handler.h.

◆ getProtocolVersion()

float mercury::Protocol2PacketHandler::getProtocolVersion ( )
inlinevirtual

The function that returns Protocol version used in Protocol2PacketHandler (2.0)

Returns
2.0

Implements mercury::PacketHandler.

Definition at line 61 of file protocol2_packet_handler.h.

◆ getRxPacketError()

const char * Protocol2PacketHandler::getRxPacketError ( uint8_t  error)
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)

Implements mercury::PacketHandler.

Definition at line 110 of file protocol2_packet_handler.cpp.

◆ getTxRxResult()

const char * Protocol2PacketHandler::getTxRxResult ( int  result)
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)

Implements mercury::PacketHandler.

Definition at line 74 of file protocol2_packet_handler.cpp.

◆ ping() [1/2]

int Protocol2PacketHandler::ping ( PortHandler port,
uint8_t  id,
uint16_t *  model_number,
uint8_t *  error = 0 
)
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 Protocol2PacketHandler::txRxPacket(), @description and call Protocol2PacketHandler::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 Protocol2PacketHandler::txRxPacket() and Protocol2PacketHandler::readTxRx()

Implements mercury::PacketHandler.

Definition at line 473 of file protocol2_packet_handler.cpp.

◆ ping() [2/2]

int Protocol2PacketHandler::ping ( PortHandler port,
uint8_t  id,
uint8_t *  error = 0 
)
virtual

The function that pings Mercury but doesn't take its model number @description The function calls Protocol2PacketHandler::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 Protocol2PacketHandler::ping()

Implements mercury::PacketHandler.

Definition at line 468 of file protocol2_packet_handler.cpp.

◆ read1ByteRx()

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

The function that calls Protocol2PacketHandler::readRx() function and reads 1 byte data on the packet @description The function calls Protocol2PacketHandler::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 Protocol2PacketHandler::readRx()

Implements mercury::PacketHandler.

Definition at line 747 of file protocol2_packet_handler.cpp.

◆ read1ByteTx()

int Protocol2PacketHandler::read1ByteTx ( PortHandler port,
uint8_t  id,
uint16_t  address 
)
virtual

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

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

Implements mercury::PacketHandler.

Definition at line 743 of file protocol2_packet_handler.cpp.

◆ read1ByteTxRx()

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

The function that calls Protocol2PacketHandler::readTxRx() function for reading 1 byte data @description The function calls Protocol2PacketHandler::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 Protocol2PacketHandler::txRxPacket()

Implements mercury::PacketHandler.

Definition at line 755 of file protocol2_packet_handler.cpp.

◆ read2ByteRx()

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

The function that calls Protocol2PacketHandler::readRx() function and reads 2 byte data on the packet @description The function calls Protocol2PacketHandler::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 Protocol2PacketHandler::readRx()

Implements mercury::PacketHandler.

Definition at line 768 of file protocol2_packet_handler.cpp.

◆ read2ByteTx()

int Protocol2PacketHandler::read2ByteTx ( PortHandler port,
uint8_t  id,
uint16_t  address 
)
virtual

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

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

Implements mercury::PacketHandler.

Definition at line 764 of file protocol2_packet_handler.cpp.

◆ read2ByteTxRx()

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

The function that calls Protocol2PacketHandler::readTxRx() function for reading 2 byte data @description The function calls Protocol2PacketHandler::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 Protocol2PacketHandler::txRxPacket()

Implements mercury::PacketHandler.

Definition at line 776 of file protocol2_packet_handler.cpp.

◆ read4ByteRx()

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

The function that calls Protocol2PacketHandler::readRx() function and reads 4 byte data on the packet @description The function calls Protocol2PacketHandler::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 Protocol2PacketHandler::readRx()

Implements mercury::PacketHandler.

Definition at line 789 of file protocol2_packet_handler.cpp.

◆ read4ByteTx()

int Protocol2PacketHandler::read4ByteTx ( PortHandler port,
uint8_t  id,
uint16_t  address 
)
virtual

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

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

Implements mercury::PacketHandler.

Definition at line 785 of file protocol2_packet_handler.cpp.

◆ read4ByteTxRx()

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

The function that calls Protocol2PacketHandler::readTxRx() function for reading 4 byte data @description The function calls Protocol2PacketHandler::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 Protocol2PacketHandler::txRxPacket()

Implements mercury::PacketHandler.

Definition at line 797 of file protocol2_packet_handler.cpp.

◆ readRx()

int Protocol2PacketHandler::readRx ( PortHandler port,
uint8_t  id,
uint16_t  length,
uint8_t *  data,
uint8_t *  error = 0 
)
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 Protocol2PacketHandler::rxPacket()

Implements mercury::PacketHandler.

Definition at line 675 of file protocol2_packet_handler.cpp.

◆ readTx()

int Protocol2PacketHandler::readTx ( PortHandler port,
uint8_t  id,
uint16_t  address,
uint16_t  length 
)
virtual

The function that transmits INST_READ instruction packet @description The function makes an instruction packet with INST_READ, @description transmits the packet with Protocol2PacketHandler::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 Protocol2PacketHandler::txPacket()

Implements mercury::PacketHandler.

Definition at line 648 of file protocol2_packet_handler.cpp.

◆ readTxRx()

int Protocol2PacketHandler::readTxRx ( PortHandler port,
uint8_t  id,
uint16_t  address,
uint16_t  length,
uint8_t *  data,
uint8_t *  error = 0 
)
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 Protocol2PacketHandler::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 Protocol2PacketHandler::txRxPacket()

Implements mercury::PacketHandler.

Definition at line 702 of file protocol2_packet_handler.cpp.

◆ reboot()

int Protocol2PacketHandler::reboot ( PortHandler port,
uint8_t  id,
uint8_t *  error = 0 
)
virtual

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

Parameters
portPortHandler instance
idMercury ID
errorMercury hardware error
Returns
COMM_NOT_AVAILABLE

Implements mercury::PacketHandler.

Definition at line 603 of file protocol2_packet_handler.cpp.

◆ regWriteTxOnly()

int Protocol2PacketHandler::regWriteTxOnly ( PortHandler port,
uint8_t  id,
uint16_t  address,
uint16_t  length,
uint8_t *  data 
)
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 Protocol2PacketHandler::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 Protocol2PacketHandler::txPacket()

Implements mercury::PacketHandler.

Definition at line 891 of file protocol2_packet_handler.cpp.

◆ regWriteTxRx()

int Protocol2PacketHandler::regWriteTxRx ( PortHandler port,
uint8_t  id,
uint16_t  address,
uint16_t  length,
uint8_t *  data,
uint8_t *  error = 0 
)
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 Protocol2PacketHandler::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 Protocol2PacketHandler::txRxPacket()

Implements mercury::PacketHandler.

Definition at line 917 of file protocol2_packet_handler.cpp.

◆ rxPacket()

int Protocol2PacketHandler::rxPacket ( PortHandler port,
uint8_t *  rxpacket 
)
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

Implements mercury::PacketHandler.

Definition at line 312 of file protocol2_packet_handler.cpp.

◆ synchronise()

int Protocol2PacketHandler::synchronise ( PortHandler port,
uint8_t  id,
uint8_t *  error = 0 
)
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

Implements mercury::PacketHandler.

Definition at line 1000 of file protocol2_packet_handler.cpp.

◆ syncReadTx()

int Protocol2PacketHandler::syncReadTx ( PortHandler port,
uint16_t  start_address,
uint16_t  data_length,
uint8_t *  param,
uint16_t  param_length 
)
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 Protocol2PacketHandler::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 Protocol2PacketHandler::txPacket()

Implements mercury::PacketHandler.

Definition at line 943 of file protocol2_packet_handler.cpp.

◆ syncWriteTxOnly()

int Protocol2PacketHandler::syncWriteTxOnly ( PortHandler port,
uint16_t  start_address,
uint16_t  data_length,
uint8_t *  param,
uint16_t  param_length 
)
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 Protocol2PacketHandler::txRxPacket().

Parameters
portPortHandler instance
start_addressAddress of the data for Sync Write
data_lengthLength of the data for Sync Write
paramParameter for Sync Write {ID1, DATA0, DATA1, ..., DATAn, ID2, DATA0, DATA1, ..., DATAn, ID3, DATA0, DATA1, ..., DATAn}
param_lengthLength of the data for Sync Write
Returns
communication results which come from Protocol2PacketHandler::txRxPacket()

Implements mercury::PacketHandler.

Definition at line 973 of file protocol2_packet_handler.cpp.

◆ txPacket()

int Protocol2PacketHandler::txPacket ( PortHandler port,
uint8_t *  txpacket 
)
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

Implements mercury::PacketHandler.

Definition at line 268 of file protocol2_packet_handler.cpp.

◆ txRxPacket()

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

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

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

Implements mercury::PacketHandler.

Definition at line 428 of file protocol2_packet_handler.cpp.

◆ write1ByteTxOnly()

int Protocol2PacketHandler::write1ByteTxOnly ( PortHandler port,
uint8_t  id,
uint16_t  address,
uint8_t  data 
)
virtual

The function that calls Protocol2PacketHandler::writeTxOnly() for writing 1 byte data @description The function calls Protocol2PacketHandler::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 Protocol2PacketHandler::writeTxOnly()

Implements mercury::PacketHandler.

Definition at line 858 of file protocol2_packet_handler.cpp.

◆ write1ByteTxRx()

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

The function that calls Protocol2PacketHandler::writeTxRx() for writing 1 byte data and receives the packet @description The function calls Protocol2PacketHandler::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 Protocol2PacketHandler::writeTxRx()

Implements mercury::PacketHandler.

Definition at line 863 of file protocol2_packet_handler.cpp.

◆ write2ByteTxOnly()

int Protocol2PacketHandler::write2ByteTxOnly ( PortHandler port,
uint8_t  id,
uint16_t  address,
uint16_t  data 
)
virtual

The function that calls Protocol2PacketHandler::writeTxOnly() for writing 2 byte data @description The function calls Protocol2PacketHandler::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 Protocol2PacketHandler::writeTxOnly()

Implements mercury::PacketHandler.

Definition at line 869 of file protocol2_packet_handler.cpp.

◆ write2ByteTxRx()

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

The function that calls Protocol2PacketHandler::writeTxRx() for writing 2 byte data and receives the packet @description The function calls Protocol2PacketHandler::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 Protocol2PacketHandler::writeTxRx()

Implements mercury::PacketHandler.

Definition at line 874 of file protocol2_packet_handler.cpp.

◆ write4ByteTxOnly()

int Protocol2PacketHandler::write4ByteTxOnly ( PortHandler port,
uint8_t  id,
uint16_t  address,
uint32_t  data 
)
virtual

The function that calls Protocol2PacketHandler::writeTxOnly() for writing 4 byte data @description The function calls Protocol2PacketHandler::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 Protocol2PacketHandler::writeTxOnly()

Implements mercury::PacketHandler.

Definition at line 880 of file protocol2_packet_handler.cpp.

◆ write4ByteTxRx()

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

The function that calls Protocol2PacketHandler::writeTxRx() for writing 4 byte data and receives the packet @description The function calls Protocol2PacketHandler::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 Protocol2PacketHandler::writeTxRx()

Implements mercury::PacketHandler.

Definition at line 885 of file protocol2_packet_handler.cpp.

◆ writeTxOnly()

int Protocol2PacketHandler::writeTxOnly ( PortHandler port,
uint8_t  id,
uint16_t  address,
uint16_t  length,
uint8_t *  data 
)
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 Protocol2PacketHandler::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 Protocol2PacketHandler::txPacket()

Implements mercury::PacketHandler.

Definition at line 806 of file protocol2_packet_handler.cpp.

◆ writeTxRx()

int Protocol2PacketHandler::writeTxRx ( PortHandler port,
uint8_t  id,
uint16_t  address,
uint16_t  length,
uint8_t *  data,
uint8_t *  error = 0 
)
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 Protocol2PacketHandler::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 Protocol2PacketHandler::txRxPacket()

Implements mercury::PacketHandler.

Definition at line 832 of file protocol2_packet_handler.cpp.


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