Add CRC docstring

This commit is contained in:
Simon Alibert 2025-03-22 00:50:01 +01:00
parent 4fe1880887
commit fc4a95f187
1 changed files with 11 additions and 0 deletions

View File

@ -149,6 +149,17 @@ class MockDynamixelPacketv2(abc.ABC):
@staticmethod @staticmethod
def _add_crc(packet: list[int]) -> list[int]: def _add_crc(packet: list[int]) -> list[int]:
"""Computes and add CRC to the packet.
https://emanual.robotis.com/docs/en/dxl/crc/
https://en.wikipedia.org/wiki/Cyclic_redundancy_check
Args:
packet (list[int]): The raw packet without CRC (but with placeholders for it).
Returns:
list[int]: The raw packet with a valid CRC.
"""
crc = 0 crc = 0
for j in range(len(packet) - 2): for j in range(len(packet) - 2):
i = ((crc >> 8) ^ packet[j]) & 0xFF i = ((crc >> 8) ^ packet[j]) & 0xFF