Edit on GitHub

API Reference

Python

Python PacketHandler

Base functions for packet construction.

   
packetHandler Initializes members of packet data pointer struct
printTxRxResult Shows communication result
printRxPacketError Shows hardware error
getLastTxRxResult Gets last communication result
getLastRxPacketError Gets last hardware error
setDataWrite Gets last communication result
getDataRead Gets last hardware error
txPacket Transmits the packet
rxPacket Receives the packet
txRxPacket Transmits and receives the packet
ping ping a Dynamixel
pingGetModelNum Ping a Dynamixel and get its model number
broadcastPing ping all connected Dynamixels
getBroadcastPingResult Get IDs of Dynamixels responded by BroadcastPing2
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
printTxRxResult
   
protocol_version Protocol version
result Communication result
printRxPacketError
   
protocol_version Protocol version
error Hardware error
getLastTxRxResult
   
port_num Port number
protocol_version Protocol version
getLastRxPacketError
   
port_num Port number
protocol_version Protocol version
setDataWrite
   
port_num Port number
protocol_version Protocol version
data_length Data length
data_pos Targeted position of array element
data Data
getDataRead
   
port_num Port number
protocol_version Protocol version
data_length Data length
data_pos Targeted position of array element
txPacket
   
port_num Port_num
protocol_version Protocol version
rxPacket
   
port_num Port number
protocol_version Protocol version
txRxPacket
- Parameters

| | |
| ------------- | ------------- |
|port_num	|Port number|
|protocol_version | Protocol version |

- Detailed Description

   This function calls either `txRxPacket1` or `txRxPacket2` function depending on the `protocol_version`. 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
void ping (int port_num, int protocol_version, int id)

   
port_num Port number
protocol_version Protocol version
id Dynamixel ID
pingGetModelNum
- Parameters

| | |
| ------------- | ------------- |
|port_num	|Port number|
|protocol_version | Protocol version |
|id	|Dynamixel ID|

- Detailed Description

   This function calls either `pingGetModelNum1` or `pingGetModelNum2` function depending on the `protocol_version`. The function constructs the transmission packet for ping, and stats `txRxPacket`. Then, the function tries to get the model number of the Dynamixel by `readTxRx` function. When it succeeds to receive the packet, it returns the model number. The communication result and the hardware error are available when the function is terminated.


##### broadcastPing
- Syntax
``` python
void broadcastPing(int port_num, int protocol_version)

   
port_num Port number
protocol_version Protocol version
getBroadcastPingResult
- Parameters

| | |
| ------------- | ------------- |
|port_num	|Port number|
|protocol_version | Protocol version |
|id | Dynamixel ID |

- Detailed Description

   This function calls either `getBroadcastPingResult1` or `getBroadcastPingResult2` function depending on the `protocol_version`. The function returns whether #`id` Dynamixel responded by `broadcastPing` function. The function is unavailable in protocol 1.0.


##### action
- Syntax
``` python
void action(int port_num, int protocol_version, int id)
   
port_num Port number
protocol_version Protocol version
id Dynamixel ID
reboot
   
port_num Port number
protocol_version Protocol version
id Dynamixel ID
factoryReset
- Parameters

| | |
| ------------- | ------------- |
|port_num	|Port number|
|protocol_version | Protocol version |
|id	|Dynamixel ID|
|option |Reset option|

- Detailed Description

   This function calls either `factoryReset1` or `factoryReset2` function depending on the `protocol_version`. 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
void readTx(int port_num, int protocol_version, int id, int address, int length)

   
port_num Port number
protocol_version Protocol version
id Dynamixel ID
address Address on the control table of Dynamixel
length Packet length
readRx
   
port_num Port number
protocol_version Protocol version
length Packet length
readTxRx
   
port_num Port number
protocol_version Protocol version
id Dynamixel ID
address Address on the control table of Dynamixel
length Packet length
read1ByteTx
   
port_num Port number
protocol_version Protocol version
id Dynamixel ID
address Address on the control table of Dynamixel
read1ByteRx
   
port_num Port number
protocol_version Protocol version
read1ByteTxRx
   
port_num Port number
protocol_version Protocol version
id Dynamixel ID
address Address on the control table of Dynamixel
read2ByteTx
   
port_num Port number
protocol_version Protocol version
id Dynamixel ID
address Address on the control table of Dynamixel
read2ByteRx
   
port_num Port number
protocol_version Protocol version
read2ByteTxRx
   
port_num Port number
protocol_version Protocol version
id Dynamixel ID
address Address on the control table of Dynamixel
read4ByteTx
   
port_num Port number
protocol_version Protocol version
id Dynamixel ID
address Address on the control table of Dynamixel
read4ByteRx
   
port_num Port number
protocol_version Protocol version
read4ByteTxRx
   
port_num Port number
protocol_version Protocol version
id Dynamixel ID
address Address on the control table of Dynamixel
writeTxOnly
   
port_num Port number
protocol_version Protocol version
id Dynamixel ID
address Address on the control table of Dynamixel
length Packet length
writeTxRx
   
port_num Port number
protocol_version Protocol version
id Dynamixel ID
address Address on the control table of Dynamixel
length Packet length
write1ByteTxOnly
   
port_num Port number
protocol_version Protocol version
id Dynamixel ID
address Address on the control table of Dynamixel
data Data for write
write1ByteTxRx
   
port_num Port number
protocol_version Protocol version
id Dynamixel ID
address Address on the control table of Dynamixel
data Data for write
write2ByteTxOnly
   
port_num Port number
protocol_version Protocol version
id Dynamixel ID
address Address on the control table of Dynamixel
data Data for write
write2ByteTxRx
   
port_num Port number
protocol_version Protocol version
id Dynamixel ID
address Address on the control table of Dynamixel
data Data for write
write4ByteTxOnly
   
port_num Port number
protocol_version Protocol version
id Dynamixel ID
address Address on the control table of Dynamixel
data Data for write
write4ByteTxRx
   
port_num Port number
protocol_version Protocol version
id Dynamixel ID
address Address on the control table of Dynamixel
regWriteTxOnly
   
port_num Port number
protocol_version Protocol version
id Dynamixel ID
address Address on the control table of Dynamixel
length Packet length
regWriteTxRx
   
port_num Port number
protocol_version Protocol version
id Dynamixel ID
address Address on the control table of Dynamixel
length Packet length
syncReadTx
   
port_num Port number
protocol_version Protocol version
address Address on the control table of Dynamixel
data_length Data length
param_length Parameter length
syncWriteTxOnly
   
port_num Port number
protocol_version Protocol version
start_address Address on the control table of Dynamixel
data_length Data length
param_length Parameter length
bulkReadTx
   
port_num Port number
protocol_version Protocol version
param_length Parameter length
bulkWriteTxOnly
   
port_num Port number
protocol_version Protocol version
param_length Parameter length