Instrumentation for Testing and Debugging : Debug Options: Trace State Transitions (reportState function) : Debug Options: Trace State Transition (reportState function)

Debug Options: Trace State Transition (reportState function)

The debug option inserts calls to the "reportState" functions. The “reportState” functions are placed in a file p_state.c and are called according to the defined “Debug Level”:

Debug Level1
The reportState functions are called when a Task enters a stable state mode.
Debug Level2:
The reportState functions are called after each step in the statecharts.
For example, consider the following file extract from P_STATE.C:

cgReportState(unsigned char whichChart, unsigned char*

baseAddress)

{

if(whichChart == 1){

OSPrintf("Statechart %s ", "INIT_MODE_SC");

OSPrintf("In State: ");

if ((((*(StateInfo_INIT_MODE_SC*)baseAddress)) & 0)

== 0) {

OSPrintf("%s", "Chart_INIT_MODE_SC");

OSPrintf(".");

if ((((*(StateInfo_INIT_MODE_SC*)baseAddress)) &

3) == 3) {

OSPrintf("%s", "DefaultOf_Chart_INIT_MODE_SC");

}

else if ((((*(StateInfo_INIT_MODE_SC*)baseAddress))

& 3) == 2) {

OSPrintf("%s", "VOLT_OUT_OF_RANGEst3");

}

else if ((((*(StateInfo_INIT_MODE_SC*)baseAddress))

& 3) == 1) {

OSPrintf("%s", "STATE_15");

OSPrintf(".");

 

 

 

Note: OSPrintf is used only in OSEK applications, and outputs to the stdout, which can be redirected. Redefining the OSPrintf function can allow the debug info to be directed anywhere. For Non-OSEK applications, printf is used.