Skip to main content

python_packethandler

  • Description

Base functions for packet construction.

  • Members

    None

  • Methods

MethodsDescription
packetHandlerInitializes members of packet data pointer struct
getTxRxResultGets communication result
getRxPacketErrorGets hardware error
txPacketTransmits the packet
rxPacketReceives the packet
txRxPacketTransmits and receives the packet
pingping DYNAMIXEL
broadcastPingping all connected DYNAMIXEL's
actionCommands ‘Run’ the Regwritten
regWriteWrites the packets and wait for the ‘Action’ command
rebootReboots DYNAMIXEL
factoryResetResets all DYNAMIXEL settings
readTxTransmits N byte read instruction packet
readRxReceives N byte read status packet
readTxRxTransmits and receives N byte packet
read1ByteTxTransmits 1 byte read instruction packet
read1ByteRxReceives 1 byte read status packet
read1ByteTxRxTransmits and receives 1 byte packet
read2ByteTxTransmits 2 byte read instruction packet
read2ByteRxReceives 2 byte read status packet
read2ByteTxRxTransmits and receives 2 byte packet
read4ByteTxTransmits 4 byte read instruction packet
read4ByteRxReceives 4 byte read status packet
read4ByteTxRxTransmits and receives 4 byte packet
writeTxOnlyTransmits N byte write instruction packet
writeTxRxTransmits and receives N byte packet
write1ByteTxOnlyTransmits 1 byte write instruction packet
write1ByteTxRxTransmits and receives 1 byte packet
write2ByteTxOnlyTransmits 2 byte write instruction packet
write2ByteTxRxTransmits and receives 2 byte packet
write4ByteTxOnlyTransmits 4 byte write instruction packet
write4ByteTxRxTransmits and receives 4 byte packet
regWriteTxOnlyTransmits register write instruction packet
regWriteTxRxTransmits and receives register write packet
syncReadTxTransmits N byte sync read Instruction packet
syncWriteTxOnlyTransmits N byte sync write Instruction packet
bulkReadTxTransmits N byte bulk read Instruction packet
bulkWriteTxOnlyTransmits N byte bulk write Instruction packet
  • Enumerator
EnumeratorDescription
DXL_MAKEWORD(a, b)makes value from a and b to word type
DXL_MAKEDWORD(a, b)makes value from a and b to dword type
DXL_LOWORD(l)gets lower word type value from l
DXL_HIWORD(l)gets higher word type value from l
DXL_LOBYTE(w)gets lower byte type value from w
DXL_HIBYTE(w)gets higher byte type value from w
BROADCAST_ID:= 0xFE Broadcast ID
MAX_ID:= 0xFC Maximum ID value
INST_PING:= 1 Instruction value of ping
INST_READ:= 2 Instruction value of Read
INST_WRITE:= 3 Instruction value of Write
INST_REG_WRITE:= 4 Instruction value of Register Write
INST_ACTION:= 5 Instruction value of Action
INST_FACTORY_RESET:= 6 Instruction value of Factory Reset
INST_SYNC_WRITE:= 131 Instruction value of Sync Write
INST_BULK_READ:= 146 Instruction value of Bulk Read
INST_REBOOT:= 8 Instruction value of Reboot
INST_STATUS:= 85 Instruction value of Status
INST_SYNC_READ:= 130 Instruction value of Sync Read
INST_BULK_WRITE:= 147 Instruction value of Bulk Write
COMM_SUCCESS:= 0 Status of Communication Success
COMM_PORT_BUSY:= -1000 Status of Port in use
COMM_TX_FAIL:= -1001 Status of Transmit packet failed
COMM_RX_FAIL:= -1002 Status of Receive packet failed
COMM_TX_ERROR:= -2000 Status of Transmit packet error
COMM_RX_WAITING:= -3000 Status of Receive packet waiting
COMM_RX_TIMEOUT:= -3001 Status of Receive packet timeout
COMM_RX_CORRUPT:= -3002 Status of Receive packet corrupt
COMM_NOT_AVAILABLE:= -9000 Status of Unavailable in protocol 1.0

