Skip to content

Commit

Permalink
Formalize the process of soft-fails in CP state machine
Browse files Browse the repository at this point in the history
  • Loading branch information
sidcha committed Nov 29, 2019
1 parent c86f084 commit a78e0b8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/osdp_cp.c
Original file line number Diff line number Diff line change
Expand Up @@ -609,15 +609,18 @@ int cp_cmd_dispatcher(struct osdp_pd *p, int cmd)

int cp_state_update(struct osdp_pd *pd)
{
int phy_state;
int phy_state, soft_fail;

phy_state = cp_phy_state_update(pd);
if (phy_state == 1 || /* commands are being executed */
phy_state == 2) /* in-between commands */
return -1 * phy_state;

/* Certain states can fail without causing PD offline */
soft_fail = (pd->state == CP_STATE_SC_CHLNG);

/* phy state error -- cleanup */
if (phy_state < 0 && (pd->state != CP_STATE_SC_CHLNG)) {
if (phy_state < 0 && soft_fail == 0) {
cp_set_offline(pd);
}

Expand Down
2 changes: 1 addition & 1 deletion test/test-mixed-fsm.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ int test_mixed_fsm_setup(struct test *t)
osdp_cp_teardown((osdp_cp_t *) test_data.cp_ctx);
return -1;
}
osdp_set_log_level(LOG_DEBUG);
// osdp_set_log_level(LOG_DEBUG);
t->mock_data = (void *)&test_data;
return 0;
}
Expand Down

0 comments on commit a78e0b8

Please sign in to comment.