diff options
author | Daniel Drake <dsd@cs.manchester.ac.uk> | 2008-02-15 18:09:14 +0000 |
---|---|---|
committer | Daniel Drake <dsd@cs.manchester.ac.uk> | 2008-02-16 12:49:37 +0000 |
commit | 0aaffcee33015163d79320433cfd9d9c5941143a (patch) | |
tree | 893767a7384777e1bdf1a892a1739a65169cba29 /libfprint/drv.c | |
parent | 77b5dab04b1305ba1e65eb7459349f99f36eba73 (diff) |
Allow jumping to arbitrary state in a SSM
This is looking less and less like a simple state machine now, but it's
proving a useful model!
Diffstat (limited to 'libfprint/drv.c')
-rw-r--r-- | libfprint/drv.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/libfprint/drv.c b/libfprint/drv.c index bb92126..f1cc6c5 100644 --- a/libfprint/drv.c +++ b/libfprint/drv.c @@ -297,6 +297,11 @@ void fpi_drvcb_identify_stopped(struct fp_dev *dev) * There is also an implicit error state and an implicit accepting state * (both with implicit edges from every state). * + * You can also jump to any arbitrary state (while marking completion of the + * current state) while the machine is running. In other words there are + * implicit edges linking one state to every other state. OK, we're stretching + * the "state machine" description at this point. + * * To create a ssm, you pass a state handler function and the total number of * states (4 in the above example). * @@ -377,7 +382,7 @@ void fpi_ssm_mark_completed(struct fpi_ssm *machine) /* Mark a ssm as aborted with error. */ void fpi_ssm_mark_aborted(struct fpi_ssm *machine, int error) { - fp_dbg("error %d", error); + fp_dbg("error %d from state %d", error, machine->cur_state); BUG_ON(error == 0); machine->error = error; fpi_ssm_mark_completed(machine); @@ -395,3 +400,11 @@ void fpi_ssm_next_state(struct fpi_ssm *machine) } } +void fpi_ssm_jump_to_state(struct fpi_ssm *machine, int state) +{ + BUG_ON(machine->completed); + BUG_ON(state >= machine->nr_states); + machine->cur_state = state; + __ssm_call_handler(machine); +} + |