Method References

packetHandler
  • Syntax
packetHandler()
  • Parameters

    None

  • Detailed Description

    This function initializes the parameters for packet construction. The function resizes packetData struct and initialzes struct members.

getTxRxResult
  • Syntax
getTxRxResult(result)
  • Parameters
ParametersDescription
resultCommunication result
  • Detailed Description

    This function gets communication result as string type.

getRxPacketError
  • Syntax
getRxPacketError(error)
  • Parameters
ParametersDescription
errorHardware error
  • Detailed Description

    This function gets hardware error sent by DYNAMIXEL.

txPacket
  • Syntax
txPacket(port, txpacket)
  • Parameters
ParametersDescription
portPortHandler instance
txpacketpacket byte for sending
  • Detailed Description

    The function transmits the packet. The function clears the port by clearPort function at first, and stores data in the txpacket storage of port. The communication result and the hardware error are available when the function is terminated.

rxPacket
  • Syntax
void rxPacket(port)
  • Parameters
ParametersDescription
portPortHandler instance
  • Detailed Description

    The function repeatedly tries to receive packets from port rx buffer until whole packets that it waits to get have arrived, or the packet wait time limit is over, while it filters garbage signals and verify correctness of received signal. The communication result and the hardware error are available when the function is terminated.

txRxPacket
  • Syntax
txRxPacket(port, txpacket)

  • Parameters
ParametersDescription
portPortHandler instance
txpacketpacket byte for sending
  • Detailed Description

    The function stores data for being written into the array for packet transmission and gets data read from rx buffer of #port_num port by txPacket and rxPacket functions. When txPacket function succeeds to communicate, it will continue to rxPacket and finishes the process if the packet succeeds to be received. In particular, the group handler functions for write, such as SyncWrite, and BulkWrite, don’t use rxPacket so the function finishes its operation immediately after the 'txPacket2'. Before the rxPacket, it sets packet timeout if the instruction of received packet is for read. The communication result and the hardware error are available when the function is terminated.

ping
  • Syntax
ping(port, dxl_id)

  • Parameters
ParametersDescription
portPortHandler instance
dxl_idDYNAMIXEL ID
  • Detailed Description

    The function uses pingGetModelNum without requesting DYNAMIXEL to send its the model number. The communication result and the hardware error are available when the function is terminated.

broadcastPing
  • Syntax
broadcastPing(port, dxl_id)

  • Parameters
ParametersDescription
portPortHandler instance
dxl_idDYNAMIXEL ID
  • Detailed Description

    The function finds all connected dynamixels and store their id in the list. The function is unavailable in protocol 1.0.

action
  • Syntax
action(port, dxl_id)
  • Parameters
ParametersDescription
portPortHandler instance
dxl_idDYNAMIXEL ID
  • Detailed Description

    The function pulls the trigger of sending txpacket previously set by regWriteTxOnly or regWriteTxRx function, using txRxPacket function. The communication result and the hardware error are available when the function is terminated.

reboot
  • Syntax
void reboot(port, dxl_id)
  • Parameters
ParametersDescription
portPortHandler instance
dxl_idDYNAMIXEL ID
  • Detailed Description

    The function constructs the transmission packet with reboot instruction, and starts txRxPacket. The function may perform its role when the DYNAMIXEL stops working caused by hardware error. The communication result and the hardware error are available when the function is terminated. The function is unavailable in protocol 1.0.

factoryReset
  • Syntax
factoryReset(port, dxl_id, option)

  • Parameters
ParametersDescription
portPortHandler instance
dxl_idDYNAMIXEL ID
optionReset option
  • Detailed Description

    The function constructs the transmission packet for reset DYNAMIXEL, and starts txRxPacket. The resets targeted DYNAMIXEL's settings to the factory default settings. The option indicates the range of which items on the control table should be reset: 0xFF for resetting all values, 0x01 for resetting all values except ID, 0x02 for resetting all values except ID and Baudrate. The communication result and the hardware error are available when the function is terminated. In protocol 1.0, option is selectable with only full-reset mode 0x00.

