ROVER - Improvements to CPU Logger thread

Signed-off-by: Mustafa Ozcelikors <mozcelikors@gmail.com>
diff --git a/rover/src/tasks/cpu_logger_task.cpp b/rover/src/tasks/cpu_logger_task.cpp
index 79b1d26..31c5de6 100644
--- a/rover/src/tasks/cpu_logger_task.cpp
+++ b/rover/src/tasks/cpu_logger_task.cpp
@@ -50,6 +50,8 @@
 
 		//Task content starts here -----------------------------------------------
 
+		core_num = 0;
+
 		// Read from file
 		fileptr = fopen ("/var/www/html/core_usage_rpi.inc", "r");
 		if (!fileptr)
@@ -61,17 +63,23 @@
 		{
 			// Get the data
 			fgets(buf, 20, fileptr);
-
+#ifdef DEBUG_CPU_LOGGER
+			printf("buf=%s\n", buf);
+#endif
 			// Parse the read file to get core usage information, Splitting operation with tokens
 			char *token = strtok(buf, ",");
 
 			while (token != NULL && core_num<=4)
 			{
-				sscanf(token, "%f", &roverUtilCpu[core_num]);
+				printf("token=%s\n", token);
+				sscanf(token, "%lf", &roverUtilCpu[core_num]);
 				token = strtok(NULL, ",");
 				core_num++;
 			}
 
+#ifdef DEBUG_CPU_LOGGER
+			printf("CPU_Util=%f %f %f %f\n",roverUtilCpu[0],roverUtilCpu[1],roverUtilCpu[2],roverUtilCpu[3]);
+#endif
 			// Write it to a shared variable for further usage in the application
 			pthread_mutex_lock(&cpu_util_shared_lock);
 				for (int i = 0; i < 4; i++)
diff --git a/rover/src/tasks/cpu_logger_task.h b/rover/src/tasks/cpu_logger_task.h
index 30fd784..57ea26b 100644
--- a/rover/src/tasks/cpu_logger_task.h
+++ b/rover/src/tasks/cpu_logger_task.h
@@ -20,7 +20,8 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-
+// Uncomment below compiler directive to see the output
+//#define DEBUG_CPU_LOGGER 1
 
 void *Cpu_Logger_Task (void * arg);