![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Fork to see if I can get working
Dependencies: BufferedSerial OneWire WinbondSPIFlash libxDot-dev-mbed5-deprecated
Fork of xDotBridge_update_test20180823 by
Diff: xDotBridge/src/SerialTermMgr.cpp
- Revision:
- 92:1f86edb14cbe
- Parent:
- 91:8196900df6fe
- Child:
- 93:f3adc409c54e
--- a/xDotBridge/src/SerialTermMgr.cpp Sat Nov 18 18:01:43 2017 -0700 +++ b/xDotBridge/src/SerialTermMgr.cpp Tue Nov 21 16:07:54 2017 -0700 @@ -7,7 +7,6 @@ #include "SerialTermMgr.h" #include "UserInterface.h" -//#include "bootloader.h" extern Serial pc; const char ACK = 0x06; @@ -88,11 +87,11 @@ case '2': mCurrScreen = enterProgModeScreenId; break; + case '3': + mPc->printf("\r\nNot implemented yet.\r\n"); +// mCurrScreen = settingsScreenId; + break; // Future -// case '3': -// mPc->printf("\r\nNot implemented yet.\r\n"); -//// mCurrScreen = settingsScreenId; -// break; // case '4': // mPc->printf("\r\nNot implemented yet.\r\n"); //// mCurrScreen = statsScreenId; @@ -136,8 +135,8 @@ mPc->printf("= 0: Refresh (Enter and space also work) =\r\n"); mPc->printf("= 1: General information =\r\n"); mPc->printf("= 2: Enter programming mode =\r\n"); + mPc->printf("= 3: Settings =\r\n"); // Future -// mPc->printf("= 3: Settings =\r\n"); // mPc->printf("= 4: Statistics =\r\n"); // mPc->printf("= 5: Error log =\r\n"); // mPc->printf("= 6: Live log =\r\n"); @@ -260,22 +259,42 @@ pc.printf("Programming timed out.\r\n"); break; } - } if (mPc->readable()) { packetBuf[pktIdx++] = mPc->getc(); if (pktIdx == 1 && packetBuf[0] == EOT) { lastValidInput = time(NULL); mPc->printf("%c", ACK); // Last ACK - mPc->printf("Success.\r\n"); - pc.printf("Success on xmodem. Reset in progress.\r\n"); - writeBootloaderCtrlPage(packetNum*XMODEM_PACKET_SIZE); -// copyNewProgram(); + + // Check for update string in last packet + bool foundKey; + for (int packetIdx=3;packetIdx<sizeof(packetBuf)-sizeof(VORTEX_UPDATE_KEY);packetIdx++) { + foundKey = true; + for (int i=0;i<sizeof(VORTEX_UPDATE_KEY);i++) { + if (packetBuf[packetIdx+i] != VORTEX_UPDATE_KEY[i]) { + foundKey = false; + break; + } + } + if (foundKey) { + break; + } + } + if (foundKey) { + mPc->printf("Success.\r\n"); + pc.printf("Success on xmodem. Reset in progress.\r\n"); + writeBootloaderCtrlPage(packetNum*XMODEM_PACKET_SIZE); + } + else { + mPc->printf("Failed update key validation.\r\n"); + pc.printf("Failed update key validation\r\n"); + } wait(0.01); mFlash->powerDown(); - NVIC_SystemReset(); - // Should never get here because of reset. + if (foundKey) { + NVIC_SystemReset(); + } break; } else if (pktIdx >= 132) { @@ -287,8 +306,9 @@ } pktIdx = 0; if ((csum == packetBuf[131]) && (packetBuf[0] == SOH) && - (packetBuf[1] == ((uint8_t)packetNum)) && (((uint8_t)~packetBuf[2]) == ((uint8_t)packetNum))) { - mFlash->writeStream(FLASH_BIN_OFFSET+(packetNum-1)*XMODEM_PACKET_SIZE, packetBuf+3, XMODEM_PACKET_SIZE); + (packetBuf[1] == ((uint8_t)packetNum)) && (((uint8_t)~packetBuf[2]) == ((uint8_t)packetNum))) { + mFlash->writeStream(FLASH_BIN_OFFSET+(packetNum-1)*XMODEM_PACKET_SIZE, packetBuf+3, + XMODEM_PACKET_SIZE); mPc->printf("%c", ACK); packetNum++; }