Skip to content

Commit

Permalink
Adjusted sendCommand Method
Browse files Browse the repository at this point in the history
  • Loading branch information
chezlyne committed Jan 15, 2024
1 parent 24eba00 commit 947ce9d
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 26 deletions.
32 changes: 25 additions & 7 deletions lib/ZumoOta/src/FlashManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ const uint8_t NEXT_SERIAL_SEND_DELAY_MS = 10;
/******************************************************************************
* Local Variables
*****************************************************************************/
const uint16_t WAIT_TIME_MS = 500U;
/*Delay before processing the response.
const uint8_t AWAIT_RESPONSE_DELAY_MS = 50U;*/

/** Specifies the number of bytes stored in one Zumo bootloader/flash memory page.*/
static const uint16_t PAGE_SIZE_BYTES = 128U;
Expand All @@ -80,10 +81,10 @@ FlashManager::~FlashManager()
{
}

void FlashManager::readToRobotFlash(size_t expectedsize)
bool FlashManager::readToRobotFlash(size_t expectedsize)
{
bool retCode = false;
Stream& deviceStream = Board::getInstance().getDevice().getStream();
Board::getInstance().getDevice().process();
int availableBytes = deviceStream.available();
if (0 < availableBytes)

Expand Down Expand Up @@ -114,23 +115,40 @@ void FlashManager::readToRobotFlash(size_t expectedsize)
Serial.print(" ");
}
Serial.println();
retCode = true;
}
else
{
LOG_INFO("Failure!");
}
}
return retCode;

}

void FlashManager ::sendCommand(const uint8_t command[])
{
const uint16_t WRITE_BUFFER_SIZE = 256;
uint8_t writeBuffer[WRITE_BUFFER_SIZE];
Stream& deviceStream = Board::getInstance().getDevice().getStream();
size_t commandsize = sizeof(command[0]);
size_t mysize= deviceStream.write(command, commandsize);

readToRobotFlash(mysize);
/*Size of array*/
size_t commandsize = sizeof(command);
/* Copy the command OpCode into buffer */
memcpy(writeBuffer, command, commandsize);

/* Send the OpCode and command data to Zumo robot */
size_t bytesWritten= deviceStream.write(command, commandsize);

if(bytesWritten == commandsize)
{
/* Await response */
delay(50);
readToRobotFlash(commandsize);
}
else
{
LOG_ERROR("Could not send data packet to Zumo robot. Aborting now");
}
}

void FlashManager:: enterBootloadermode()
Expand Down
2 changes: 1 addition & 1 deletion lib/ZumoOta/src/FlashManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class FlashManager
* This function reads data from the provided stream and writes it to
* the robot's flash memory.
*/
void readToRobotFlash(size_t expectedsize);
bool readToRobotFlash(size_t expectedsize);

/**
* @brief exit the bootloader mode.
Expand Down
16 changes: 0 additions & 16 deletions lib/ZumoOta/src/WebServerCustom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,6 @@ void WebServerCustom::init()
}
});

/*server.on("/changeProfile", HTTP_GET, [](AsyncWebServerRequest *request)
{
request->send(LittleFS, "/login.html","text/html");
});*/





server.on("/uploadFirmware", HTTP_GET, [](AsyncWebServerRequest *request)
{
Expand All @@ -190,13 +181,6 @@ void WebServerCustom::init()
});


/*server.on("/performFirmwareUpdate", HTTP_POST, [](AsyncWebServerRequest* request)
{
{
request->send(200, "text/plain", "Firmware update successful!");
}
});*/



Expand Down
5 changes: 3 additions & 2 deletions lib/ZumoOta/src/Zumo32U4Specifications.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ namespace Zumo32U4Specification
/** Command for reading the software ID */
static const uint8_t READ_SW_ID_COMMAND[] = {0x53};

/** Command for reading the software version *
/** Command for reading the software version */
static const uint8_t READ_SW_VERSION[] = {0x56};

/** Command for reading the hardware version */
Expand Down Expand Up @@ -129,7 +129,6 @@ namespace Zumo32U4Specification
/** The expected bootloader ID string */
static const uint8_t EXPECTED_SOFTWARE_ID[] = {'C', 'A', 'T', 'E', 'R', 'I', 'N', '\0'};


/** The expected bootloader version */

static const uint8_t EXPECTED_SW_VERSION[] = {0x31, 0x30};
Expand Down Expand Up @@ -161,4 +160,6 @@ namespace Zumo32U4Specification
/** The expected signature value */
static const uint8_t EXPECTED_SIGNATURE[] = {0x87, 0x95, 0x1E};
};

#endif /** __ZUMO32U4Specification_H__ */
/** @} */

0 comments on commit 947ce9d

Please sign in to comment.