ROVER - Compass application is also being timing traced now.

Signed-off-by: Mustafa Ozcelikors <mozcelikors@gmail.com>
diff --git a/rover/src/RaspberryTest.cpp b/rover/src/RaspberryTest.cpp
index 9c6bd64..36a34da 100644
--- a/rover/src/RaspberryTest.cpp
+++ b/rover/src/RaspberryTest.cpp
@@ -48,6 +48,9 @@
 
 using namespace std;
 
+timing_interface compass_task_ti;
+pthread_mutex_t compass_task_ti_l;
+
 timing_interface temperature_task_ti;
 pthread_mutex_t temperature_task_ti_l;
 
diff --git a/rover/src/interfaces.h b/rover/src/interfaces.h
index 4c708ea..1f87a49 100644
--- a/rover/src/interfaces.h
+++ b/rover/src/interfaces.h
@@ -42,6 +42,9 @@
    double prev_slack_time;
 } timing_interface;
 
+extern timing_interface compass_task_ti;
+extern pthread_mutex_t compass_task_ti_l;
+
 extern timing_interface temperature_task_ti;
 extern pthread_mutex_t temperature_task_ti_l;
 
diff --git a/rover/src/tasks/compass_sensor_task.cpp b/rover/src/tasks/compass_sensor_task.cpp
index a932c64..280448a 100644
--- a/rover/src/tasks/compass_sensor_task.cpp
+++ b/rover/src/tasks/compass_sensor_task.cpp
@@ -13,7 +13,7 @@
  *     <david.schmelter@iem.fraunhofer.de>
  *
  * Contributors:
- * 		Mustafa Ozcelikors <mozcelikors@gmail.com> Calibration via web-page
+ * 		Mustafa Ozcelikors <mozcelikors@gmail.com> Calibration via web-page, changes regarding schedulability
  *
  * Update History:
  *    22.03.2017 - initial revision
@@ -120,14 +120,24 @@
 	return 1;
 }
 
-void *CompassSensor_Task(void * arg) {
+void *CompassSensor_Task(void * arg)
+{
+	timing compass_task_tmr;
 	char local_command = 'f';
 
 	CollectThreadName("CompassSensor_Task");
 
+	compass_task_tmr.setTaskID("Compass-Sensor");
+	compass_task_tmr.setDeadline(0.1);
+	compass_task_tmr.setPeriod(0.1);
+
 	setupCompassSensor();
 
 	while (1) {
+		compass_task_tmr.recordStartTime();
+		compass_task_tmr.calculatePreviousSlackTime();
+
+		//Task content starts here -----------------------------------------------
 		local_command = keycommand_shared;
 
 		//Calibration routine
@@ -147,7 +157,23 @@
 			pthread_mutex_unlock(&compass_lock);
 			//printf("Bearing=%f\n", bearing_shared);
 		}
-		delayMicroseconds(5000);
+
+		//Task content ends here -------------------------------------------------
+		compass_task_tmr.recordEndTime();
+		compass_task_tmr.calculateExecutionTime();
+		compass_task_tmr.calculateDeadlineMissPercentage();
+		compass_task_tmr.incrementTotalCycles();
+		pthread_mutex_lock(&compass_task_ti_l);
+			compass_task_ti.deadline = compass_task_tmr.getDeadline();
+			compass_task_ti.deadline_miss_percentage = compass_task_tmr.getDeadlineMissPercentage();
+			compass_task_ti.execution_time = compass_task_tmr.getExecutionTime();
+			compass_task_ti.period = compass_task_tmr.getPeriod();
+			compass_task_ti.prev_slack_time = compass_task_tmr.getPrevSlackTime();
+			compass_task_ti.task_id = compass_task_tmr.getTaskID();
+			compass_task_ti.start_time = compass_task_tmr.getStartTime();
+			compass_task_ti.end_time = compass_task_tmr.getEndTime();
+		pthread_mutex_unlock(&compass_task_ti_l);
+		compass_task_tmr.sleepToMatchPeriod();
 	}
 
 	/* the function must return something - NULL will do */
diff --git a/rover/src/tasks/record_timing_task.cpp b/rover/src/tasks/record_timing_task.cpp
index aee411b..d4ceef7 100644
--- a/rover/src/tasks/record_timing_task.cpp
+++ b/rover/src/tasks/record_timing_task.cpp
@@ -75,6 +75,7 @@
 		PrintTimingInfo(acc_task_ti);
 		PrintTimingInfo(record_sensor_data_task_ti);
 		PrintTimingInfo(parking_task_ti);
+		PrintTimingInfo(compass_task_ti);
 		printf("-------------------------------------------------\n");
 		//Task content ends here -------------------------------------------------