changeset 424:2b31cf1ebbcc ImprovmentNVM_2

Added (optional) menu item to analyse log sample buffer: The analysis function will check the ring buffer for proper closure of sectors. In case of a log sample ring corruption more than sector will show the state started (4). Depending on the time past since corruption and the location of the corrupted sector, a cleanup function will be executed if a dive is started. The dive is necessary because of the definition of sample position during OSTC startup phase.
author ideenmodellierer
date Sat, 15 Feb 2020 20:45:19 +0100
parents a560afdaadbf
children 86fcac4cc43a
files Discovery/Inc/tStructure.h Discovery/Inc/text_multilanguage.h Discovery/Src/tMenuEditSystem.c Discovery/Src/text_multilanguage.c
diffstat 4 files changed, 50 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/Discovery/Inc/tStructure.h	Mon Feb 10 19:40:33 2020 +0100
+++ b/Discovery/Inc/tStructure.h	Sat Feb 15 20:45:19 2020 +0100
@@ -290,19 +290,19 @@
 #define StMSYS5_Info		_MB(2,8,5,1,0)
 
 
-#define StMSYS6_Exit					_MB(2,8,6,1,0)
+#define StMSYS6_Exit			_MB(2,8,6,1,0)
 #define StMSYS6_LogbookOffset	_MB(2,8,6,7,0)
-#define StMSYS6_ResetAll			_MB(2,8,6,2,0)
-#define StMSYS6_ResetDeco			_MB(2,8,6,3,0)
-#define StMSYS6_Reboot				_MB(2,8,6,4,0)
+#define StMSYS6_ResetAll		_MB(2,8,6,2,0)
+#define StMSYS6_ResetDeco		_MB(2,8,6,3,0)
+#define StMSYS6_Reboot			_MB(2,8,6,4,0)
 #define StMSYS6_Maintenance		_MB(2,8,6,5,0)
 #define StMSYS6_ResetLogbook	_MB(2,8,6,6,0)
 #define StMSYS6_SetBattCharge	_MB(2,8,6,7,0)
-#define StMSYS6_RebootRTE			_MB(2,8,6,8,0)
+#define StMSYS6_RebootRTE		_MB(2,8,6,8,0)
 #define StMSYS6_RebootMainCPU	_MB(2,8,6,9,0)
 #define StMSYS6_ScreenTest		_MB(2,8,6,10,0)
 #define StMSYS6_SetFactoryBC	_MB(2,8,6,11,0)
-
+#define StMSYS6_SetSampleIndx   _MB(2,8,6,12,0)
 
 /* PAGE 9 */
 #define StMPLAN		_MB(2,9,0,0,0)
--- a/Discovery/Inc/text_multilanguage.h	Mon Feb 10 19:40:33 2020 +0100
+++ b/Discovery/Inc/text_multilanguage.h	Sat Feb 15 20:45:19 2020 +0100
@@ -288,6 +288,7 @@
 		TXT2BYTE_Maintenance,
 		TXT2BYTE_SetBatteryCharge,
 		TXT2BYTE_SetFactoryDefaults,
+		TXT2BYTE_SetSampleIndex,
 		TXT2BYTE_Reboot,
 		TXT2BYTE_ButtonLeft,
 		TXT2BYTE_ButtonMitte,
--- a/Discovery/Src/tMenuEditSystem.c	Mon Feb 10 19:40:33 2020 +0100
+++ b/Discovery/Src/tMenuEditSystem.c	Sat Feb 15 20:45:19 2020 +0100
@@ -41,6 +41,8 @@
 #include "motion.h"
 #include "t7.h"
 
+/* Uncomment to activate a menu item in reset menu which provide sample ring analysis / repair functionality */
+#define ENABLE_ANALYSE_SAMPLES
 
 #define CV_SUBPAGE_MAX		(2u)	/* max number of customer view selection pages */
 /*#define HAVE_DEBUG_VIEW */
