PWM out: provide running state

Important to know if the app is running.
This commit is contained in:
Lorenz Meier 2021-03-17 17:31:12 +01:00
parent 33c5f4210a
commit 9490c64ad4
1 changed files with 9 additions and 0 deletions

View File

@ -2258,15 +2258,24 @@ extern "C" __EXPORT int pwm_out_main(int argc, char *argv[])
} else if (strcmp(argv[1], "status") == 0) {
if (PWMOut::trylock_module()) {
unsigned count = 0;
for (int i = 0; i < PWM_OUT_MAX_INSTANCES; i++) {
if (_objects[i].load()) {
PX4_INFO_RAW("\n");
_objects[i].load()->print_status();
count++;
}
}
PWMOut::unlock_module();
if (count == 0) {
PX4_INFO("not running");
return 1;
}
} else {
PX4_WARN("module locked, try again later");
}