Skip to content

Commit

Permalink
AP_RobotisServo: Send register write values as little-endian
Browse files Browse the repository at this point in the history
  • Loading branch information
nexton-winjeel authored and peterbarker committed Sep 27, 2024
1 parent 9253d6f commit eb4224b
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions libraries/AP_RobotisServo/AP_RobotisServo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#if AP_ROBOTISSERVO_ENABLED

#include <AP_HAL/AP_HAL.h>
#include <AP_HAL/utility/sparse-endian.h>
#include <AP_Math/AP_Math.h>
#include <AP_SerialManager/AP_SerialManager.h>
#include <SRV_Channel/SRV_Channel.h>
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit eb4224b

Please sign in to comment.