@@ -95,6 +97,7 @@
 uint8_t OnAction_LogbookOffset(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
 uint8_t OnAction_SetFactoryDefaults(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
 uint8_t OnAction_SetBatteryCharge(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
+uint8_t OnAction_RecoverSampleIdx(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
 #ifdef SCREENTEST
 uint8_t OnAction_ScreenTest		(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
 #endif
@@ -1470,27 +1473,46 @@
 
     case StMSYS6_Maintenance:
     case StMSYS6_SetBattCharge:
+    case StMSYS6_SetSampleIndx:
         text[0] = TXT_2BYTE;
         text[1] = TXT2BYTE_SetFactoryDefaults;
         text[2] = 0;
         write_field_button(StMSYS6_SetFactoryBC,			30, 800, ME_Y_LINE2,  &FontT48, text);
 
+#ifdef ENABLE_ANALYSE_SAMPLES
+        text[0] = TXT_2BYTE;
+        text[1] = TXT2BYTE_SetSampleIndex;
+        text[2] = 0;
+        write_field_button(StMSYS6_SetSampleIndx,			30, 800, ME_Y_LINE3,  &FontT48, text);
+#endif
+
+
         if(stateRealGetPointer()->lifeData.battery_charge == 0)
         {
             text[0] = TXT_2BYTE;
             text[1] = TXT2BYTE_SetBatteryCharge;
             text[2] = 0;
             snprintf(&text[2],10,": %u%%",settingsGetPointer()->lastKnownBatteryPercentage);
+#ifdef ENABLE_ANALYSE_SAMPLES
+            write_field_button(StMSYS6_SetBattCharge,			30, 800, ME_Y_LINE4,  &FontT48, text);
+#else
             write_field_button(StMSYS6_SetBattCharge,			30, 800, ME_Y_LINE3,  &FontT48, text);
+#endif
 
             setEvent(StMSYS6_Exit, (uint32_t)OnAction_Exit);
             setEvent(StMSYS6_SetFactoryBC, (uint32_t)OnAction_SetFactoryDefaults);
+#ifdef ENABLE_ANALYSE_SAMPLES
+            setEvent(StMSYS6_SetSampleIndx, (uint32_t)OnAction_RecoverSampleIdx);
+#endif
             setEvent(StMSYS6_SetBattCharge, (uint32_t)OnAction_SetBatteryCharge);
         }
         else
         {
             setEvent(StMSYS6_Exit, (uint32_t)OnAction_Exit);
             setEvent(StMSYS6_SetFactoryBC, (uint32_t)OnAction_SetFactoryDefaults);
+#ifdef ENABLE_ANALYSE_SAMPLES
+            setEvent(StMSYS6_SetSampleIndx, (uint32_t)OnAction_RecoverSampleIdx);
+#endif
         }
 //		write_field_button(StMSYS6_ScreenTest,			30, 800, ME_Y_LINE3,  &FontT48, "Screen Test");
 //		setEvent(StMSYS6_ScreenTest, (uint32_t)OnAction_ScreenTest);
@@ -1609,6 +1631,18 @@
 }
 
 
+uint8_t OnAction_RecoverSampleIdx(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
+{
+	char text[32];
+	char strResult[20];
+
+
+	ext_flash_AnalyseSampleBuffer(strResult);
+    snprintf(&text[0],30,"Ring: %s",strResult); //"Code: %X",settingsGetPointer()->logFlashNextSampleStartAddress); //getLicence());
+    write_label_var(  30, 800, ME_Y_LINE6, &FontT42, text);
+    return UNSPECIFIC_RETURN;
+}
+
 uint8_t OnAction_SetBatteryCharge(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
 {
     setBatteryPercentage(settingsGetPointer()->lastKnownBatteryPercentage);
--- a/Discovery/Src/text_multilanguage.c	Mon Feb 10 19:40:33 2020 +0100
+++ b/Discovery/Src/text_multilanguage.c	Sat Feb 15 20:45:19 2020 +0100
@@ -618,6 +618,14 @@
 static uint8_t text_ES_SetFactoryDefaults[] = "Restablecer ajustes de fábrica";
 
 // Menu SYS2 sub
+static uint8_t text_EN_SetSampleIndex[] = "Analyse log memory";
+static uint8_t text_DE_SetSampleIndex[] = "Prüfe Logbuchspeicher";
+static uint8_t text_FR_SetSampleIndex[] = "Maintain log memory";
+static uint8_t text_IT_SetSampleIndex[] = "Maintain log memory";
+static uint8_t text_ES_SetSampleIndex[] = "Maintain log memory";
+
+
+// Menu SYS2 sub
 static uint8_t text_EN_Reboot[] = "Reboot";
 static uint8_t text_DE_Reboot[] = "Neustart";
 static uint8_t text_FR_Reboot[] = "Redémarrage";
@@ -1761,6 +1769,7 @@
     {(uint8_t)TXT2BYTE_Maintenance,		{text_EN_Maintenance, text_DE_Maintenance, text_FR_Maintenance, text_IT_Maintenance, text_ES_Maintenance}},
     {(uint8_t)TXT2BYTE_SetBatteryCharge,{text_EN_SetBatteryCharge, text_DE_SetBatteryCharge, text_FR_SetBatteryCharge, text_IT_SetBatteryCharge, text_ES_SetBatteryCharge}},
     {(uint8_t)TXT2BYTE_SetFactoryDefaults,{text_EN_SetFactoryDefaults, text_DE_SetFactoryDefaults, text_FR_SetFactoryDefaults, text_IT_SetFactoryDefaults, text_ES_SetFactoryDefaults}},
+	{(uint8_t)TXT2BYTE_SetSampleIndex,  {text_EN_SetSampleIndex, text_DE_SetSampleIndex, text_FR_SetSampleIndex, text_IT_SetSampleIndex, text_ES_SetSampleIndex}},
 
     {(uint8_t)TXT2BYTE_Reboot,			{text_EN_Reboot, text_DE_Reboot, text_FR_Reboot, text_IT_Reboot, text_ES_Reboot}},
     {(uint8_t)TXT2BYTE_ButtonLeft,		{text_EN_ButtonLeft, text_DE_ButtonLeft, text_FR_ButtonLeft, text_IT_ButtonLeft, text_ES_ButtonLeft}},