GIU\ZF
Dependencies: MCP23017 WattBob_TextLCD mbed-rtos mbed
Fork of rtos_basic by
Revision 14:8a6c20435523, committed 2018-03-27
- Comitter:
- ihexx
- Date:
- Tue Mar 27 16:11:18 2018 +0000
- Parent:
- 13:ab52f46c98ab
- Child:
- 15:524de2b2ef8e
- Commit message:
- fixed debug framework
Changed in this revision
--- a/main.cpp Tue Mar 27 15:56:27 2018 +0000 +++ b/main.cpp Tue Mar 27 16:11:18 2018 +0000 @@ -12,7 +12,7 @@ float avgSpeed = 0.0f; float odometer = 0.0f; #if DEBUG_MODE - string debugLog = "task,execution_time_ms,lastSleep,drift\n"; + string debugLog = "task,execution_time_ms,lastSleep,drift\n\r"; #endif }
--- a/tasks/sendMail.cpp Tue Mar 27 15:56:27 2018 +0000 +++ b/tasks/sendMail.cpp Tue Mar 27 16:11:18 2018 +0000 @@ -4,25 +4,25 @@ Mail<mail_t, 100> mailBox; } - - namespace enqueueMail{ //Send speed, accelerometer and brake values to a 100 element MAIL queue Thread thread; const float freq = 0.2; //hz //I/O - void runTask(){ + + Timer executionTimer,sleepTimer; executionTimer.reset(); sleepTimer.reset(); const int const_delay = int((1000.0f/freq)+0.5f); int dynamic_delay = const_delay; + int tick = 0; while(1){ - sleepTimer.stop(); + sleepTimer.stop(); executionTimer.start(); int sleepTime = sleepTimer.read_ms(); const int drift = ((sleepTime - dynamic_delay) > 0)? @@ -42,20 +42,26 @@ mailBox.put(mail); //End of Core loop + tick++; executionTimer.stop(); int exec_time = executionTimer.read_ms(); #if DEBUG_MODE - runTimeParams::liveAccess.lock(); - //runTimeParams::debugLog += "Enqueue Mail," + to_string(exec_time) + "," -// + to_string(sleepTime) + "," -// + to_string(drift) + "\n"; - runTimeParams::liveAccess.unlock(); + const int debug_log_interval = int(freq/dequeueMail::freq); + if (!(tick%debug_log_interval)){ + runTimeParams::liveAccess.lock(); + runTimeParams::debugLog += "Enqueue Mail," + to_string(exec_time) + "," + + to_string(sleepTime) + "," + + to_string(drift) + "\n\r"; + runTimeParams::liveAccess.unlock(); + tick = 0; + } #endif executionTimer.reset(); sleepTimer.reset(); sleepTimer.start(); + dynamic_delay = const_delay - (exec_time + drift); Thread::wait(dynamic_delay); }
--- a/tasks/task_group1.cpp Tue Mar 27 15:56:27 2018 +0000 +++ b/tasks/task_group1.cpp Tue Mar 27 16:11:18 2018 +0000 @@ -13,7 +13,7 @@ const int const_delay = int((1000.0f/freq)+0.5f); int dynamic_delay = const_delay; - + int tick = 0; while(true){ sleepTimer.stop(); executionTimer.start(); @@ -28,15 +28,22 @@ display::hotLoop(); + tick++; executionTimer.stop(); int exec_time = executionTimer.read_ms(); #if DEBUG_MODE runTimeParams::liveAccess.lock(); - //runTimeParams::debugLog += "GROUP_1," + to_string(executionTimer.read_ms()) + "," -// + to_string(sleepTimer.read_ms()) + ", \n"; - runTimeParams::odometer = float(sleepTime); - runTimeParams::avgSpeed = float(exec_time); + const int debug_log_interval = int(freq/dequeueMail::freq); + if (!(tick%debug_log_interval)){ + runTimeParams::liveAccess.lock(); + runTimeParams::debugLog += "task_group_1," + to_string(exec_time) + "," + + to_string(sleepTime) + "," + + to_string(drift) + "\n\r"; + runTimeParams::liveAccess.unlock(); + + } + if (tick==debug_log_interval*1) tick=0; runTimeParams::liveAccess.unlock(); #endif