vedderb / bldc

The VESC motor control firmware
2.18k stars 1.35k forks source link

Bug in release 6.02, in COMM_GET_IMU_DATA command handler, controller_id is never sent #721

Open sentient-cloud opened 5 months ago

sentient-cloud commented 5 months ago

Here

        if (mask & ((uint32_t)1 << 16)) {
            uint8_t current_controller_id = app_get_configuration()->controller_id;
#ifdef HW_HAS_DUAL_MOTORS
            if (mc_interface_get_motor_thread() == 2) {
                current_controller_id = utils_second_motor_id();
            }
#endif
            send_buffer[ind++] = current_controller_id;
        }

A uint16_t is read from payload into mask, which is a uint32_t itself. The upper 16 bits always be zero which means this check always fails and controller_id is never sent no matter what the received mask is.

This appears to be fixed in the master branch by always sending the field instead, but anyone running the 6.02 firmware will never receive the controller_id value. It might be worth adding a note somewhere about this behavior.