mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-31 07:01:35 +08:00
reduce reporting frequency for smartport sensors. reduces CPU load to
approx. 1%
This commit is contained in:
committed by
Lorenz Meier
parent
4f55ae5306
commit
3b9ef1cef5
@@ -252,35 +252,73 @@ static int sPort_telemetry_thread_main(int argc, char *argv[])
|
|||||||
|
|
||||||
if (status < 1) { continue; }
|
if (status < 1) { continue; }
|
||||||
|
|
||||||
|
hrt_abstime now = hrt_absolute_time();
|
||||||
|
|
||||||
newBytes = read(uart, &sbuf[1], 1);
|
newBytes = read(uart, &sbuf[1], 1);
|
||||||
|
|
||||||
// allow a minimum of 500usec before reply
|
// allow a minimum of 500usec before reply
|
||||||
usleep(500);
|
usleep(500);
|
||||||
|
|
||||||
|
static hrt_abstime lastBATV = 0;
|
||||||
|
static hrt_abstime lastCUR = 0;
|
||||||
|
static hrt_abstime lastALT = 0;
|
||||||
|
static hrt_abstime lastSPD = 0;
|
||||||
|
static hrt_abstime lastFUEL = 0;
|
||||||
|
|
||||||
switch (sbuf[1]) {
|
switch (sbuf[1]) {
|
||||||
|
|
||||||
case SMARTPORT_POLL_1:
|
case SMARTPORT_POLL_1:
|
||||||
/* send battery voltage */
|
|
||||||
sPort_send_BATV(uart);
|
/* report BATV at 1Hz */
|
||||||
|
if (now - lastBATV > 1000 * 1000) {
|
||||||
|
lastBATV = now;
|
||||||
|
/* send battery voltage */
|
||||||
|
sPort_send_BATV(uart);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
case SMARTPORT_POLL_2:
|
case SMARTPORT_POLL_2:
|
||||||
/* send battery current */
|
/* report battery current at 5Hz */
|
||||||
sPort_send_CUR(uart);
|
if (now - lastCUR > 200 * 1000) {
|
||||||
|
lastCUR = now;
|
||||||
|
/* send battery current */
|
||||||
|
sPort_send_CUR(uart);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
case SMARTPORT_POLL_3:
|
case SMARTPORT_POLL_3:
|
||||||
/* send altitude */
|
/* report altitude at 5Hz */
|
||||||
sPort_send_ALT(uart);
|
if (now - lastALT > 200 * 1000) {
|
||||||
|
lastALT = now;
|
||||||
|
/* send altitude */
|
||||||
|
sPort_send_ALT(uart);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
case SMARTPORT_POLL_4:
|
case SMARTPORT_POLL_4:
|
||||||
/* send speed */
|
/* report speed at 5Hz */
|
||||||
sPort_send_SPD(uart);
|
if (now - lastSPD > 200 * 1000) {
|
||||||
|
lastSPD = now;
|
||||||
|
/* send speed */
|
||||||
|
sPort_send_SPD(uart);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SMARTPORT_POLL_5:
|
case SMARTPORT_POLL_5:
|
||||||
/* send fuel */
|
/* report fuel at 1Hz */
|
||||||
sPort_send_FUEL(uart);
|
if (now - lastFUEL > 1000 * 1000) {
|
||||||
|
lastFUEL = now;
|
||||||
|
/* send fuel */
|
||||||
|
sPort_send_FUEL(uart);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user