![](/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:
- 91:8196900df6fe
- Parent:
- 78:43f074baac34
- Child:
- 92:1f86edb14cbe
--- a/xDotBridge/src/SerialTermMgr.cpp Sat Nov 18 22:58:20 2017 +0000 +++ b/xDotBridge/src/SerialTermMgr.cpp Sat Nov 18 18:01:43 2017 -0700 @@ -7,7 +7,7 @@ #include "SerialTermMgr.h" #include "UserInterface.h" -#include "bootloader.h" +//#include "bootloader.h" extern Serial pc; const char ACK = 0x06; @@ -86,28 +86,29 @@ mCurrScreen = genInfoScreenId; break; case '2': - mPc->printf("\r\nNot implemented yet.\r\n"); -// mCurrScreen = settingsScreenId; - break; - case '3': - mPc->printf("\r\nNot implemented yet.\r\n"); -// mCurrScreen = statsScreenId; - break; - case '4': - mPc->printf("\r\nNot implemented yet.\r\n"); -// mCurrScreen = errorLogScreenId; - break; - case '5': - mPc->printf("\r\nNot implemented yet.\r\n"); -// mCurrScreen = liveLogScreenId; - break; - case '6': - mPc->printf("\r\nNot implemented yet.\r\n"); -// mCurrScreen = enterSerialBridgeScreenId; - break; - case '7': mCurrScreen = enterProgModeScreenId; 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; +// break; +// case '5': +// mPc->printf("\r\nNot implemented yet.\r\n"); +//// mCurrScreen = errorLogScreenId; +// break; +// case '6': +// mPc->printf("\r\nNot implemented yet.\r\n"); +//// mCurrScreen = liveLogScreenId; +// break; +// case '7': +// mPc->printf("\r\nNot implemented yet.\r\n"); +//// mCurrScreen = enterSerialBridgeScreenId; +// break; case 0x11: // ctrl-q quit=true; break; @@ -134,12 +135,13 @@ mPc->printf("===============================================\r\n"); mPc->printf("= 0: Refresh (Enter and space also work) =\r\n"); mPc->printf("= 1: General information =\r\n"); - mPc->printf("= 2: Settings =\r\n"); - mPc->printf("= 3: Statistics =\r\n"); - mPc->printf("= 4: Error log =\r\n"); - mPc->printf("= 5: Live log =\r\n"); - mPc->printf("= 6: Enter serial bridge mode =\r\n"); - mPc->printf("= 7: Enter programming mode =\r\n"); + mPc->printf("= 2: Enter programming mode =\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"); +// mPc->printf("= 7: Enter serial bridge mode =\r\n"); mPc->printf("= <ctrl>-q: Exit terminal =\r\n"); mPc->printf("===============================================\r\n"); } @@ -149,7 +151,7 @@ return; } switch (in) { - case 0x1B: + case 0x1B: // esc mCurrScreen = mainScreenId; break; case 'r': @@ -181,10 +183,10 @@ "Normally closed"); mPc->printf("= WB Mode: %s =\r\n", mBbio->isTx() ? "Transmitter" : "Receiver "); - mPc->printf("= Comm Mode: %s =\r\n", mBbio->isLoRaWANMode() ? "LoRaWAN " : - "Peer-to-peer"); - mPc->printf("= Serial Mode: %s =\r\n", mBbio->isSerialEnabled() ? "Enabled " : - "Disabled"); +// mPc->printf("= Comm Mode: %s =\r\n", mBbio->isLoRaWANMode() ? "LoRaWAN " : +// "Peer-to-peer"); +// mPc->printf("= Serial Mode: %s =\r\n", mBbio->isSerialEnabled() ? "Enabled " : +// "Disabled"); if (mBbio->isTx()) { mPc->printf("= Currently no rotary switches apply for TX =\r\n"); } @@ -202,7 +204,7 @@ } mPc->printf("\r\n\r\n"); mPc->printf("===============================================\r\n"); - mPc->printf("= Serial Firmware Prog Mode (Esc to return) =\r\n"); + mPc->printf("= Serial Firmware Prog Mode (Esc to return) =\r\n"); mPc->printf("===============================================\r\n"); mPc->printf("===============================================\r\n"); mPc->printf("= To program firmware: \r\n"); @@ -211,7 +213,7 @@ mPc->printf("= 3: In terminal program (such as teraterm) =\r\n"); mPc->printf("= select transfer via XMODEM =\r\n"); mPc->printf("= 4: Programming may take up to a minute =\r\n"); - mPc->printf("= 5: If successful terminal will print \"Success\" =\r\n"); + mPc->printf("= 5: If successful terminal prints \"Success\" =\r\n"); mPc->printf("= 6: Wireless Bridge will then automatically =\r\n"); mPc->printf("= reboot with new firmware. =\r\n"); mPc->printf("===============================================\r\n"); @@ -222,7 +224,7 @@ return; } switch (in) { - case 0x1B: + case 0x1B: // esc: mCurrScreen = mainScreenId; break; case 0x04: @@ -305,11 +307,16 @@ void SerialTermMgr::writeBootloaderCtrlPage(uint32_t nBytes) { // This should always be less than 256 bytes - const unsigned int ctrlSize = sizeof(NEW_CODE)+sizeof(nBytes); + + // Zero updates the bootloader version so that is cleared until the bootloader adds its back + const uint32_t zeroBootloaderVersion = 0; + const unsigned int ctrlSize = sizeof(NEW_CODE)+sizeof(nBytes)+sizeof(zeroBootloaderVersion); char buf[ctrlSize]; std::memcpy(buf, NEW_CODE, sizeof(NEW_CODE)); std::memcpy(buf+sizeof(NEW_CODE), &nBytes, sizeof(nBytes)); - // TODO add reprogram counter just for fun + std::memcpy(buf+sizeof(NEW_CODE)+sizeof(nBytes), + &zeroBootloaderVersion, sizeof(zeroBootloaderVersion)); + // TODO add reprogram counter or other functions // Copy to first page of flash mFlash->writeStream(0, buf, sizeof(buf));