readTx
  • Syntax
readTx(port, dxl_id, address, length)

  • Parameters
ParametersDescription
portPortHandler instance
dxl_idDYNAMIXEL ID
addressAddress on the control table of DYNAMIXEL
lengthPacket length
  • Detailed Description

    The function constructs the transmission packet with read instruction, and starts txPacket. Then the function calls setPacketTimeout function when packet transmission succeeds. The function can't control more than one DYNAMIXEL at once. The communication result and the hardware error are available when the function is terminated.

readRx
  • Syntax
readRx(port, dxl_id, length)
  • Parameters
ParametersDescription
portPortHandler instance
dxl_idDYNAMIXEL ID
lengthPacket length
  • Detailed Description

    The function calls rxPacket2 function and gets the packet from read data storage if the communication succeeds. The communication result and the hardware error are available when the function is terminated.

readTxRx
  • Syntax
readTxRx(port, dxl_id, address, length)
  • Parameters
ParametersDescription
portPortHandler instance
dxl_idDYNAMIXEL ID
addressAddress on the control table of DYNAMIXEL
lengthPacket length
  • Detailed Description

    The function calls readTx function and readRx function. readRx function will be called when readTx succeeds. The communication result and the hardware error are available when the function is terminated.

read1ByteTx
  • Syntax
read1ByteTx(port, dxl_id, address)
  • Parameters
ParametersDescription
portPortHandler instance
dxl_idDYNAMIXEL ID
addressAddress on the control table of DYNAMIXEL
  • Detailed Description

    The function calls readTx function to send 1 Byte read intended packet transmission. The communication result and the hardware error are available when the function is terminated.

read1ByteRx
  • Syntax
read1ByteRx(port, dxl_id)
  • Parameters
ParametersDescription
portPortHandler instance
dxl_idDYNAMIXEL ID
  • Detailed Description

    The function calls readRx function to receive response packet of 1 Byte read intended packet transmission. The communication result and the hardware error are available when the function is terminated.

read1ByteTxRx
  • Syntax
read1ByteTxRx(port, dxl_id, address)
  • Parameters
ParametersDescription
portPortHandler instance
dxl_idDYNAMIXEL ID
addressAddress on the control table of DYNAMIXEL
  • Detailed Description

    The function calls readTxRx function to read 1 Byte data from DYNAMIXEL. The communication result and the hardware error are available when the function is terminated.

read2ByteTx
  • Syntax
read2ByteTx(port, dxl_id, address)
  • Parameters
ParametersDescription
portPortHandler instance
dxl_idDYNAMIXEL ID
addressAddress on the control table of DYNAMIXEL
  • Detailed Description

    The function calls readTx function to send 2 Byte read intended packet transmission. The communication result and the hardware error are available when the function is terminated.

read2ByteRx
  • Syntax
read2ByteRx(port, dxl_id)
  • Parameters
ParametersDescription
portPortHandler instance
dxl_idDYNAMIXEL ID
  • Detailed Description

    The function calls readRx function to receive response packet of 2 Byte read intended packet transmission. The communication result and the hardware error are available when the function is terminated.

read2ByteTxRx
  • Syntax
read2ByteTxRx(port, dxl_id, address)
  • Parameters
ParametersDescription
portPortHandler instance
dxl_idDYNAMIXEL ID
addressAddress on the control table of DYNAMIXEL
  • Detailed Description

    The function calls readTxRx function to read 2 Byte data from DYNAMIXEL. The communication result and the hardware error are available when the function is terminated.

read4ByteTx
  • Syntax
read4ByteTx(port, dxl_id, address)
  • Parameters
ParametersDescription
portPortHandler instance
dxl_idDYNAMIXEL ID
addressAddress on the control table of DYNAMIXEL
  • Detailed Description

    The function calls readTx function to send 4 Byte read intended packet transmission. The communication result and the hardware error are available when the function is terminated. The function is unavailable in protocol 1.0.

