Skip to content

Integrate new features #25

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 50 commits into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
21e28f1
added opta fixes, using latest POSIXStorage lib
cristidragomir97 Oct 3, 2023
083b2ce
added opta logger
cristidragomir97 Oct 4, 2023
12b6e76
added partitioning, did 'some' refactoring
cristidragomir97 Oct 12, 2023
f783e81
added full refactorings, but it fails to build for now
cristidragomir97 Oct 12, 2023
a5f54ee
fixed issues caused by refactorings
cristidragomir97 Oct 23, 2023
38f181d
Merge pull request #1 from cristidragomir97/refactorings
cristidragomir97 Oct 23, 2023
17f9203
Merge branch 'arduino-libraries:main' into main
cristidragomir97 Oct 23, 2023
541952e
added readPartitions, unified Logger for C33, H7 and opta
cristidragomir97 Oct 25, 2023
02e852f
fixed examples
cristidragomir97 Oct 26, 2023
07b405d
refactoring partitioning
cristidragomir97 Oct 26, 2023
9cd7a6e
Improve formatting
sebromero Oct 26, 2023
6d677f6
Improve documentation
sebromero Oct 26, 2023
bb22d70
Refactor variable name
sebromero Oct 26, 2023
f107ae1
Report success only if all partitions are correctly formatted
sebromero Oct 26, 2023
4e7931f
Simplify code by using guard clauses
sebromero Oct 26, 2023
b0a5061
Rename variable
sebromero Oct 26, 2023
5ee1f70
Remove unused code
sebromero Oct 26, 2023
852ef17
Add documentation
sebromero Oct 26, 2023
0331227
Simplify code
sebromero Oct 26, 2023
7024428
Remove superfluous empty lines
sebromero Oct 26, 2023
df9c8b6
Simplify code by using guard clauses
sebromero Oct 26, 2023
2ce00cd
Fix compiler warnings
sebromero Oct 26, 2023
6103551
Revert calls to printToSerialOrRS485
sebromero Oct 26, 2023
3d332ea
Use board config instead of custom defines
sebromero Oct 26, 2023
dd83662
Fix spelling mistakes
sebromero Oct 26, 2023
be4f8b0
Add missing return statements
sebromero Oct 27, 2023
99ffb53
Fix incorrect reference
sebromero Oct 27, 2023
688059b
Replace printToSerialOrRS485 with debugPrint
sebromero Oct 27, 2023
1940f36
Add missing import
sebromero Oct 27, 2023
1821d32
Use Boards file instead of redefining board features
sebromero Oct 27, 2023
6bb89a9
Merge pull request #24 from arduino-libraries/partitioning_refactorings
cristidragomir97 Oct 27, 2023
638a5ba
fixes on tests
cristidragomir97 Oct 27, 2023
79bbd80
added RS485 dependency in gituhub actions, fixed unused methods from …
cristidragomir97 Oct 27, 2023
817aeae
updated RS485 dependency in github action
cristidragomir97 Oct 27, 2023
943a875
fixes and tweaks
cristidragomir97 Oct 30, 2023
ac8699a
added debugPrint statements everywhere
cristidragomir97 Oct 31, 2023
2ea7e0c
fixed warningins
cristidragomir97 Oct 31, 2023
722bf6e
fixed bug on first-time internal storage usage
cristidragomir97 Nov 2, 2023
9f2b611
implemented static bool for logging
cristidragomir97 Nov 3, 2023
7f2e8e3
fixed logging
cristidragomir97 Nov 3, 2023
3b5be8d
cleaned up examples, fixed RS485, fixed spelling errors
cristidragomir97 Nov 3, 2023
4200218
updated readme and docs
cristidragomir97 Nov 3, 2023
26c8b0b
Update README.md
cristidragomir97 Nov 3, 2023
3a80cc5
Update Partitioning.cpp to skip partitions of 0x0B type that have 0 b…
cristidragomir97 Nov 6, 2023
08910eb
Update Partitioning.cpp to avoid empty partitions
cristidragomir97 Nov 6, 2023
50fb1fc
Readme improvements
aliphys Nov 7, 2023
b5b21e1
cosmetic and consistency fixes
cristidragomir97 Nov 7, 2023
9089fa7
Merge branch 'main' into partitioning_callbacks_opta
sebromero Nov 8, 2023
a10bdc8
Change storage variable name in example
sebromero Nov 8, 2023
9948840
Bump version number
sebromero Nov 8, 2023
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
Prev Previous commit
Next Next commit
fixed logging
  • Loading branch information
