/******************************************************************************* * TzCtrl * * Task for receiving commands from Tracealyzer and for recorder diagnostics. * ******************************************************************************/ static portTASK_FUNCTION( TzCtrl, pvParameters ) { (void)pvParameters; TracealyzerCommandType msg; int bytes = 0; while (1) { do { /* Listen for new commands */ bytes = 0; TRC_STREAM_PORT_READ_DATA(&msg, sizeof(TracealyzerCommandType), &bytes); if (bytes == sizeof(TracealyzerCommandType)) { if (prvIsValidCommand(&msg)) { prvProcessCommand(&msg); /* Start or Stop currently... */ } } /* Send periodic data */ bytes = 0; TRC_STREAM_PORT_PERIODIC_SEND_DATA(&bytes); /* If there was data sent (bytes != 0), immediately loop around and do all this again. Otherwise, step out of this loop and sleep for a while. */ } while (bytes != 0); prvCheckRecorderStatus(); vTaskDelay(TRC_CFG_CTRL_TASK_DELAY); /* 10ms */ } }
/******************************************************************************* * TzCtrl * * Task for receiving commands from Tracealyzer and for recorder diagnostics. * ******************************************************************************/ static portTASK_FUNCTION( TzCtrl, pvParameters ) { TracealyzerCommandType msg; int bytes = 0; while (1) { bytes = 0; TRC_STREAM_PORT_READ_DATA(&msg, sizeof(TracealyzerCommandType), &bytes); if (bytes != 0) { if (bytes == sizeof(TracealyzerCommandType)) { if (isValidCommand(&msg)) { processCommand(&msg); /* Start or Stop currently... */ } } } do { bytes = 0; TRC_STREAM_PORT_PERIODIC_SEND_DATA(&bytes); } while (bytes != 0); CheckRecorderStatus(); vTaskDelay(TRC_CTRL_TASK_DELAY); /* 10ms */ } }