changeset 464:05c5c3d10902 Improve_Logtansfer

Added compile switch to handle additional data during raw header request: Beeside the pure header also the number of the last dive is of interested. Added compile switch to stay compatible with tools which might use the raw header command Added commands to support read and write acces to sample buffer
author ideenmodellierer
date Mon, 13 Apr 2020 16:00:54 +0200
parents e4f6afd9c96b
children 2c2df051e554
files Discovery/Inc/configuration.h Discovery/Src/tComm.c
diffstat 2 files changed, 50 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/Discovery/Inc/configuration.h	Sun Apr 12 21:02:34 2020 +0200
+++ b/Discovery/Inc/configuration.h	Mon Apr 13 16:00:54 2020 +0200
@@ -43,4 +43,7 @@
 /* Enable this to reset the profile data by pressing enter within log info menu */
 /* #define ENABLE_PROFILE_RESET */
 
+/* Enable this to transfer additional data list last dive ID and last sample index during raw data requests */
+/* define SEND_DATA_DETAILS */
+
 #endif
--- a/Discovery/Src/tComm.c	Sun Apr 12 21:02:34 2020 +0200
+++ b/Discovery/Src/tComm.c	Mon Apr 13 16:00:54 2020 +0200
@@ -589,6 +589,7 @@
     uint8_t aTxBuffer[128];
     uint8_t aRxBuffer[68];
     uint8_t answer;
+    uint16_t index;
     aTxBuffer[0] = type;
     aTxBuffer[1] = prompt4D4C(receiveStartByteUart);
     uint8_t tempHigh, tempLow;
@@ -665,6 +666,8 @@
         case 0x85: // hw read entire logbook memory
         case 0x86: // hw overwrite entire logbook memory
         case 0x87: // hw ext_flash_repair_SPECIAL_dive_numbers_starting_count_with memory(x)
+        case 0x88: /* read entire sample memory  */
+        case 0x89: /* write entire sample memory */
 
 #endif
         case 0xC1: // 	Start low-level bootloader
@@ -885,14 +888,25 @@
             for(int i=0;i<8;i++)
                 HAL_UART_Transmit(&UartHandle, (uint8_t *)(logCopyDataPtr + (0x8000 * i)), (uint16_t)0x8000,60000);
             releaseFrame(98,logCopyDataPtr);
+#ifdef SEND_DATA_DETAILS
+            HAL_UART_Transmit(&UartHandle, (uint8_t*)&pSettings->lastDiveLogId, 1,60000);
+#endif
             break;
 
         case 0x86:
             aTxBuffer[count++] = prompt4D4C(receiveStartByteUart);
             logCopyDataPtr = getFrame(98);
             for(int i=0;i<8;i++)
+            {
                 HAL_UART_Receive(&UartHandle, (uint8_t *)(logCopyDataPtr + (0x8000 * i)), (uint16_t)0x8000,60000);
+            }
             ext_flash_write_header_memory((uint8_t *)logCopyDataPtr);
+#ifdef SEND_DATA_DETAILS
+            if(HAL_UART_Receive(&UartHandle, (uint8_t *)(logCopyDataPtr + (0x8000 * 8)), (uint16_t)0x01,60000) == HAL_OK)	/* receive lastlogID */
+            {
+            	pSettings->lastDiveLogId = *(uint8_t*)(logCopyDataPtr + (0x40000));
+            }
+#endif
             releaseFrame(98,logCopyDataPtr);
             break;
 
@@ -906,6 +920,39 @@
             ext_flash_repair_SPECIAL_dive_numbers_starting_count_with(totalDiveCount.u16bit);
             aTxBuffer[count++] = prompt4D4C(receiveStartByteUart);
             break;
+        case 0x88:
+             aTxBuffer[count++] = prompt4D4C(receiveStartByteUart);
+             logCopyDataPtr = getFrame(98);
+
+             for(index = 0; index <384; index++)		/* transmit in 32k blocks */
+             {
+            	 ext_flash_read_sample_memory((uint8_t *)logCopyDataPtr, index);
+                 if(HAL_UART_Transmit(&UartHandle, (uint8_t *)(logCopyDataPtr), (uint16_t)0x8000,60000) != HAL_OK)
+                 {
+                	 break;
+                 }
+             }
+             releaseFrame(98,logCopyDataPtr);
+             HAL_UART_Transmit(&UartHandle, (uint8_t*)&pSettings->logFlashNextSampleStartAddress, 4,60000);	/* send next sample pos */
+        	break;
+        case 0x89:
+             aTxBuffer[count++] = prompt4D4C(receiveStartByteUart);
+             logCopyDataPtr = getFrame(98);
+
+             for(index = 0; index <384; index++)		/* transmit in 32k blocks  384*/
+             {
+
+                 if(HAL_UART_Receive(&UartHandle, (uint8_t *)(logCopyDataPtr), (uint16_t)0x8000,60000) != HAL_OK)
+                 {
+                	 break;
+                 }
+                 ext_flash_write_sample_memory((uint8_t *)logCopyDataPtr, index);
+             }
+
+             releaseFrame(98,logCopyDataPtr);
+             HAL_UART_Receive(&UartHandle, (uint8_t*)&pSettings->logFlashNextSampleStartAddress, 4,60000);	/* send next sample pos */
+        	break;
+
 #endif
         }