diff --git a/src/oi_can.cpp b/src/oi_can.cpp index 9033e78..f2c7c0a 100644 --- a/src/oi_can.cpp +++ b/src/oi_can.cpp @@ -228,6 +228,9 @@ static void handleUpdate(twai_message_t *rxframe) { updstate = SEND_SIZE; DBG_OUTPUT_PORT.printf("Sending ID %" PRIu32 "\r\n", *(uint32_t*)tx_frame.data); twai_transmit(&tx_frame, pdMS_TO_TICKS(10)); + + if (rxframe->data[1] < 1) //boot loader with timing quirk, wait 100 ms + delay(100); } break; case SEND_SIZE: @@ -317,7 +320,6 @@ static void handleUpdate(twai_message_t *rxframe) { // Do not exit this state break; } - } int StartUpdate(String fileName) { @@ -325,6 +327,8 @@ int StartUpdate(String fileName) { //Reset host processor setValueSdo(SDO_INDEX_COMMANDS, SDO_CMD_RESET, 1U); updstate = SEND_MAGIC; + currentPage = 0; + DBG_OUTPUT_PORT.println("Starting Update"); return (updateFile.size() + PAGE_SIZE_BYTES - 1) / PAGE_SIZE_BYTES; }