Skip to content

Address compiler warning in Sketch file #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions examples/PortentaH7Logger/PortentaH7Logger.ino
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ void performUpdate() {
UFile lastUpdateFile = usbRoot.createFile("diff.txt", FileMode::READ); // Create or open the last update file

backingUP = true;
int lastUpdateBytes = lastUpdateFile.readAsString().toInt(); // Read the last update size from the file
unsigned lastUpdateBytes = lastUpdateFile.readAsString().toInt(); // Read the last update size from the file

Serial.print("Last update bytes: "); Serial.println(lastUpdateBytes);

Expand All @@ -97,7 +97,8 @@ void performUpdate() {
unsigned long totalBytesToMove = bytesWritten - lastUpdateBytes;
Serial.print("New update bytes: "); Serial.println(totalBytesToMove);

uint8_t buffer[totalBytesToMove];
uint8_t* buffer = new uint8_t[totalBytesToMove];

size_t bytesRead = logFile.read(buffer, totalBytesToMove);
size_t bytesMoved = backupFile.write(buffer, bytesRead); // Only write the bytes that haven't been backed up yet

Expand All @@ -115,6 +116,7 @@ void performUpdate() {

digitalWrite(USB_MOUNTED_LED, HIGH);
backingUP = false;
delete[] buffer;
}


Expand Down