mbed-os github

Dependencies:   ADS1015 Faulhaber HTU21D_mod MS5837_potless Sensor_Head_RevB_3 USBDevice_dfu Utilsdfu beep

Fork of ARNSRS_testDFU by POTLESS

Revision:
36:1f5e2247b073
Parent:
35:a209a192f431
Child:
37:f9461c6592f2
--- a/main.cpp	Tue Mar 06 10:32:45 2018 +0000
+++ b/main.cpp	Thu Mar 08 15:38:06 2018 +0000
@@ -93,7 +93,7 @@
 int ppO2 = 0;
 int CellO2_1 = 0;
 int CellO2_2 = 0;
-    
+
 //Variables et constantes OTU
 float OTU = 0;
 float COEF_OTU = 0.83;
@@ -284,7 +284,7 @@
 void SENSORS_thread()
 {
     while (true) {
-        DEEP_DEBUG("  SENSORS_thread\r\n");
+        //DEEP_DEBUG("  SENSORS_thread\r\n");
 
         //CO2 sur Cozir
         co2 = sensors.requestCO2();
@@ -311,7 +311,7 @@
 void GO_TO_thread()
 {
     while (true) {
-        DEEP_DEBUG("  GO_TO_Thread\r\n");
+        //DEEP_DEBUG("  GO_TO_Thread\r\n");
 
         //Servo_Poumon.Go_To_Prop(Consigne_poumon);
         //Servo_Poumon.Go_To_PID(Consigne_poumon, Volet_DeadBand);
@@ -326,7 +326,7 @@
 void SECU_thread()
 {
     while (true) {
-        DEEP_DEBUG("  SECU_Thread\r\n");
+        //DEEP_DEBUG("  SECU_Thread\r\n");
 
         //Alim USB
         //Vusb = Power_Test(V_USB);
@@ -372,11 +372,11 @@
 
     char com[sizeParam] = "";
     char numb[] = "";
-    
+
     sscanf(message,"%s %s",&com , &numb);
-    
+
     DEEP_DEBUG("\r\n  Commande = %s       Valeur = %s \r\n\r\n", com, numb);
-    
+
     if (0 == strcmp(com, "secu")) {
         Mode_SECU();
     } else if (0 == strcmp(com, "ARNSRS_ID")) {
@@ -403,6 +403,11 @@
         FLAG_REC = false;
         UTILS::Flash_Infos();
         FLAG_REC = true;
+    } else if (0 == strcmp(com, "flash_u")) {
+        FLAG_REC = false;
+        UTILS::UnMount_Flash();
+    } else if (0 == strcmp(com, "flash_m")) {
+        UTILS::Mount_Flash();        
     } else if (0 == strcmp(com, "check_F")) {
         FLAG_REC = false;
         serialMonit.printf("  ARNSRS_ID.txt   = %d\r\n", (int)UTILS::Read_A_Val("ARNSRS_ID"));
@@ -428,7 +433,7 @@
     } else if (0 == strcmp(com, "stop")) {
         FLAG_AFF = false;
         UTILS::Help();
-    } else if (0 == strcmp(com, "clean")) {
+    } else if (0 == strcmp(com, "flash_c")) {
         FLAG_REC = false;
         UTILS::Clean_Flash();
     } else if (0 == strcmp(com, "dir")) {
@@ -475,6 +480,7 @@
         Consigne_fuite = atof(numb);
         DEBUG("  Servo Fuite     =  %f\r\n", Consigne_fuite);
     } else if (0 == strcmp(com, "reset")) {
+        UTILS::UnMount_Flash();
         NVIC_SystemReset();
     } else {
         sensors.cozirSend(message);
@@ -584,13 +590,19 @@
             //Liste des fichiers sur la Flash
             UTILS::Dir_Flash();
 
+            //Vérification RTC, si on est le 01/01/70, c'est qu'il y a un problème
+            seconds = time(NULL);
+            char YEAR[10];
+            strftime(YEAR, 10, "%D", localtime(&seconds));
+            if (0 == strcmp(YEAR, "01/01/70")) serialMonit.printf("  Vous devez régler la RTC...\r\n");
+             
             if (UTILS::File_Exist("ARNSRS_ID") == false) {
                 UTILS::Store_A_Val(000, "ARNSRS_ID");
-                DEBUG("ARNSRS ID forcée à 000");
+                DEBUG("ARNSRS ID forcée à 000\r\n");
             }
 
-            bool calib_O2 = false;
-            bool calib_CO2 = false;
+            bool calib_O2 = true;
+            bool calib_CO2 = true;
 
             /*
             Par défaut les valeur en cas de calibration sur true sont les suivant
@@ -615,16 +627,13 @@
             sensors.Sensors_INIT(calib_O2, calib_CO2);
             wait(1);
 
-            sensors.Sensor_head_check();
-            wait(1);
-            
             //Création du nouveau fichier LOG par index / par date.
             Create_File_Name_Index();
             //Create_File_Name_Date()
-            
+
             //Création et écriture du header du fichier LOG
             sensors.Create_Header(Log_File_Name);
-            
+
             Servo_Poumon.Init("Servo_Poumon");
             //Servo_Fuite.Init("Servo_Fuite");
 
@@ -643,17 +652,17 @@
                   osPriorityRealtime      = +3,          ///< priority: realtime (highest)
                   osPriorityError         =  0x84        ///< system cannot determine priority or thread has illegal priority
             */
-            wait(1); 
-            
-            
+            wait(1);
+
+
             Thread thread_Volets(osPriorityNormal);
-            
+
             thread_Volets.start(callback(GO_TO_thread));
 
             DEBUG("  Volets thread démarré\r\n\r\n");
 
             wait(1);
-            
+
             Thread thread_Secu(osPriorityNormal);
 
             thread_Secu.start(callback(SECU_thread));
@@ -663,7 +672,7 @@
             wait(1);
 
             Thread thread_Head(osPriorityNormal);
-            
+
             thread_Head.start(callback(SENSORS_thread));
 
             DEBUG("  Info thread démarré\r\n\r\n");