0

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 the SD card is valid or invalid and sends signal (ValidSDCard and InvalidSDCard) to datalogging sensor accordingly.

I have come up with the following state chart: enter image description here

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.

0

I am also not sure whether my current model is correct or not.

In the basis, your model looks fine. The only transitions I have my doubts about are the timeouts (after(...)).

I would expect that the WriteData state transitions to WaitForDataLogging after the writing has finished, regardless of how long that takes. In a state diagram, that would be shown as a transition without a trigger.

Also, the transition from Failure to Idle puzzles me a bit, but you might have a good reason for having that transition in.

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?

One way to model that the file gets created when the logging sensor detects a valid SD card to to have it as an additional entry action of the state Operational.

Also, I am not sure how to go to idle state when power down the board.

If you are modelling the software, then a power-down means that the state machine ceases to exist. On the next power-up, the state machine is created again and starts with the initial state.

If you are modelling the entire system, you could put your current state machine in a super state "PoweredOn" and create a new state "PoweredOff" with power-down and power-up transitions between them.

7
  • Thanks for the reply. Currently, transition without trigger is not allowed by the rule set by the tool I am using for a specific purpose which I can't reveal here. For the sake of simplicity, I have removed the create new file from my use case. Oct 7 at 11:14
  • For the timeout event, I designed it in a way that every 50 micro second the sensor will check for error data in can bus, if it finds one, logs it immediately. That's why I put the timeout event to go back to wait mode. Oct 7 at 11:14
  • In case of SD card failure**(for example sd card removed during operation or file system damaged), if there is no valid sd card detected again, the logging sensor will go to idle mode. That's what I have tried to come up with. In case of **power on, I am not sure which states will be inside. For example, failure state will not be inside the power on state, and I am also not sure about whether the idle state will be inside the power on state or not. Oct 7 at 11:15
  • If your tooling has a restriction that doesn't allow you to use an implicit 'state done' transition, then it might be better to use an explicit Done trigger. I would prefer that over a timeout. Oct 7 at 11:31
  • Regarding your SD card failure, from that requirement is looks like the InvalidSDCard event should trigger a transition to the Idle state and you don't need the Failure state. Oct 7 at 11:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.