Skip to content

Commit

Permalink
Merge pull request #1321 from bitcraze/krichardsson/locked-log
Browse files Browse the repository at this point in the history
Added locked info to supervisor
  • Loading branch information
krichardsson authored Sep 29, 2023
2 parents cd3f3df + d843555 commit 1d70513
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/modules/interface/supervisor.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,11 @@ bool supervisorCanArm();
* @return false
*/
bool supervisorIsArmed();

/**
* @brief Query if the system is locked (due to a crash)
*
* @return true
* @return false
*/
bool supervisorIsLocked();
8 changes: 8 additions & 0 deletions src/modules/src/supervisor.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ bool supervisorIsArmed() {
return supervisorMem.isArmingActivated || supervisorMem.deprecatedArmParam;
}

bool supervisorIsLocked() {
return supervisorStateLocked == supervisorMem.state;
}

bool supervisorRequestArming(const bool doArm) {
if (doArm == supervisorMem.isArmingActivated) {
return true;
Expand Down Expand Up @@ -305,6 +309,9 @@ static void updateLogData(SupervisorMem_t* this, const supervisorConditionBits_t
if (this->isTumbled) {
this->infoBitfield |= 0x0020;
}
if (supervisorStateLocked == this->state) {
this->infoBitfield |= 0x0040;
}
}

void supervisorUpdate(const sensorData_t *sensors, const setpoint_t* setpoint, stabilizerStep_t stabilizerStep) {
Expand Down Expand Up @@ -440,6 +447,7 @@ LOG_GROUP_START(supervisor)
* Bit 3 = can fly - the Crazyflie is ready to fly
* Bit 4 = is flying - the Crazyflie is flying.
* Bit 5 = is tumbled - the Crazyflie is up side down.
* Bit 6 = is locked - the Crazyflie is in the locked state and must be restarted.
*/
LOG_ADD(LOG_UINT16, info, &supervisorMem.infoBitfield)
LOG_GROUP_STOP(supervisor)
Expand Down

0 comments on commit 1d70513

Please sign in to comment.