I try to subscriber 20052.StatusMsg3.uavcan.
#if AP_DRONECAN_HOBBYWING_ESC_SUPPORT
/\*
Hobbywing ESC support. Note that we need additional meta-data as
the status messages do not have an ESC ID in them, so we need a
mapping from node ID
\*/
#define HOBBYWING_MAX_ESC 8
struct {
uint32_t last_GetId_send_ms;
uint8_t thr_chan\[HOBBYWING_MAX_ESC\];
} hobbywing;
void hobbywing_ESC_update();
void SRV_send_esc_hobbywing();
Canard::Publisher<com_hobbywing_esc_RawCommand> esc_hobbywing_raw{canard_iface};
Canard::Publisher<com_hobbywing_esc_GetEscID> esc_hobbywing_GetEscID{canard_iface};
Canard::ObjCallback<AP_DroneCAN, com_hobbywing_esc_GetEscID> esc_hobbywing_GetEscID_cb{this, &AP_DroneCAN::handle_hobbywing_GetEscID};
Canard::Subscriber<com_hobbywing_esc_GetEscID> esc_hobbywing_GetEscID_listener{esc_hobbywing_GetEscID_cb, \_driver_index};
Canard::ObjCallback<AP_DroneCAN, com_hobbywing_esc_StatusMsg1> esc_hobbywing_StatusMSG1_cb{this, &AP_DroneCAN::handle_hobbywing_StatusMsg1};
Canard::Subscriber<com_hobbywing_esc_StatusMsg1> esc_hobbywing_StatusMSG1_listener{esc_hobbywing_StatusMSG1_cb, \_driver_index};
Canard::ObjCallback<AP_DroneCAN, com_hobbywing_esc_StatusMsg2> esc_hobbywing_StatusMSG2_cb{this, &AP_DroneCAN::handle_hobbywing_StatusMsg2};
Canard::Subscriber<com_hobbywing_esc_StatusMsg2> esc_hobbywing_StatusMSG2_listener{esc_hobbywing_StatusMSG2_cb, \_driver_index};
Canard::ObjCallback<AP_DroneCAN, com_hobbywing_esc_StatusMsg3> esc_hobbywing_StatusMSG3_cb{this, &AP_DroneCAN::handle_hobbywing_StatusMsg3};
Canard::Subscriber<com_hobbywing_esc_StatusMsg3> esc_hobbywing_StatusMSG3_listener{esc_hobbywing_StatusMSG3_cb, \_driver_index};
bool hobbywing_find_esc_index(uint8_t node_id, uint8_t &esc_index) const;
void handle_hobbywing_GetEscID(const CanardRxTransfer& transfer, const com_hobbywing_esc_GetEscID& msg);
void handle_hobbywing_StatusMsg1(const CanardRxTransfer& transfer, const com_hobbywing_esc_StatusMsg1& msg);
void handle_hobbywing_StatusMsg2(const CanardRxTransfer& transfer, const com_hobbywing_esc_StatusMsg2& msg);
void handle_hobbywing_StatusMsg3(const CanardRxTransfer& transfer, const com_hobbywing_esc_StatusMsg3& msg);
#endif // AP_DRONECAN_HOBBYWING_ESC_SUPPORT
this is AP_DroneCAN.h hobbywing code. I add msg3 subscriber like msg1 and msg2.
void AP_DroneCAN::handle_hobbywing_StatusMsg3(const CanardRxTransfer& transfer, const com_hobbywing_esc_StatusMsg3& msg)
{
uint8_t esc_index;
static uint32_t ptime;
if (AP_HAL::millis() - ptime > 1000) {
GCS_SEND_TEXT(MAV_SEVERITY_INFO, “1.Sub success”);
ptime = AP_HAL::millis();
}
if (hobbywing_find_esc_index(transfer.source_node_id, esc_index)) {
static uint32_t ptime2;
if (AP_HAL::millis() - ptime2 > 1000) {
GCS_SEND_TEXT(MAV_SEVERITY_INFO, “2.Update, mos:%d, cap:%d, motor:%d”, msg.MOS_T, msg.CAP_T, msg.Motor_T);
ptime2 = AP_HAL::millis();
}
update_temp_detail(esc_index, msg.MOS_T, msg.CAP_T, msg.Motor_T);
}
}
#endif // AP_DRONECAN_HOBBYWING_ESC_SUPPORT
this is handle_hobbywing_StatusMsg3 function, I add gcs print. Then I find no “1…” print when ESC working, but dronecan gui show msg3 is ok.
So, what’s problem?
