Edit on GitHub

API Reference

Python

Python PacketHandler

Base functions for packet construction.

Methods Description
packetHandler Initializes members of packet data pointer struct
getTxRxResult Gets communication result
getRxPacketError Gets hardware error
txPacket Transmits the packet
rxPacket Receives the packet
txRxPacket Transmits and receives the packet
ping ping a Dynamixel
broadcastPing ping all connected Dynamixels
action Commands ‘Run’ the Regwritten
regWrite Writes the packets and wait for the ‘Action’ command
reboot Reboots Dynamixel
factoryReset Resets all Dynamixel settings
readTx Transmits N byte read instruction packet
readRx Receives N byte read status packet
readTxRx Transmits and receives N byte packet
read1ByteTx Transmits 1 byte read instruction packet
read1ByteRx Receives 1 byte read status packet
read1ByteTxRx Transmits and receives 1 byte packet
read2ByteTx Transmits 2 byte read instruction packet
read2ByteRx Receives 2 byte read status packet
read2ByteTxRx Transmits and receives 2 byte packet
read4ByteTx Transmits 4 byte read instruction packet
read4ByteRx Receives 4 byte read status packet
read4ByteTxRx Transmits and receives 4 byte packet
writeTxOnly Transmits N byte write instruction packet
writeTxRx Transmits and receives N byte packet
write1ByteTxOnly Transmits 1 byte write instruction packet
write1ByteTxRx Transmits and receives 1 byte packet
write2ByteTxOnly Transmits 2 byte write instruction packet
write2ByteTxRx Transmits and receives 2 byte packet
write4ByteTxOnly Transmits 4 byte write instruction packet
write4ByteTxRx Transmits and receives 4 byte packet
regWriteTxOnly Transmits register write instruction packet
regWriteTxRx Transmits and receives register write packet
syncReadTx Transmits N byte sync read Instruction packet
syncWriteTxOnly Transmits N byte sync write Instruction packet
bulkReadTx Transmits N byte bulk read Instruction packet
bulkWriteTxOnly Transmits N byte bulk write Instruction packet

Method References

packetHandler
getTxRxResult
Parameters Description
result Communication result
getRxPacketError
Parameters Description
error Hardware error
txPacket
Parameters Description
port PortHandler instance
txpacket packet byte for sending
rxPacket
Parameters Description
port PortHandler instance
txRxPacket
- Parameters

| Parameters       | Description                               |
|:-----------------|:------------------------------------------|
| port             | PortHandler instance                      |
| txpacket         | packet 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
``` python
ping(port, dxl_id)

Parameters Description
port PortHandler instance
dxl_id Dynamixel ID
broadcastPing
- Parameters

| Parameters       | Description                               |
|:-----------------|:------------------------------------------|
| port             | PortHandler instance                      |
| dxl_id           | Dynamixel 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
``` python
action(port, dxl_id)
Parameters Description
port PortHandler instance
dxl_id Dynamixel ID
reboot
Parameters Description
port PortHandler instance
dxl_id Dynamixel ID
factoryReset
- Parameters

| Parameters       | Description                               |
|:-----------------|:------------------------------------------|
| port             | PortHandler instance                      |
| dxl_id           | Dynamixel ID                              |
| option           | Reset 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
``` python
readTx(port, dxl_id, address, length)

Parameters Description
port PortHandler instance
dxl_id Dynamixel ID
address Address on the control table of Dynamixel
length Packet length
readRx
Parameters Description
port PortHandler instance
dxl_id Dynamixel ID
length Packet length
readTxRx
Parameters Description
port PortHandler instance
dxl_id Dynamixel ID
address Address on the control table of Dynamixel
length Packet length
read1ByteTx
Parameters Description
port PortHandler instance
dxl_id Dynamixel ID
address Address on the control table of Dynamixel
read1ByteRx
Parameters Description
port PortHandler instance
dxl_id Dynamixel ID
read1ByteTxRx
Parameters Description
port PortHandler instance
dxl_id Dynamixel ID
address Address on the control table of Dynamixel
read2ByteTx
Parameters Description
port PortHandler instance
dxl_id Dynamixel ID
address Address on the control table of Dynamixel
read2ByteRx
Parameters Description
port PortHandler instance
dxl_id Dynamixel ID
read2ByteTxRx
Parameters Description
port PortHandler instance
dxl_id Dynamixel ID
address Address on the control table of Dynamixel
read4ByteTx
Parameters Description
port PortHandler instance
dxl_id Dynamixel ID
address Address on the control table of Dynamixel
read4ByteRx
Parameters Description
port PortHandler instance
dxl_id Dynamixel ID
read4ByteTxRx
Parameters Description
port PortHandler instance
dxl_id Dynamixel ID
address Address on the control table of Dynamixel
writeTxOnly
Parameters Description
port PortHandler instance
dxl_id Dynamixel ID
address Address on the control table of Dynamixel
length Packet length
data data for sending
writeTxRx
Parameters Description
port PortHandler instance
dxl_id Dynamixel ID
address Address on the control table of Dynamixel
length Packet length
data data for sending
write1ByteTxOnly
Parameters Description
port PortHandler instance
dxl_id Dynamixel ID
address Address on the control table of Dynamixel
data data for sending
write1ByteTxRx
Parameters Description
port PortHandler instance
dxl_id Dynamixel ID
address Address on the control table of Dynamixel
data data for sending
write2ByteTxOnly
Parameters Description
port PortHandler instance
dxl_id Dynamixel ID
address Address on the control table of Dynamixel
data data for sending
write2ByteTxRx
Parameters Description
port PortHandler instance
dxl_id Dynamixel ID
address Address on the control table of Dynamixel
data data for sending
write4ByteTxOnly
Parameters Description
port PortHandler instance
dxl_id Dynamixel ID
address Address on the control table of Dynamixel
data data for sending
write4ByteTxRx
Parameters Description
port PortHandler instance
dxl_id Dynamixel ID
address Address on the control table of Dynamixel
data data for sending
regWriteTxOnly
Parameters Description
port PortHandler instance
dxl_id Dynamixel ID
address Address on the control table of Dynamixel
length Packet length
data data for sending
regWriteTxRx
Parameters Description
port PortHandler instance
dxl_id Dynamixel ID
address Address on the control table of Dynamixel
length Packet length
data data for sending
syncReadTx
Parameters Description
port PortHandler instance
start_address Address on the control table of Dynamixel
data_length Data length
param Parameter for write
param_length Parameter length
syncWriteTxOnly
Parameters Description
port PortHandler instance
start_address Address on the control table of Dynamixel
data_length Data length
param Parameter for write
param_length Parameter length
bulkReadTx
Parameters Description
port PortHandler instance
param Parameters
param_length Parameter length
bulkWriteTxOnly
Parameters Description
port PortHandler instance
param Parameters
param_length Parameter length