read4ByteRx
  • Syntax
read4ByteRx(port, dxl_id)
  • Parameters
ParametersDescription
portPortHandler instance
dxl_idDYNAMIXEL ID
  • Detailed Description

    The function calls readRx function to receive response packet of 4 Byte read intended packet transmission. The communication result and the hardware error are available when the function is terminated. The function is unavailable in protocol 1.0.

read4ByteTxRx
  • Syntax
read4ByteTxRx(port, dxl_id, address)
  • Parameters
ParametersDescription
portPortHandler instance
dxl_idDYNAMIXEL ID
addressAddress on the control table of DYNAMIXEL
  • Detailed Description

    The function calls readTxRx function to read 4 Byte data from DYNAMIXEL. The communication result and the hardware error are available when the function is terminated. The function is unavailable in protocol 1.0.

writeTxOnly
  • Syntax
writeTxOnly(port, dxl_id, address, length, data)
  • Parameters
ParametersDescription
portPortHandler instance
dxl_idDYNAMIXEL ID
addressAddress on the control table of DYNAMIXEL
lengthPacket length
datadata for sending
  • Detailed Description

    The function constructs the transmission packet with write instruction, and starts txPacket. The communication result and the hardware error are available when the function is terminated.

writeTxRx
  • Syntax
writeTxRx(port, dxl_id, address, length, data)
  • Parameters
ParametersDescription
portPortHandler instance
dxl_idDYNAMIXEL ID
addressAddress on the control table of DYNAMIXEL
lengthPacket length
datadata for sending
  • Detailed Description

    The function constructs the transmission packet with write instruction, and starts txRxPacket. The communication result and the hardware error are available when the function is terminated.

write1ByteTxOnly
  • Syntax
write1ByteTxOnly(port, dxl_id, address, data)
  • Parameters
ParametersDescription
portPortHandler instance
dxl_idDYNAMIXEL ID
addressAddress on the control table of DYNAMIXEL
datadata for sending
  • Detailed Description

    The function calls writeTxOnly function to send 1 Byte write intended packet transmission. The communication result and the hardware error are available when the function is terminated.

write1ByteTxRx
  • Syntax
write1ByteTxRx(port, dxl_id, address, data)
  • Parameters
ParametersDescription
portPortHandler instance
dxl_idDYNAMIXEL ID
addressAddress on the control table of DYNAMIXEL
datadata for sending
  • Detailed Description

    The function calls writeTxRx function to send 1 Byte write intended packet transmission (and reception). The communication result and the hardware error are available when the function is terminated.

write2ByteTxOnly
  • Syntax
write2ByteTxOnly(port, dxl_id, address, data)
  • Parameters
ParametersDescription
portPortHandler instance
dxl_idDYNAMIXEL ID
addressAddress on the control table of DYNAMIXEL
datadata for sending
  • Detailed Description

    The function calls writeTxOnly function to send 2 Byte write intended packet transmission. The communication result and the hardware error are available when the function is terminated.

write2ByteTxRx
  • Syntax
write2ByteTxRx(port, dxl_id, address, data)
  • Parameters
ParametersDescription
portPortHandler instance
dxl_idDYNAMIXEL ID
addressAddress on the control table of DYNAMIXEL
datadata for sending
  • Detailed Description

    The function calls writeTxRx function to send 2 Byte write intended packet transmission (and reception). The communication result and the hardware error are available when the function is terminated.

write4ByteTxOnly
  • Syntax
write4ByteTxOnly(port, dxl_id, address, data)
  • Parameters
ParametersDescription
portPortHandler instance
dxl_idDYNAMIXEL ID
addressAddress on the control table of DYNAMIXEL
datadata for sending
  • Detailed Description

    The function calls writeTxOnly function to send 4 Byte write intended packet transmission. The communication result and the hardware error are available when the function is terminated. The function is unavailable in protocol 1.0.

