avec dfu

Fork of Utils by POTLESS

Files at this revision

API Documentation at this revision

Comitter:
POTLESS_2
Date:
Sat Feb 24 16:55:04 2018 +0000
Parent:
9:fa2818db80cf
Child:
11:a41267cffa61
Commit message:
DEBUG general

Changed in this revision

Utils.cpp Show annotated file Show diff for this revision Revisions of this file
Utils.h Show annotated file Show diff for this revision Revisions of this file
--- a/Utils.cpp	Fri Feb 23 19:05:27 2018 +0000
+++ b/Utils.cpp	Sat Feb 24 16:55:04 2018 +0000
@@ -13,10 +13,10 @@
 {
     Exist_Val = 0;
     if (ret_val) {
-        DEBUG_U("  Problème Flash = %d\r\n", ret_val);
+        DEBUG("  Problème Flash = %d\r\n", ret_val);
         Exist_Val = 0;
     } else {
-        DEBUG_U("  Flash -> OK.\r\n");
+        DEBUG("  Flash -> OK.\r\n");
         Exist_Val = 1;
     }
     wait_ms(100);
@@ -26,10 +26,10 @@
 {
     Exist_Val = 0;
     if (ret_val == NULL) {
-        DEBUG_U("  Problème Flash = %d \r\n", errno);
+        DEBUG("  Problème Flash = %d \r\n", errno);
         Exist_Val = 0;
     } else {
-        DEBUG_U("  Flash -> OK.\r\n");
+        DEBUG("  Flash -> OK.\r\n");
         Exist_Val = 1;
     }
     wait_ms(100);
@@ -146,7 +146,7 @@
     fprintf(fd, "%f\r\n", Val_To_Store);
     fclose(fd);
 
-    DEBUG_U("  \r\n  %s sauvegardée = %f\r\n", filename, Val_To_Store);
+    DEBUG("  \r\n  %s sauvegardée = %f\r\n", filename, Val_To_Store);
 
 }
 
@@ -160,7 +160,7 @@
     char filename[20];
     sprintf(filename, "/Root/%s.txt", File_Name);
 
-    DEBUG_U("  \n  Récupération de %s...\r\n", filename);
+    DEBUG("  \n  Récupération de %s...\r\n", filename);
 
     FILE* fd = fopen(filename, "r");
     errno_error(fd);
@@ -175,7 +175,7 @@
 
     float val = atof(token);
 
-    DEBUG_U("  Valeur Récupérée = %f\r\n", val);
+    DEBUG("  Valeur Récupérée = %f\r\n", val);
 
     fclose(fd);
 
@@ -194,7 +194,7 @@
     fprintf(fd, "%s\r\n", To_Store);
     fclose(fd);
 
-    DEBUG_U("  Enregistrement de %s OK\r\n\r\n", filename);
+    DEBUG("  Enregistrement de %s OK\r\n\r\n", filename);
 }
 
 /*
@@ -248,7 +248,7 @@
     errno_error(fd);
 
     if (Exist_Val == 0) {
-        DEBUG_U("  Le fichier %s n'existe pas....\r\n", filename);
+        DEBUG("  Le fichier %s n'existe pas....\r\n", filename);
         fclose(fd);
         return false;
     }
@@ -267,12 +267,12 @@
     error = Root.remove(filename);
     return_error(error);
 
-    DEBUG_U("Fichier %s effacé.\r\n", filename);
+    DEBUG("Fichier %s effacé.\r\n", filename);
 }
 
 void UTILS::Clean_Flash()
 {
-    DEBUG_U("Nettoyage de la Flash.\r\n");
+    DEBUG("Nettoyage de la Flash.\r\n");
     float Saved_O2 = UTILS::Read_A_Val("Calibration_O2");
     int Saved_Motor = (int)UTILS::Read_A_Val("Servo_Poumon");
     UTILS::UnMount_Flash();
@@ -280,8 +280,8 @@
     UTILS::Mount_Flash();
     UTILS::Store_A_Val(Saved_O2, "Calibration_O2");
     UTILS::Store_A_Val(Saved_Motor, "Servo_Poumon");
-    DEBUG_U("Flash nettoyée.\r\n");
-    DEBUG_U("Redémmarage code.\r\n");
+    DEBUG("Flash nettoyée.\r\n");
+    DEBUG("Redémmarage code.\r\n");
     NVIC_SystemReset();   
 }
 
@@ -296,19 +296,19 @@
     error = Root.rename(Oldfilename, Newfilename);
     return_error(error);
 
-    DEBUG_U("Fichier %s renommé en %s.\r\n", Oldfilename, Newfilename);
+    DEBUG("Fichier %s renommé en %s.\r\n", Oldfilename, Newfilename);
 }
 
 void UTILS::Mount_Flash()
 {
     //Montage Flash
-    DEBUG_U("  Montage Flash \"/Root\". \r\n\r\n");
+    DEBUG("  Montage Flash \"/Root\". \r\n\r\n");
     int error = 0;
     error = Root.mount(&bd);
     return_error(error);
     if (error > 0) {
         //On re format s'il n'y a as de file system...normalement une seul fois...
-        DEBUG_U("Pas de File system, on format... ");
+        DEBUG("Pas de File system, on format... ");
         Format_Flash();
     }
 }
@@ -316,7 +316,7 @@
 void UTILS::UnMount_Flash()
 {
     //De Montage Flash
-    DEBUG_U("  Demontage Flash \"/Root\". \r\n\r\n");
+    DEBUG("  Demontage Flash \"/Root\". \r\n\r\n");
     int error = 0;
     error = Root.unmount();
     return_error(error);
@@ -325,7 +325,7 @@
 void UTILS::Format_Flash()
 {
     //Formatage Flash
-    DEBUG_U("  Formatage Flash\r\n\r\n");
+    DEBUG("  Formatage Flash\r\n\r\n");
     int error = 0;
     error = FATFileSystem::format(&bd);
     return_error(error);
@@ -335,21 +335,21 @@
 {
     int error = 0;
     int nb = 0;
-    DEBUG_U("\r\n  Ouverture du répertoire %s\r\n", Dir_Name);
+    DEBUG("\r\n  Ouverture du répertoire %s\r\n", Dir_Name);
     char Dirname[20];
     sprintf(Dirname, "/Root/%s", Dir_Name);
 
     DIR* dir = opendir(Dirname);
 
     struct dirent* de;
-    DEBUG_U("  Fichier du répertoire :\r\n\r\n");
+    DEBUG("  Fichier du répertoire :\r\n\r\n");
     while((de = readdir(dir)) != NULL) {
         printf("  %s\r\n", &(de->d_name)[0]);
         fflush(stdout);
         nb++;
     }
-    DEBUG_U("\r\n  Nombre de fichiers = %d\r\n", nb);
-    DEBUG_U("  Fermeture du répertoire.\r\n");
+    DEBUG("\r\n  Nombre de fichiers = %d\r\n", nb);
+    DEBUG("  Fermeture du répertoire.\r\n");
     error = closedir(dir);
     return_error(error);
 }
--- a/Utils.h	Fri Feb 23 19:05:27 2018 +0000
+++ b/Utils.h	Sat Feb 24 16:55:04 2018 +0000
@@ -17,12 +17,12 @@
 #define Flash_SCK PA_5
 #define Flash_CS PB_6
 
-#define DEBUG_UTILS 0
+#define DEBUG_MODE 0
 
-#if DEBUG_UTILS
-#define DEBUG_U(...) { printf(__VA_ARGS__); fflush(stdout);}
+#if DEBUG_MODE
+#define DEBUG(...) { printf(__VA_ARGS__); fflush(stdout);}
 #else
-#define DEBUG_U(...)
+#define DEBUG(...)
 #endif
 
 /** Utils class.