cristidragomir97 committed Nov 3, 2023
commit 7f2e8e305b793b784f4da7b0ac1ad8ba8c008e8c
28 changes: 14 additions & 14 deletions examples/Logger/Logger.ino
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ void performUpdate() {
backingUP = true;
unsigned lastUpdateBytes = lastUpdateFile.readAsString().toInt(); // Read the last update size from the file

debugPrint("Last update bytes: " + String(lastUpdateBytes));
Arduino_UnifiedStorage::debugPrint("Last update bytes: " + String(lastUpdateBytes));

if (lastUpdateBytes >= bytesWritten) {
debugPrint("No new data to copy. ");
Arduino_UnifiedStorage::debugPrint("No new data to copy. ");
backupFile.close();
lastUpdateFile.close();
backingUP = false;
Expand All @@ -109,14 +109,14 @@ void performUpdate() {

logFile.seek(lastUpdateBytes); // Move the file pointer to the last update position
unsigned long totalBytesToMove = bytesWritten - lastUpdateBytes;
debugPrint("New update bytes: " + String(totalBytesToMove));
Arduino_UnifiedStorage::debugPrint("New update bytes: " + String(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

debugPrint("Successfully copied " + String(bytesMoved) + " new bytes. ");
Arduino_UnifiedStorage::debugPrint("Successfully copied " + String(bytesMoved) + " new bytes. ");

lastUpdateFile.changeMode(FileMode::WRITE); // Open the last update file in write mode
lastUpdateFile.write(String(lastUpdateBytes + bytesMoved)); // Update the last update size
Expand All @@ -138,32 +138,32 @@ void performUpdate() {
void backupToUSB() {
if(usbAvailable && !usbIntialized){
usbStorage.begin();
debugPrint("First drive insertion, creating folders... ");
Arduino_UnifiedStorage::debugPrint("First drive insertion, creating folders... ");
Folder usbRoot = usbStorage.getRootFolder();
String folderName = "LoggerBackup" + String(random(9999));
backupFolder = usbRoot.createSubfolder(folderName);
debugPrint("Successfully created backup folder: " + backupFolder.getPathAsString());
Arduino_UnifiedStorage::debugPrint("Successfully created backup folder: " + backupFolder.getPathAsString());
usbStorage.unmount();
usbIntialized = true;
}
else if(usbAvailable && usbIntialized) {
debugPrint("USB Mass storage is available ");
Arduino_UnifiedStorage::debugPrint("USB Mass storage is available ");
delay(100);
if (!usbStorage.isMounted()) {

debugPrint("Mounting USB Mass Storage ");
Arduino_UnifiedStorage::debugPrint("Mounting USB Mass Storage ");
digitalWrite(USB_MOUNTED_LED, LOW);
if(usbStorage.begin()){
performUpdate();
}

} else if (usbStorage.isMounted()) {
debugPrint("USB Mass storage is connected, performing update ");
Arduino_UnifiedStorage::debugPrint("USB Mass storage is connected, performing update ");
performUpdate();

}
} else {
debugPrint("USB Mass storage is not available ");
Arduino_UnifiedStorage::debugPrint("USB Mass storage is not available ");
}


Expand All @@ -185,17 +185,17 @@ void setup() {
usbStorage.onDisconnect(disconnectionCallback);

pinMode(USB_MOUNTED_LED, OUTPUT);
debugPrint("Formatting internal storage... ");
Arduino_UnifiedStorage::debugPrint("Formatting internal storage... ");
int formatted = internalStorage.format(FS_LITTLEFS);
debugPrint("QSPI Format status: " + String(formatted));
Arduino_UnifiedStorage::debugPrint("QSPI Format status: " + String(formatted));



if (!internalStorage.begin()) {
debugPrint("Failed to initialize internal storage ");
Arduino_UnifiedStorage::debugPrint("Failed to initialize internal storage ");
return;
} else {
debugPrint("Initialized storage ");
Arduino_UnifiedStorage::debugPrint("Initialized storage ");
}

}
Expand Down
24 changes: 12 additions & 12 deletions extras/tests/TestExisting/TestExisting.ino
Original file line number Diff line number Diff line change
Expand Up @@ -26,42 +26,42 @@ void setup() {


// Test copyTo
debugPrint("Testing copyTo...");
Arduino_UnifiedStorage::debugPrint("Testing copyTo...");
Folder sourceFolder2 = root.createSubfolder("source_folder");
debugPrint("Folder 1 created");
Arduino_UnifiedStorage::debugPrint("Folder 1 created");

debugPrint("Trying to create a folder on top of an existing one... without overwrite");
Arduino_UnifiedStorage::debugPrint("Trying to create a folder on top of an existing one... without overwrite");
Folder sourceFolder3 = root.createSubfolder("source_folder");


debugPrint("Trying to create a folder on top of an existing one... with overwrite");
Arduino_UnifiedStorage::debugPrint("Trying to create a folder on top of an existing one... with overwrite");
Folder sourceFolder4 = root.createSubfolder("source_folder", true);



Folder destinationFolder2 = root.createSubfolder("destination_folder");
debugPrint("Folder 2 created");
Arduino_UnifiedStorage::debugPrint("Folder 2 created");



bool copyResult = sourceFolder2.copyTo(destinationFolder2, true); // Overwrite if exists
if (copyResult) {
debugPrint("Copy successful");
Arduino_UnifiedStorage::debugPrint("Copy successful");
} else {
debugPrint("Copy failed");
Arduino_UnifiedStorage::debugPrint("Copy failed");
}


// Test moveTo
Folder sourceFolder = root.createSubfolder("source");
Folder destinationFolder = root.createSubfolder("destination");

debugPrint("Testing moveTo... ");
Arduino_UnifiedStorage::debugPrint("Testing moveTo... ");
bool moveResult = sourceFolder.moveTo(destinationFolder, true); // Overwrite if exists
if (moveResult) {
debugPrint("Move successful");
Arduino_UnifiedStorage::debugPrint("Move successful");
} else {
debugPrint("Move failed");
Arduino_UnifiedStorage::debugPrint("Move failed");
}


Expand All @@ -75,10 +75,10 @@ void setup() {


bool success = someFile.copyTo(someOtherFolder);
debugPrint("trying to copy file without overwrite: " + String(success));
Arduino_UnifiedStorage::debugPrint("trying to copy file without overwrite: " + String(success));

success = someFile.copyTo(someOtherFolder,true);
debugPrint("trying to copy file with overwrite: " + String(success));
Arduino_UnifiedStorage::debugPrint("trying to copy file with overwrite: " + String(success));

}

Expand Down
Loading