From eb4224b818fa7a8c0fbd241d11c7aa6d95f414ca Mon Sep 17 00:00:00 2001 From: Nick Exton Date: Fri, 5 May 2023 16:23:13 +1000 Subject: [PATCH] AP_RobotisServo: Send register write values as little-endian --- libraries/AP_RobotisServo/AP_RobotisServo.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libraries/AP_RobotisServo/AP_RobotisServo.cpp b/libraries/AP_RobotisServo/AP_RobotisServo.cpp index 5261b1615db71..b234c1409c2de 100644 --- a/libraries/AP_RobotisServo/AP_RobotisServo.cpp +++ b/libraries/AP_RobotisServo/AP_RobotisServo.cpp @@ -39,6 +39,7 @@ #if AP_ROBOTISSERVO_ENABLED #include +#include #include #include #include @@ -268,6 +269,9 @@ void AP_RobotisServo::send_command(uint8_t id, uint16_t reg, uint32_t value, uin txpacket[PKT_INSTRUCTION] = INST_WRITE; txpacket[PKT_INSTRUCTION+1] = DXL_LOBYTE(reg); txpacket[PKT_INSTRUCTION+2] = DXL_HIBYTE(reg); + + // Register values are transmitted as little-endian. + value = htole32(value); memcpy(&txpacket[PKT_INSTRUCTION+3], &value, MIN(len,4)); send_packet(txpacket);