I have the following requirement to design behavior of a software component for logging sensor, which writes data to SD card a:
Datalogging sensor can write data to a FAT16-formatted SD card that is inserted into the card reader slot. When the board is booted and a valid card is detected, a new file is created and data from all messages on the can bus is written into this file. As long as the card is valid and there is error message present in can bus, this sensor will log the error to sd car. There is no mechanism to specifically close the log file. Just remove the card or power down the board. There is a bootloader in the board which checks whether a sd card is valid or not .
I have come up with the following state chart:
What I am not sure is whether the new file creation command is being sent by the bootloader or the logging sensor itself invokes the new file creation command when it finds the valid sd card signal from bootloader. If later is the case, what is the way to model it in this state machine? Also, I am not sure how to go to idle state when power down the board. I am also not sure whether my current model is correct or not.
The basis of designing the state machine comes from the following sequence diagram: