Commit ca608403 authored by Alessandro Rubini's avatar Alessandro Rubini

diag: add a 'LOOP' fsm state

Too many messages are confusing: let's make a state change more
visible than a re-enter of the same state.
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent afa607df
......@@ -16,6 +16,11 @@ void pp_diag_fsm(struct pp_instance *ppi, char *name, int sequence, int plen)
name, plen);
return;
}
if (sequence == STATE_LOOP) {
pp_timed_printf("fsm: %s: reenter in %i ms\n", name,
ppi->next_delay);
return;
}
/* leave has one \n more, so different states are separate */
pp_timed_printf("fsm: LEAVE %s (next: %3i in %i ms)\n\n",
name, ppi->next_state, ppi->next_delay);
......
......@@ -39,22 +39,23 @@ int pp_state_machine(struct pp_instance *ppi, uint8_t *packet, int plen)
/* found: handle this state */
ppi->next_state = state;
ppi->next_delay = 0;
if (pp_diag_verbosity)
if (pp_diag_verbosity && ppi->is_new_state)
pp_diag_fsm(ppi, ip->name, STATE_ENTER, plen);
err = ip->f1(ppi, packet, plen);
if (err)
pp_diag_error(ppi, err);
if (pp_diag_verbosity)
pp_diag_fsm(ppi, ip->name, STATE_LEAVE, 0 /* unused */);
ppi->is_new_state = 0;
/* done: if new state mark it, and enter it now (0 ms) */
if (ppi->state != ppi->next_state) {
ppi->state = ppi->next_state;
ppi->is_new_state = 1;
if (pp_diag_verbosity)
pp_diag_fsm(ppi, ip->name, STATE_LEAVE, 0);
return 0;
}
ppi->is_new_state = 0;
if (pp_diag_verbosity)
pp_diag_fsm(ppi, ip->name, STATE_LOOP, 0);
return ppi->next_delay;
}
/* Unknwon state, can't happen */
......
......@@ -15,6 +15,7 @@
*/
enum {
STATE_ENTER,
STATE_LOOP,
STATE_LEAVE
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment