comparison Discovery/Src/tComm.c @ 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 dddfe7917131
children 5387e684d797
comparison
equal deleted inserted replaced
463:e4f6afd9c96b 464:05c5c3d10902
587 #endif 587 #endif
588 uint8_t count; 588 uint8_t count;
589 uint8_t aTxBuffer[128]; 589 uint8_t aTxBuffer[128];
590 uint8_t aRxBuffer[68]; 590 uint8_t aRxBuffer[68];
591 uint8_t answer; 591 uint8_t answer;
592 uint16_t index;
592 aTxBuffer[0] = type; 593 aTxBuffer[0] = type;
593 aTxBuffer[1] = prompt4D4C(receiveStartByteUart); 594 aTxBuffer[1] = prompt4D4C(receiveStartByteUart);
594 uint8_t tempHigh, tempLow; 595 uint8_t tempHigh, tempLow;
595 count = 0; 596 count = 0;
596 597
663 case 0x83: // hw copy logbook entry - read 664 case 0x83: // hw copy logbook entry - read
664 case 0x84: // hw copy logbook entry - write 665 case 0x84: // hw copy logbook entry - write
665 case 0x85: // hw read entire logbook memory 666 case 0x85: // hw read entire logbook memory
666 case 0x86: // hw overwrite entire logbook memory 667 case 0x86: // hw overwrite entire logbook memory
667 case 0x87: // hw ext_flash_repair_SPECIAL_dive_numbers_starting_count_with memory(x) 668 case 0x87: // hw ext_flash_repair_SPECIAL_dive_numbers_starting_count_with memory(x)
669 case 0x88: /* read entire sample memory */
670 case 0x89: /* write entire sample memory */
668 671
669 #endif 672 #endif
670 case 0xC1: // Start low-level bootloader 673 case 0xC1: // Start low-level bootloader
671 if(HAL_UART_Transmit(&UartHandle, (uint8_t*)aTxBuffer, 1, UART_OPERATION_TIMEOUT)!= HAL_OK) 674 if(HAL_UART_Transmit(&UartHandle, (uint8_t*)aTxBuffer, 1, UART_OPERATION_TIMEOUT)!= HAL_OK)
672 return 0; 675 return 0;
883 logCopyDataPtr = getFrame(98); 886 logCopyDataPtr = getFrame(98);
884 ext_flash_read_header_memory((uint8_t *)logCopyDataPtr); 887 ext_flash_read_header_memory((uint8_t *)logCopyDataPtr);
885 for(int i=0;i<8;i++) 888 for(int i=0;i<8;i++)
886 HAL_UART_Transmit(&UartHandle, (uint8_t *)(logCopyDataPtr + (0x8000 * i)), (uint16_t)0x8000,60000); 889 HAL_UART_Transmit(&UartHandle, (uint8_t *)(logCopyDataPtr + (0x8000 * i)), (uint16_t)0x8000,60000);
887 releaseFrame(98,logCopyDataPtr); 890 releaseFrame(98,logCopyDataPtr);
891 #ifdef SEND_DATA_DETAILS
892 HAL_UART_Transmit(&UartHandle, (uint8_t*)&pSettings->lastDiveLogId, 1,60000);
893 #endif
888 break; 894 break;
889 895
890 case 0x86: 896 case 0x86:
891 aTxBuffer[count++] = prompt4D4C(receiveStartByteUart); 897 aTxBuffer[count++] = prompt4D4C(receiveStartByteUart);
892 logCopyDataPtr = getFrame(98); 898 logCopyDataPtr = getFrame(98);
893 for(int i=0;i<8;i++) 899 for(int i=0;i<8;i++)
900 {
894 HAL_UART_Receive(&UartHandle, (uint8_t *)(logCopyDataPtr + (0x8000 * i)), (uint16_t)0x8000,60000); 901 HAL_UART_Receive(&UartHandle, (uint8_t *)(logCopyDataPtr + (0x8000 * i)), (uint16_t)0x8000,60000);
902 }
895 ext_flash_write_header_memory((uint8_t *)logCopyDataPtr); 903 ext_flash_write_header_memory((uint8_t *)logCopyDataPtr);
904 #ifdef SEND_DATA_DETAILS
905 if(HAL_UART_Receive(&UartHandle, (uint8_t *)(logCopyDataPtr + (0x8000 * 8)), (uint16_t)0x01,60000) == HAL_OK) /* receive lastlogID */
906 {
907 pSettings->lastDiveLogId = *(uint8_t*)(logCopyDataPtr + (0x40000));
908 }
909 #endif
896 releaseFrame(98,logCopyDataPtr); 910 releaseFrame(98,logCopyDataPtr);
897 break; 911 break;
898 912
899 case 0x87: 913 case 0x87:
900 if(HAL_UART_Receive(&UartHandle, (uint8_t*)aRxBuffer, 4, 1000)!= HAL_OK) 914 if(HAL_UART_Receive(&UartHandle, (uint8_t*)aRxBuffer, 4, 1000)!= HAL_OK)
904 totalDiveCount.u8bit.byteLow = aRxBuffer[1]; 918 totalDiveCount.u8bit.byteLow = aRxBuffer[1];
905 totalDiveCount.u8bit.byteHigh = aRxBuffer[0]; 919 totalDiveCount.u8bit.byteHigh = aRxBuffer[0];
906 ext_flash_repair_SPECIAL_dive_numbers_starting_count_with(totalDiveCount.u16bit); 920 ext_flash_repair_SPECIAL_dive_numbers_starting_count_with(totalDiveCount.u16bit);
907 aTxBuffer[count++] = prompt4D4C(receiveStartByteUart); 921 aTxBuffer[count++] = prompt4D4C(receiveStartByteUart);
908 break; 922 break;
923 case 0x88:
924 aTxBuffer[count++] = prompt4D4C(receiveStartByteUart);
925 logCopyDataPtr = getFrame(98);
926
927 for(index = 0; index <384; index++) /* transmit in 32k blocks */
928 {
929 ext_flash_read_sample_memory((uint8_t *)logCopyDataPtr, index);
930 if(HAL_UART_Transmit(&UartHandle, (uint8_t *)(logCopyDataPtr), (uint16_t)0x8000,60000) != HAL_OK)
931 {
932 break;
933 }
934 }
935 releaseFrame(98,logCopyDataPtr);
936 HAL_UART_Transmit(&UartHandle, (uint8_t*)&pSettings->logFlashNextSampleStartAddress, 4,60000); /* send next sample pos */
937 break;
938 case 0x89:
939 aTxBuffer[count++] = prompt4D4C(receiveStartByteUart);
940 logCopyDataPtr = getFrame(98);
941
942 for(index = 0; index <384; index++) /* transmit in 32k blocks 384*/
943 {
944
945 if(HAL_UART_Receive(&UartHandle, (uint8_t *)(logCopyDataPtr), (uint16_t)0x8000,60000) != HAL_OK)
946 {
947 break;
948 }
949 ext_flash_write_sample_memory((uint8_t *)logCopyDataPtr, index);
950 }
951
952 releaseFrame(98,logCopyDataPtr);
953 HAL_UART_Receive(&UartHandle, (uint8_t*)&pSettings->logFlashNextSampleStartAddress, 4,60000); /* send next sample pos */
954 break;
955
909 #endif 956 #endif
910 } 957 }
911 958
912 // was service command? Yes, finish and exit 959 // was service command? Yes, finish and exit
913 if(count) 960 if(count)