Constructs for wrapping a hardware state machine

Posted by Henry Gomersall on Programmers See other posts from Programmers or by Henry Gomersall
Published on 2012-07-08T22:17:51Z Indexed on 2012/07/09 3:22 UTC
Read the original article Hit count: 332

I am using a piece of hardware with a well defined C API. The hardware is stateful, with the relevant API calls needing to be in the correct order for the hardware to work properly. The API calls themselves will always return, passing back a flag that advises whether the call was successful, or if not, why not. The hardware will not be left in some ill defined state. In effect, the API calls advise indirectly of the current state of the hardware if the state is not correct to perform a given operation. It seems to be a pretty common hardware API style.

My question is this: Is there a well established design pattern for wrapping such a hardware state machine in a high level language, such that consistency is maintained?

My development is in Python. I ideally wish the hardware state machine to be abstracted to a much simpler state machine and wrapped in an object that represents the hardware. I'm not sure what should happen if an attempt is made to create multiple objects representing the same piece of hardware.

I apologies for the slight vagueness, I'm not very knowledgeable in this area and so am fishing for assistance of the description as well!

© Programmers or respective owner

Related posts about design-patterns

Related posts about Hardware