write4ByteTxRx
  • Syntax
write4ByteTxRx(port, dxl_id, address, data)
  • Parameters
ParametersDescription
portPortHandler instance
dxl_idDYNAMIXEL ID
addressAddress on the control table of DYNAMIXEL
datadata for sending
  • Detailed Description

    The function calls writeTxRx function to send 4 Byte write intended packet transmission (and reception). The communication result and the hardware error are available when the function is terminated. The function is unavailable in protocol 1.0.

regWriteTxOnly
  • Syntax
regWriteTxOnly(port, dxl_id, address, length, data)
  • Parameters
ParametersDescription
portPortHandler instance
dxl_idDYNAMIXEL ID
addressAddress on the control table of DYNAMIXEL
lengthPacket length
datadata for sending
  • Detailed Description

    The function intends simultaneous control of more than one DYNAMIXEL. The function writes the data without requesting an action of DYNAMIXEL. The DYNAMIXEL works when the trigger action function is executed. The function needs previous setting of the data to write on the DYNAMIXEL. The communication result and the hardware error are available when the function is terminated.

regWriteTxRx
  • Syntax
regWriteTxRx(port, dxl_id, address, length, data)
  • Parameters
ParametersDescription
portPortHandler instance
dxl_idDYNAMIXEL ID
addressAddress on the control table of DYNAMIXEL
lengthPacket length
datadata for sending
  • Detailed Description

    The function intends simultaneous multiple DYNAMIXEL's control. The function writes the data without requesting an action of DYNAMIXEL. The DYNAMIXEL works when the trigger action function is executed. The function needs previous setting of the data to write on the DYNAMIXEL. The communication result and the hardware error are available when the function is terminated.

syncReadTx
  • Syntax
syndReadTx(port, start_address, data_length, param, param_length)
  • Parameters
ParametersDescription
portPortHandler instance
start_addressAddress on the control table of DYNAMIXEL
data_lengthData length
paramParameter for write
param_lengthParameter length
  • Detailed Description

    The function intends simultanoues multiple DYNAMIXEL's control by reading same length of data from the same address on the DYNAMIXEL control table. The function constructs the transmission packet with sync read instruction, and starts 'txPacket2'. Then the function calls setPacketTimeout function when txPacket succeeds. The communication result and the hardware error are available when the function is terminated. The function is unavailable in protocol 1.0.

syncWriteTxOnly
  • Syntax
syncWriteTxOnly(port, start_address, data_length, param, param_length)
  • Parameters
ParametersDescription
portPortHandler instance
start_addressAddress on the control table of DYNAMIXEL
data_lengthData length
paramParameter for write
param_lengthParameter length
  • Detailed Description

    The function intends simultaneous multiple DYNAMIXEL's control by writing same length of data to the same address on the DYNAMIXEL control table. The function constructs the transmission packet with sync write instruction, and starts txRxPacket. The communication result and the hardware error are available when the function is terminated.

bulkReadTx
  • Syntax
bulkReadTx(port, param, param_length)
  • Parameters
ParametersDescription
portPortHandler instance
paramParameters
param_lengthParameter length
  • Detailed Description

    The function intends simultaneous multiple DYNAMIXEL's control by writing different length of data to the different address on the DYNAMIXEL control table. The function constructs the transmission packet with bulk read instruction, and starts txPacket. Then the function calls setPacketTimeout function when txPacket succeeds. The communication result and the hardware error are available when the function is terminated.

bulkWriteTxOnly
  • Syntax
bulkWriteTxOnly(port, param, param_length)
  • Parameters
ParametersDescription
portPortHandler instance
paramParameters
param_lengthParameter length
  • Detailed Description

    The function intends simultaneous multiple DYNAMIXEL's control by writing different length of data from the different address on the DYNAMIXEL control table. The function constructs the transmission packet with bulk write instruction, and starts TxRxPacket. The communication result and the hardware error are available when the function is terminated. The function is unavailable in protocol 1.0.