Mercurial > public > ostc4
comparison Discovery/Src/tComm.c @ 236:ad6ddc4aabcd
Minor: translating some comments and variable names into english, some cleanup in tComm.c
author | heinrichsweikamp |
---|---|
date | Sat, 06 Apr 2019 09:41:14 +0200 |
parents | 2c0b502b0a72 |
children | 4da2bffb07ca |
comparison
equal
deleted
inserted
replaced
235:eebad720865f | 236:ad6ddc4aabcd |
---|---|
31 ##### How to use ##### | 31 ##### How to use ##### |
32 ============================================================================== | 32 ============================================================================== |
33 ============================================================================== | 33 ============================================================================== |
34 ##### History ##### | 34 ##### History ##### |
35 ============================================================================== | 35 ============================================================================== |
36 160211 added 4 bytes Serial in update Files after pruefsumme prior to binary | 36 160211 added 4 bytes Serial in update Files after checksum prior to binary |
37 160211 0x6B changed to version only | 37 160211 0x6B changed to version only |
38 160623 fixed 0x72 (in V1.0.9) | 38 160623 fixed 0x72 (in V1.0.9) |
39 160623 fixed rebuild menu (before update) for V1.0.10 | 39 160623 fixed rebuild menu (before update) for V1.0.10 |
40 | 40 |
41 ============================================================================== | 41 ============================================================================== |
42 ##### CTS / RTS ##### | 42 ##### CTS / RTS ##### |
43 ============================================================================== | 43 ============================================================================== |
44 RTS ist immer Output, CTS is immer Input | 44 RTS is Output, CTS is Input |
45 | 45 |
46 BlueMod Pin D7 UART-RTS# ist Output | 46 BlueMod Pin D7 UART-RTS# is Output |
47 geht auf STM32F429 PA11 CTS (Input) | 47 connected to STM32F429 PA11 CTS (Input) |
48 dito STM32 PA12 RTS geht auf BlueMod UART-CTS# F3 | 48 also STM32 PA12 RTS is connected to BlueMod UART-CTS# F3 |
49 | 49 |
50 siehe BlueMod_SR_HWreference_r06.pdf, Seite 156 | 50 see BlueMod_SR_HWreference_r06.pdf, page 156 |
51 und MAIN_CPU STM32F4 Reference manual DM00031020.pdf, Seite 990 | 51 and MAIN_CPU STM32F4 Reference manual DM00031020.pdf, page 990 |
52 | 52 |
53 | 53 |
54 ============================================================================== | 54 ============================================================================== |
55 ##### Codes ##### | 55 ##### Codes ##### |
56 ============================================================================== | 56 ============================================================================== |
57 [0x73] upload CPU2 firmware in SDRAM and update CPU2 | 57 [0x73] upload CPU2 firmware in SDRAM and update CPU2 |
58 | 58 |
59 [0x74] upload MainCPU firmware in EEPROM and start bootloader | 59 [0x74] upload MainCPU firmware in EEPROM and start bootloader |
60 | 60 |
61 OSTC3 stuff can be found in comm.asm | |
62 */ | 61 */ |
63 | 62 |
64 /* Includes ------------------------------------------------------------------*/ | 63 /* Includes ------------------------------------------------------------------*/ |
65 | 64 |
66 #include "tComm.h" | 65 #include "tComm.h" |
120 static uint8_t select_mode(uint8_t aRxByte); | 119 static uint8_t select_mode(uint8_t aRxByte); |
121 uint8_t receive_update_flex(uint8_t isRTEupdateALLOWED); | 120 uint8_t receive_update_flex(uint8_t isRTEupdateALLOWED); |
122 uint8_t receive_update_data_flex(uint8_t* pBuffer1, uint8_t* pBuffer2, uint8_t RTEupdateALLOWED); | 121 uint8_t receive_update_data_flex(uint8_t* pBuffer1, uint8_t* pBuffer2, uint8_t RTEupdateALLOWED); |
123 uint8_t receive_update_data_mainCPU_firmware(void); | 122 uint8_t receive_update_data_mainCPU_firmware(void); |
124 uint8_t receive_update_data_mainCPU_variable_firmware(void); | 123 uint8_t receive_update_data_mainCPU_variable_firmware(void); |
125 uint8_t receive_update_data_mainCPU_firmware_subrotuine(uint8_t region, uint8_t* pBuffer1, uint8_t* pBuffer2); | 124 uint8_t receive_update_data_mainCPU_firmware_subroutine(uint8_t region, uint8_t* pBuffer1, uint8_t* pBuffer2); |
126 HAL_StatusTypeDef receive_uart_large_size(UART_HandleTypeDef *huart, uint8_t *pData, uint32_t Size); | 125 HAL_StatusTypeDef receive_uart_large_size(UART_HandleTypeDef *huart, uint8_t *pData, uint32_t Size); |
127 static uint8_t openComm(uint8_t aRxByte); | 126 static uint8_t openComm(uint8_t aRxByte); |
128 uint8_t HW_Set_Bluetooth_Name(uint16_t serial, uint8_t withEscapeSequence); | 127 uint8_t HW_Set_Bluetooth_Name(uint16_t serial, uint8_t withEscapeSequence); |
129 uint8_t prompt4D4C(uint8_t mode); | 128 uint8_t prompt4D4C(uint8_t mode); |
130 | 129 |
871 case 0xFF: | 870 case 0xFF: |
872 HAL_UART_Transmit(&UartHandle, (uint8_t*)&aTxBuffer, 1, 1000); | 871 HAL_UART_Transmit(&UartHandle, (uint8_t*)&aTxBuffer, 1, 1000); |
873 return 0; | 872 return 0; |
874 | 873 |
875 default: | 874 default: |
876 aTxBuffer[count++] = prompt4D4C(receiveStartByteUart); // hw 160712 | 875 aTxBuffer[count++] = prompt4D4C(receiveStartByteUart); |
877 break; | 876 break; |
878 } | 877 } |
879 | 878 |
880 switch(type) | 879 switch(type) |
881 { | 880 { |
1032 #endif | 1031 #endif |
1033 | 1032 |
1034 #ifndef BOOTLOADER_STANDALONE | 1033 #ifndef BOOTLOADER_STANDALONE |
1035 // full headers (256 byte) | 1034 // full headers (256 byte) |
1036 case 0x61: | 1035 case 0x61: |
1037 // for(int StepBackwards = 0;StepBackwards<256;StepBackwards++) // comment Jef Driesen email 15.09.2015 and 3.3.2016 | |
1038 for(int StepBackwards = 255; StepBackwards > -1; StepBackwards--) | 1036 for(int StepBackwards = 255; StepBackwards > -1; StepBackwards--) |
1039 { | 1037 { |
1040 logbook_getHeader(StepBackwards, &logbookHeader); | 1038 logbook_getHeader(StepBackwards, &logbookHeader); |
1041 plogbookHeaderOSTC3 = logbook_build_ostc3header(&logbookHeader); | 1039 plogbookHeaderOSTC3 = logbook_build_ostc3header(&logbookHeader); |
1042 if(HAL_UART_Transmit(&UartHandle, (uint8_t*)plogbookHeaderOSTC3, 256,5000)!= HAL_OK) | 1040 if(HAL_UART_Transmit(&UartHandle, (uint8_t*)plogbookHeaderOSTC3, 256,5000)!= HAL_OK) |
1045 aTxBuffer[count++] = prompt4D4C(receiveStartByteUart); | 1043 aTxBuffer[count++] = prompt4D4C(receiveStartByteUart); |
1046 break; | 1044 break; |
1047 | 1045 |
1048 // compact headers (16 byte) | 1046 // compact headers (16 byte) |
1049 case 0x6D: | 1047 case 0x6D: |
1050 // for(int StepBackwards = 0;StepBackwards<256;StepBackwards++) // comment Jef Driesen email 15.09.2015 and 3.3.2016 | |
1051 for(int StepBackwards = 255; StepBackwards > -1; StepBackwards--) | 1048 for(int StepBackwards = 255; StepBackwards > -1; StepBackwards--) |
1052 { | 1049 { |
1053 logbook_getHeader(StepBackwards, &logbookHeader); | 1050 logbook_getHeader(StepBackwards, &logbookHeader); |
1054 plogbookHeaderOSTC3compact = logbook_build_ostc3header_compact(&logbookHeader); | 1051 plogbookHeaderOSTC3compact = logbook_build_ostc3header_compact(&logbookHeader); |
1055 if(HAL_UART_Transmit(&UartHandle, (uint8_t*)plogbookHeaderOSTC3compact, 16,5000)!= HAL_OK) | 1052 if(HAL_UART_Transmit(&UartHandle, (uint8_t*)plogbookHeaderOSTC3compact, 16,5000)!= HAL_OK) |
1092 aTxBuffer[count++] = prompt4D4C(receiveStartByteUart); | 1089 aTxBuffer[count++] = prompt4D4C(receiveStartByteUart); |
1093 break; | 1090 break; |
1094 | 1091 |
1095 // get dive profile | 1092 // get dive profile |
1096 case 0x66: | 1093 case 0x66: |
1097 // logbook_getHeader(aRxBuffer[0], &logbookHeader); // comment Jef Driesen email 15.09.2015 | |
1098 logbook_getHeader(255 - aRxBuffer[0], &logbookHeader); | 1094 logbook_getHeader(255 - aRxBuffer[0], &logbookHeader); |
1099 plogbookHeaderOSTC3 = logbook_build_ostc3header(&logbookHeader); | 1095 plogbookHeaderOSTC3 = logbook_build_ostc3header(&logbookHeader); |
1100 if(HAL_UART_Transmit(&UartHandle, (uint8_t*)plogbookHeaderOSTC3, 256,5000)!= HAL_OK) | 1096 if(HAL_UART_Transmit(&UartHandle, (uint8_t*)plogbookHeaderOSTC3, 256,5000)!= HAL_OK) |
1101 return 0; | 1097 return 0; |
1102 ext_flash_open_read_sample(255 - aRxBuffer[0], &sampleTotalLength); // comment Jef Driesen email 15.09.2015 about length: changed in externLogbookFlash.c | 1098 ext_flash_open_read_sample(255 - aRxBuffer[0], &sampleTotalLength); |
1103 while(sampleTotalLength >= 128) | 1099 while(sampleTotalLength >= 128) |
1104 { | 1100 { |
1105 ext_flash_read_next_sample_part(aTxBuffer,128); | 1101 ext_flash_read_next_sample_part(aTxBuffer,128); |
1106 sampleTotalLength -= 128; | 1102 sampleTotalLength -= 128; |
1107 if(HAL_UART_Transmit(&UartHandle, (uint8_t*)aTxBuffer, 128,5000)!= HAL_OK) | 1103 if(HAL_UART_Transmit(&UartHandle, (uint8_t*)aTxBuffer, 128,5000)!= HAL_OK) |
1241 | 1237 |
1242 | 1238 |
1243 uint8_t receive_update_data_cpu2_sub(uint8_t* pBuffer) | 1239 uint8_t receive_update_data_cpu2_sub(uint8_t* pBuffer) |
1244 { | 1240 { |
1245 uint8_t sBuffer[10]; | 1241 uint8_t sBuffer[10]; |
1246 uint32_t length, offsetTotal, pruefsumme, pruefsummeCalc; | 1242 uint32_t length, offsetTotal, checksum, checksumCalc; |
1247 uint8_t id; | 1243 uint8_t id; |
1248 const uint8_t id_RTE = 0xFE; | 1244 const uint8_t id_RTE = 0xFE; |
1249 | 1245 |
1250 //Get length | 1246 //Get length |
1251 if(HAL_UART_Receive(&UartHandle, pBuffer, 4,5000)!= HAL_OK) // 58000 | 1247 if(HAL_UART_Receive(&UartHandle, pBuffer, 4,5000)!= HAL_OK) // 58000 |
1260 return 0; | 1256 return 0; |
1261 } | 1257 } |
1262 id = pBuffer[0]; | 1258 id = pBuffer[0]; |
1263 offsetTotal = 256 * 256 * 256 * (uint32_t)pBuffer[0] + 256 * 256 * (uint32_t)pBuffer[1] + 256 * (uint32_t)pBuffer[2] + pBuffer[3]; | 1259 offsetTotal = 256 * 256 * 256 * (uint32_t)pBuffer[0] + 256 * 256 * (uint32_t)pBuffer[1] + 256 * (uint32_t)pBuffer[2] + pBuffer[3]; |
1264 | 1260 |
1265 // get pruefsumme, bytes are in different order on Dev C++ code!!! | 1261 // get checksum, bytes are in different order on Dev C++ code!!! |
1266 if(HAL_UART_Receive(&UartHandle, sBuffer, 4,5000)!= HAL_OK) // 58000 | 1262 if(HAL_UART_Receive(&UartHandle, sBuffer, 4,5000)!= HAL_OK) // 58000 |
1267 { | 1263 { |
1268 return 0; | 1264 return 0; |
1269 } | 1265 } |
1270 pruefsumme = 256 * 256 * 256 * (uint32_t)sBuffer[3] + 256 * 256 * (uint32_t)sBuffer[2] + 256 * (uint32_t)sBuffer[1] + sBuffer[0]; | 1266 checksum = 256 * 256 * 256 * (uint32_t)sBuffer[3] + 256 * 256 * (uint32_t)sBuffer[2] + 256 * (uint32_t)sBuffer[1] + sBuffer[0]; |
1271 pruefsummeCalc = length + offsetTotal; | 1267 checksumCalc = length + offsetTotal; |
1272 | 1268 |
1273 // no need to get code if pruefsumme == length is wrong | 1269 // no need to get code if checksum == length is wrong |
1274 if(pruefsummeCalc != pruefsumme) | 1270 if(checksumCalc != checksum) |
1275 { | 1271 { |
1276 return 0; | 1272 return 0; |
1277 } | 1273 } |
1278 | 1274 |
1279 //get Code | 1275 //get Code |
1331 { | 1327 { |
1332 uint8_t answer; | 1328 uint8_t answer; |
1333 | 1329 |
1334 uint8_t* pBuffer1 = (uint8_t*)getFrame(20); | 1330 uint8_t* pBuffer1 = (uint8_t*)getFrame(20); |
1335 | 1331 |
1336 answer = receive_update_data_mainCPU_firmware_subrotuine(1, pBuffer1, 0); | 1332 answer = receive_update_data_mainCPU_firmware_subroutine(1, pBuffer1, 0); |
1337 | 1333 |
1338 releaseFrame(20,(uint32_t)pBuffer1); | 1334 releaseFrame(20,(uint32_t)pBuffer1); |
1339 | 1335 |
1340 return answer; | 1336 return answer; |
1341 } | 1337 } |
1346 uint8_t answer; | 1342 uint8_t answer; |
1347 | 1343 |
1348 uint8_t* pBuffer1 = (uint8_t*)getFrame(20); | 1344 uint8_t* pBuffer1 = (uint8_t*)getFrame(20); |
1349 uint8_t* pBuffer2 = (uint8_t*)getFrame(20); | 1345 uint8_t* pBuffer2 = (uint8_t*)getFrame(20); |
1350 | 1346 |
1351 answer = receive_update_data_mainCPU_firmware_subrotuine(2, pBuffer1, pBuffer2); | 1347 answer = receive_update_data_mainCPU_firmware_subroutine(2, pBuffer1, pBuffer2); |
1352 | 1348 |
1353 releaseFrame(20,(uint32_t)pBuffer1); | 1349 releaseFrame(20,(uint32_t)pBuffer1); |
1354 releaseFrame(20,(uint32_t)pBuffer2); | 1350 releaseFrame(20,(uint32_t)pBuffer2); |
1355 | 1351 |
1356 return answer; | 1352 return answer; |
1359 uint8_t receive_update_data_flex(uint8_t* pBuffer1, uint8_t* pBuffer2, uint8_t RTEupdateALLOWED) | 1355 uint8_t receive_update_data_flex(uint8_t* pBuffer1, uint8_t* pBuffer2, uint8_t RTEupdateALLOWED) |
1360 { | 1356 { |
1361 uint8_t sBuffer[10]; | 1357 uint8_t sBuffer[10]; |
1362 uint8_t serialBuffer[10]; | 1358 uint8_t serialBuffer[10]; |
1363 uint32_t length1, length2, lengthCompare, offsetCompare, ByteCompareStatus; | 1359 uint32_t length1, length2, lengthCompare, offsetCompare, ByteCompareStatus; |
1364 uint32_t lengthTotal, offsetTotal, pruefsumme, pruefsummeCalc; | 1360 uint32_t lengthTotal, offsetTotal; |
1365 uint32_t checksum, checksumCalc = 0; | 1361 uint32_t checksum, checksumCalc = 0; |
1366 uint8_t id; | 1362 uint8_t id; |
1367 const uint8_t id_Region1_firmware = 0xFF; | 1363 const uint8_t id_Region1_firmware = 0xFF; |
1368 const uint8_t id_RTE = 0xFE; | 1364 const uint8_t id_RTE = 0xFE; |
1369 uint8_t textpointer = 0; | 1365 uint8_t textpointer = 0; |
1380 { | 1376 { |
1381 return 0; | 1377 return 0; |
1382 } | 1378 } |
1383 id = sBuffer[0]; | 1379 id = sBuffer[0]; |
1384 | 1380 |
1385 pruefsummeCalc = 256 * 256 * 256 * (uint32_t)sBuffer[0] + 256 * 256 * (uint32_t)sBuffer[1] + 256 * (uint32_t)sBuffer[2] + sBuffer[3]; | 1381 checksumCalc = 256 * 256 * 256 * (uint32_t)sBuffer[0] + 256 * 256 * (uint32_t)sBuffer[1] + 256 * (uint32_t)sBuffer[2] + sBuffer[3]; |
1386 pruefsummeCalc += lengthTotal; | 1382 checksumCalc += lengthTotal; |
1387 //alt, geht nicht mehr wegen Font: pruefsummeCalc = lengthTotal + offsetTotal; | 1383 //old, does no longer work because of the fonts: checksumCalc = lengthTotal + offsetTotal; |
1388 | 1384 |
1389 if((id != id_Region1_firmware) && (id != id_RTE) && (id != id_FONT) && (id != id_FONT_OLD)) | 1385 if((id != id_Region1_firmware) && (id != id_RTE) && (id != id_FONT) && (id != id_FONT_OLD)) |
1390 { | 1386 { |
1391 return 0; | 1387 return 0; |
1392 } | 1388 } |
1395 if(id == id_FONT) | 1391 if(id == id_FONT) |
1396 offsetTotal = 256 * 256 * 256 * (uint32_t)sBuffer[1] + 256 * 256 * (uint32_t)sBuffer[2] + 256 * (uint32_t)sBuffer[3]; | 1392 offsetTotal = 256 * 256 * 256 * (uint32_t)sBuffer[1] + 256 * 256 * (uint32_t)sBuffer[2] + 256 * (uint32_t)sBuffer[3]; |
1397 else | 1393 else |
1398 offsetTotal = 256 * 256 * 256 * (uint32_t)sBuffer[0] + 256 * 256 * (uint32_t)sBuffer[1] + 256 * (uint32_t)sBuffer[2] + sBuffer[3]; | 1394 offsetTotal = 256 * 256 * 256 * (uint32_t)sBuffer[0] + 256 * 256 * (uint32_t)sBuffer[1] + 256 * (uint32_t)sBuffer[2] + sBuffer[3]; |
1399 | 1395 |
1400 // get pruefsumme, bytes are in different order on Dev C++ code!!! | 1396 // get checksum, bytes are in different order on Dev C++ code!!! |
1401 if(HAL_UART_Receive(&UartHandle, sBuffer, 4,5000)!= HAL_OK) // 58000 | 1397 if(HAL_UART_Receive(&UartHandle, sBuffer, 4,5000)!= HAL_OK) // 58000 |
1402 { | 1398 { |
1403 return 0; | 1399 return 0; |
1404 } | 1400 } |
1405 pruefsumme = 256 * 256 * 256 * (uint32_t)sBuffer[3] + 256 * 256 * (uint32_t)sBuffer[2] + 256 * (uint32_t)sBuffer[1] + sBuffer[0]; | 1401 checksum = 256 * 256 * 256 * (uint32_t)sBuffer[3] + 256 * 256 * (uint32_t)sBuffer[2] + 256 * (uint32_t)sBuffer[1] + sBuffer[0]; |
1406 | 1402 |
1407 | 1403 |
1408 if(pruefsummeCalc != pruefsumme) | 1404 if(checksumCalc != checksum) |
1409 { | 1405 { |
1410 uint8_t ptr = 0; | 1406 uint8_t ptr = 0; |
1411 strcpy(&display_text[ptr]," checksum error"); | 1407 strcpy(&display_text[ptr]," checksum error"); |
1412 ptr += 15; | 1408 ptr += 15; |
1413 strcpy(&display_text[ptr],"\n\r"); | 1409 strcpy(&display_text[ptr],"\n\r"); |
1480 */ | 1476 */ |
1481 /* test checksum */ | 1477 /* test checksum */ |
1482 if(checksum != checksumCalc) | 1478 if(checksum != checksumCalc) |
1483 { | 1479 { |
1484 uint8_t ptr = 0; | 1480 uint8_t ptr = 0; |
1485 strcpy(&display_text[ptr]," pruefsummen error"); | 1481 strcpy(&display_text[ptr]," checksum error"); |
1486 ptr += 15; | 1482 ptr += 15; |
1487 strcpy(&display_text[ptr],"\n\r"); | 1483 strcpy(&display_text[ptr],"\n\r"); |
1488 display_text[ptr] = 0; | 1484 display_text[ptr] = 0; |
1489 display_text[255] = ptr + 1; | 1485 display_text[255] = ptr + 1; |
1490 return 0xFF; | 1486 return 0xFF; |
1504 { | 1500 { |
1505 strcpy(&display_text[ptr],"beta "); | 1501 strcpy(&display_text[ptr],"beta "); |
1506 ptr +=5; | 1502 ptr +=5; |
1507 } | 1503 } |
1508 strcpy(&display_text[ptr],"\n\rpreparing for install."); | 1504 strcpy(&display_text[ptr],"\n\rpreparing for install."); |
1509 ptr += 25; // circa ungef�hr | 1505 ptr += 25; |
1510 display_text[255] = ptr + 1; | 1506 display_text[255] = ptr + 1; |
1511 } | 1507 } |
1512 else if(id == id_RTE) | 1508 else if(id == id_RTE) |
1513 { | 1509 { |
1514 if(RTEupdateALLOWED) | 1510 if(RTEupdateALLOWED) |
1542 ptr += 12; | 1538 ptr += 12; |
1543 ptr += gfx_number_to_string(7,0,&display_text[ptr],offsetTotal); | 1539 ptr += gfx_number_to_string(7,0,&display_text[ptr],offsetTotal); |
1544 strcpy(&display_text[ptr]," offset"); | 1540 strcpy(&display_text[ptr]," offset"); |
1545 ptr += 7; | 1541 ptr += 7; |
1546 strcpy(&display_text[ptr],"\n\rpreparing for install."); | 1542 strcpy(&display_text[ptr],"\n\rpreparing for install."); |
1547 ptr += 25; // circa ungef�hr | 1543 ptr += 25; |
1548 display_text[255] = ptr + 1; | 1544 display_text[255] = ptr + 1; |
1549 } | 1545 } |
1550 | 1546 |
1551 | 1547 |
1552 // only non RTE !! | 1548 // only non RTE !! |
1611 return 1; | 1607 return 1; |
1612 } | 1608 } |
1613 } | 1609 } |
1614 | 1610 |
1615 | 1611 |
1616 uint8_t receive_update_data_mainCPU_firmware_subrotuine(uint8_t region, uint8_t* pBuffer1, uint8_t* pBuffer2) | 1612 uint8_t receive_update_data_mainCPU_firmware_subroutine(uint8_t region, uint8_t* pBuffer1, uint8_t* pBuffer2) |
1617 { | 1613 { |
1618 uint8_t sBuffer[10]; | 1614 uint8_t sBuffer[10]; |
1619 uint32_t length1, length2, lengthCompare, offsetCompare, ByteCompareStatus; | 1615 uint32_t length1, length2, lengthCompare, offsetCompare, ByteCompareStatus; |
1620 uint32_t lengthTotal, offsetTotal, pruefsumme, pruefsummeCalc; | 1616 uint32_t lengthTotal, offsetTotal, checksum, checksumCalc = 0; |
1621 uint32_t checksum, checksumCalc; | |
1622 uint8_t id; | 1617 uint8_t id; |
1623 | |
1624 checksumCalc = 0; | |
1625 | 1618 |
1626 //Get length | 1619 //Get length |
1627 if(HAL_UART_Receive(&UartHandle, sBuffer, 4,5000)!= HAL_OK) // 58000 | 1620 if(HAL_UART_Receive(&UartHandle, sBuffer, 4,5000)!= HAL_OK) // 58000 |
1628 return 0; | 1621 return 0; |
1629 | 1622 |
1633 if(HAL_UART_Receive(&UartHandle, sBuffer, 4,5000)!= HAL_OK) // 58000 | 1626 if(HAL_UART_Receive(&UartHandle, sBuffer, 4,5000)!= HAL_OK) // 58000 |
1634 return 0; | 1627 return 0; |
1635 | 1628 |
1636 id = sBuffer[0]; | 1629 id = sBuffer[0]; |
1637 | 1630 |
1638 pruefsummeCalc = 256 * 256 * 256 * (uint32_t)sBuffer[0] + 256 * 256 * (uint32_t)sBuffer[1] + 256 * (uint32_t)sBuffer[2] + sBuffer[3]; | 1631 checksumCalc = 256 * 256 * 256 * (uint32_t)sBuffer[0] + 256 * 256 * (uint32_t)sBuffer[1] + 256 * (uint32_t)sBuffer[2] + sBuffer[3]; |
1639 pruefsummeCalc += lengthTotal; | 1632 checksumCalc += lengthTotal; |
1640 | 1633 |
1641 if((id != id_Region1_firmware) && (id != id_RTE) && (id != id_FONT) && (id != id_FONT_OLD)) | 1634 if((id != id_Region1_firmware) && (id != id_RTE) && (id != id_FONT) && (id != id_FONT_OLD)) |
1642 return 0; | 1635 return 0; |
1643 | 1636 |
1644 if(id == id_FONT) | 1637 if(id == id_FONT) |
1645 offsetTotal = 256 * 256 * 256 * (uint32_t)sBuffer[1] + 256 * 256 * (uint32_t)sBuffer[2] + 256 * (uint32_t)sBuffer[3]; | 1638 offsetTotal = 256 * 256 * 256 * (uint32_t)sBuffer[1] + 256 * 256 * (uint32_t)sBuffer[2] + 256 * (uint32_t)sBuffer[3]; |
1646 // alt, prior to id for font | 1639 // alt, prior to id for font |
1647 else | 1640 else |
1648 offsetTotal = 256 * 256 * 256 * (uint32_t)sBuffer[0] + 256 * 256 * (uint32_t)sBuffer[1] + 256 * (uint32_t)sBuffer[2] + sBuffer[3]; | 1641 offsetTotal = 256 * 256 * 256 * (uint32_t)sBuffer[0] + 256 * 256 * (uint32_t)sBuffer[1] + 256 * (uint32_t)sBuffer[2] + sBuffer[3]; |
1649 | 1642 |
1650 // get pruefsumme, bytes are in different order on Dev C++ code!!! | 1643 // get checksum, bytes are in different order on Dev C++ code!!! |
1651 if(HAL_UART_Receive(&UartHandle, sBuffer, 4,5000)!= HAL_OK) // 58000 | 1644 if(HAL_UART_Receive(&UartHandle, sBuffer, 4,5000)!= HAL_OK) // 58000 |
1652 return 0; | 1645 return 0; |
1653 | 1646 |
1654 pruefsumme = 256 * 256 * 256 * (uint32_t)sBuffer[3] + 256 * 256 * (uint32_t)sBuffer[2] + 256 * (uint32_t)sBuffer[1] + sBuffer[0]; | 1647 checksum = 256 * 256 * 256 * (uint32_t)sBuffer[3] + 256 * 256 * (uint32_t)sBuffer[2] + 256 * (uint32_t)sBuffer[1] + sBuffer[0]; |
1655 | 1648 |
1656 //alt: pruefsummeCalc = lengthTotal + offsetTotal; | 1649 //old: checksumCalc = lengthTotal + offsetTotal; |
1657 | 1650 |
1658 if(pruefsummeCalc != pruefsumme) | 1651 if(checksumCalc != checksum) |
1659 { | 1652 { |
1660 uint8_t ptr = 0; | 1653 uint8_t ptr = 0; |
1661 strcpy(&display_text[ptr]," checksum error"); | 1654 strcpy(&display_text[ptr]," checksum error"); |
1662 ptr += 15; | 1655 ptr += 15; |
1663 strcpy(&display_text[ptr],"\n\r"); | 1656 strcpy(&display_text[ptr],"\n\r"); |
1741 ptr += 12; | 1734 ptr += 12; |
1742 ptr += gfx_number_to_string(7,0,&display_text[ptr],offsetTotal); | 1735 ptr += gfx_number_to_string(7,0,&display_text[ptr],offsetTotal); |
1743 strcpy(&display_text[ptr]," offset"); | 1736 strcpy(&display_text[ptr]," offset"); |
1744 ptr += 7; | 1737 ptr += 7; |
1745 strcpy(&display_text[ptr],"\n\rpreparing for install."); | 1738 strcpy(&display_text[ptr],"\n\rpreparing for install."); |
1746 ptr += 25; // circa ungef�hr | 1739 ptr += 25; |
1747 display_text[255] = ptr + 1; | 1740 display_text[255] = ptr + 1; |
1748 | 1741 |
1749 } | 1742 } |
1750 else | 1743 else |
1751 { | 1744 { |
1761 { | 1754 { |
1762 strcpy(&display_text[ptr],"beta "); | 1755 strcpy(&display_text[ptr],"beta "); |
1763 ptr +=5; | 1756 ptr +=5; |
1764 } | 1757 } |
1765 strcpy(&display_text[ptr],"\n\rpreparing for install."); | 1758 strcpy(&display_text[ptr],"\n\rpreparing for install."); |
1766 ptr += 25; // circa ungef�hr | 1759 ptr += 25; |
1767 display_text[255] = ptr + 1; | 1760 display_text[255] = ptr + 1; |
1768 } | 1761 } |
1769 | 1762 |
1770 uint8_t* pBufferCompare = (uint8_t*)getFrame(20); | 1763 uint8_t* pBufferCompare = (uint8_t*)getFrame(20); |
1771 ByteCompareStatus = 0; | 1764 ByteCompareStatus = 0; |