User Tools

Site Tools


coding_strategy_standard_for_state_machines

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
coding_strategy_standard_for_state_machines [2019/12/03 15:54]
hutch [Debugging Software State Machines]
coding_strategy_standard_for_state_machines [2019/12/03 15:58] (current)
hutch
Line 106: Line 106:
 The snippet of code shown below would be placed in the same file as the clock state-machine shown above. Call this function at the top of the tick function. The function shown below will print out state changes as they occur. What makes this code particularly helpful is that it only prints out a message when currentState changes value. This eliminates a lot of extraneous printing that often hides what you are trying to see. It keeps track of the previous value of currentState by using a static variable. Try using this function, I suspect that you will find it to be quite useful. The snippet of code shown below would be placed in the same file as the clock state-machine shown above. Call this function at the top of the tick function. The function shown below will print out state changes as they occur. What makes this code particularly helpful is that it only prints out a message when currentState changes value. This eliminates a lot of extraneous printing that often hides what you are trying to see. It keeps track of the previous value of currentState by using a static variable. Try using this function, I suspect that you will find it to be quite useful.
  
-Place this function before the tick() function in the file to keep the compiler happy. Also make sure to ''​include <​stdio.h>''​.+Place this function before the tick() function in the file to keep the compiler happy. Also make sure to ''​#include <​stdio.h>''​.
 <code C> <code C>
 // All printed messages for states are provided here. // All printed messages for states are provided here.
coding_strategy_standard_for_state_machines.txt ยท Last modified: 2019/12/03 15:58 by hutch