Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions python/src/dynamixel_sdk/protocol2_packet_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,10 @@ def readRx(self, port, dxl_id, length):

data.extend(rxpacket[PKT_PARAMETER0 + 1: PKT_PARAMETER0 + 1 + length])

if len(data) != length:
result = COMM_RX_CORRUPT
return data, result, error
Comment on lines +552 to +554
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This data validation logic is also present in the readTxRx method (lines 626-628). To improve maintainability and avoid code duplication, consider extracting this logic into a private helper method. This would centralize the data extraction and validation, making the code easier to read and maintain in the future.


return data, result, error

def fastSyncReadRx(self, port, dxl_id, length):
Expand Down Expand Up @@ -619,6 +623,10 @@ def readTxRx(self, port, dxl_id, address, length):

data.extend(rxpacket[PKT_PARAMETER0 + 1: PKT_PARAMETER0 + 1 + length])

if len(data) != length:
result = COMM_RX_CORRUPT
return data, result, error

return data, result, error

def read1ByteTx(self, port, dxl_id, address):
Expand Down