Skip to content

Commit 796881b

Browse files
committed
AP_RCTelemetry: add missing scheduler table entry and add checks for correct number of entries
1 parent eaf20db commit 796881b

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

libraries/AP_RCTelemetry/AP_CRSF_Telem.cpp

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -89,21 +89,27 @@ void AP_CRSF_Telem::setup_wfq_scheduler(void)
8989
// priority[i] = 1/_scheduler.packet_weight[i]
9090
// rate[i] = LinkRate * ( priority[i] / (sum(priority[1-n])) )
9191

92+
uint8_t sensors = 0;
93+
#define ADD_SENSOR(num, t1, t2) add_scheduler_entry(t1, t2); sensors++
9294
// CRSF telemetry rate is 150Hz (4ms) max, so these rates must fit
93-
add_scheduler_entry(50, 100); // heartbeat 10Hz
94-
add_scheduler_entry(5, 20); // parameters 50Hz (generally not active unless requested by the TX)
95-
add_scheduler_entry(50, 200); // baro_vario 5Hz
96-
add_scheduler_entry(50, 120); // Attitude and compass 8Hz
97-
add_scheduler_entry(200, 1000); // VTX parameters 1Hz
98-
add_scheduler_entry(1300, 500); // battery 2Hz
99-
add_scheduler_entry(550, 280); // GPS 3Hz
100-
add_scheduler_entry(550, 500); // flight mode 2Hz
101-
add_scheduler_entry(5000, 100); // passthrough max 10Hz
102-
add_scheduler_entry(5000, 500); // status text max 2Hz
103-
add_scheduler_entry(5, 20); // command 50Hz (generally not active unless requested by the TX)
104-
add_scheduler_entry(5, 500); // version ping 2Hz (only active at startup)
105-
add_scheduler_entry(5, 100); // device ping 10Hz (only active during TX loss, also see CRSF_RX_TIMEOUT)
95+
ADD_SENSOR(HEARTBEAT, 50, 100); // heartbeat 10Hz
96+
ADD_SENSOR(PARAMETERS, 5, 20); // parameters 50Hz (generally not active unless requested by the TX)
97+
ADD_SENSOR(BARO_VARIO, 50, 200); // baro_vario 5Hz
98+
ADD_SENSOR(VARIO, 50, 200); // vario 5Hz
99+
ADD_SENSOR(ATTITUDE, 50, 120); // Attitude and compass 8Hz
100+
ADD_SENSOR(VTX_PARAMETERS, 200, 1000); // VTX parameters 1Hz
101+
ADD_SENSOR(BATTERY, 1300, 500); // battery 2Hz
102+
ADD_SENSOR(GPS, 550, 280); // GPS 3Hz
103+
ADD_SENSOR(FLIGHT_MODE, 550, 500); // flight mode 2Hz
104+
ADD_SENSOR(PASSTHROUGH, 5000, 100); // passthrough max 10Hz
105+
ADD_SENSOR(STATUS_TEXT, 5000, 500); // status text max 2Hz
106+
ADD_SENSOR(GENERAL_COMMAND, 5, 20); // command 50Hz (generally not active unless requested by the TX)
107+
ADD_SENSOR(VERSION_PING, 5, 500); // version ping 2Hz (only active at startup)
108+
ADD_SENSOR(DEVICE_PING, 5, 100); // device ping 10Hz (only active during TX loss, also see CRSF_RX_TIMEOUT)
106109
disable_scheduler_entry(DEVICE_PING);
110+
if (sensors != NUM_SENSORS) {
111+
AP_HAL::panic("CRSF: not all sensors add to scheduler table\n");
112+
}
107113
}
108114

109115
void AP_CRSF_Telem::setup_custom_telemetry()

0 commit comments

Comments
 (0)