How can I modify the state machine logic?
I'm working on this RTOS-based application for a vending machine controller with
C
and a state machine approach that manages various vending machine states as Idle
,CoinInserted
, SelectionMade
& Dispensing
, but
I'm encountering an error message in the console: StateMachine Error: Invalid transition from CoinInserted to Dispensing.
This occurs when a user inserts enough coins to trigger dispensing, but the selection hasn't been confirmed yet.
How can I modify the state machine logic to prevent this invalid transition and ensure a valid sequence of states Idle -> CoinInserted -> SelectionMade -> Dispensing
?2 Replies
I think you would need to show your logic for any opinions
Hi @Marvee Amasi to prevent the invalid transition from CoinInserted to Dispensing when the selection hasn't been made yet, you can modify the state machine logic to introduce an intermediate state between CoinInserted and SelectionMade.
your code for the
VendingMachineState
enum should be