Skip to content

Commit 6bb89a9

Browse files
Merge pull request #24 from arduino-libraries/partitioning_refactorings
Refactorings
2 parents 07b405d + 1821d32 commit 6bb89a9

File tree

24 files changed

+447
-434
lines changed

24 files changed

+447
-434
lines changed

examples/BackupInternalPartitions/BackupInternalPartitions.ino

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,21 @@
66
77
In the setup function, the code initializes serial communication, and registers a callback for the insertion of the USB Drive.
88
9-
If the device is succesfully mounted, a folder for this instance of a backup will be created on the USB Drive.
9+
If the device is successfully mounted, a folder for this instance of a backup will be created on the USB Drive.
1010
1111
Afterwards the sketch does the following:
1212
- lists all partitions available on the InternalStorage
1313
- mounts each partition
1414
- creates a sub folder for each partition,
15-
- copies everything on that partition to the coresponding subfolder.
15+
- copies everything on that partition to the corresponding subfolder.
1616
1717
The "addSomeFakeFiles" function generates random files in the specified folder, simulating real data.
1818
The "move" function is responsible for transferring folders and files between storage locations.
1919
2020
INSTRUCTIONS
2121
- Make sure you have "POSIXStorage" and "Arduino_UnifiedStorage" installed
2222
- Insert a USB Drive whenever you want
23-
- Wait for the sketch to finish, it will display the following "DONE, you can restart the board now" when succesful
23+
- Wait for the sketch to finish, it will display the following "DONE, you can restart the board now" when successful
2424
- Unplug the USB device and inspect its contents.
2525
2626
Created: 31th August 2023

examples/InternalStoragePartitioning/InternalStoragePartitioning.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
The code defines the following main functions:
1919
1. `testWriting`: This function tests writing to a file in a specified storage partition by creating a file, writing data to it, reading the data, and then removing the file.
2020
2. `testAllPartitions`: This function tests all partitions in a list of partitions by creating an InternalStorage object for each partition, mounting it, and testing file operations within each partition.
21-
3. `listPartitions`: This function reads the MBR sector on the QSPI drive and retrieves the partitioning scheme, if this sketch is succesful it should return exactly the partitioning scheme you created
21+
3. `listPartitions`: This function reads the MBR sector on the QSPI drive and retrieves the partitioning scheme, if this sketch is successful it should return exactly the partitioning scheme you created
2222
2323
2424
INSTRUCTIONS:

examples/Logger/Logger.h

Lines changed: 0 additions & 31 deletions
This file was deleted.

examples/Logger/Logger.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
- If you are using this sketch on an Arduino OPTA, use another board or an USB adaptor to view RS485 messages
1515
- This sketch will log data, and check if there is any USB MSD Device connected to the USB Port of your board.
1616
- Insert a USB Drive whenever you want
17-
- Every 10 seconds data is transfered from the internal storage to the USB Mass storage device
17+
- Every 10 seconds data is transferred from the internal storage to the USB Mass storage device
1818
- Unplug the USB device and inspect its contents.
1919
2020
NOTES: The USB device is mounted and unmounted after every update operation. The first status LED is on when the USB drive is mounted.
@@ -143,7 +143,7 @@ void backupToUSB() {
143143
Folder usbRoot = usbStorage.getRootFolder();
144144
String folderName = "LoggerBackup" + String(random(9999));
145145
backupFolder = usbRoot.createSubfolder(folderName);
146-
printlnToSerialOrRS485("Succesfully created backup folder: " + backupFolder.getPathAsString());
146+
printlnToSerialOrRS485("Successfully created backup folder: " + backupFolder.getPathAsString());
147147
usbStorage.unmount();
148148
usbIntialized = true;
149149
}

extras/tests/TestExisting/TestExisting.ino

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
#include <Arduino_UnifiedStorage.h>
2+
#include "Utils.h"
3+
4+
#define ARDUINO_UNIFIED_STORAGE_DEBUG
25

36

47
InternalStorage internalStorage = InternalStorage();
@@ -25,26 +28,26 @@ void setup() {
2528

2629

2730
// Test copyTo
28-
printToSerialOrRS485("Testing copyTo... \n");
31+
debugPrint("Testing copyTo...");
2932
Folder sourceFolder2 = root.createSubfolder("source_folder");
30-
printToSerialOrRS485("Folder 1 created \n");
33+
debugPrint("Folder 1 created");
3134

32-
printToSerialOrRS485("Trying to create a folder on top of an existing one... without overwrite \n");
35+
debugPrint("Trying to create a folder on top of an existing one... without overwrite");
3336
Folder sourceFolder3 = root.createSubfolder("source_folder");
3437

35-
printToSerialOrRS485("Trying to create a folder on top of an existing one... with overwrite \n");
38+
debugPrint("Trying to create a folder on top of an existing one... with overwrite");
3639
Folder sourceFolder4 = root.createSubfolder("source_folder", true);
3740

3841
Folder destinationFolder2 = root.createSubfolder("destination_folder");
39-
printToSerialOrRS485("Folder 2 created \n");
42+
debugPrint("Folder 2 created");
4043

4144

4245

4346
bool copyResult = sourceFolder2.copyTo(destinationFolder2, true); // Overwrite if exists
4447
if (copyResult) {
45-
printToSerialOrRS485("Copy successful \n");
48+
debugPrint("Copy successful");
4649
} else {
47-
printToSerialOrRS485("Copy failed \n");
50+
debugPrint("Copy failed");
4851
}
4952

5053

@@ -54,12 +57,12 @@ void setup() {
5457
Folder sourceFolder = root.createSubfolder("source");
5558
Folder destinationFolder = root.createSubfolder("destination");
5659

57-
printToSerialOrRS485("Testing moveTo... \n");
60+
debugPrint("Testing moveTo... ");
5861
bool moveResult = sourceFolder.moveTo(destinationFolder, true); // Overwrite if exists
5962
if (moveResult) {
60-
printToSerialOrRS485("Move successful \n");
63+
debugPrint("Move successful");
6164
} else {
62-
printToSerialOrRS485("Move failed \n");
65+
debugPrint("Move failed");
6366
}
6467

6568

@@ -73,10 +76,10 @@ void setup() {
7376

7477

7578
bool success = someFile.copyTo(someOtherFolder);
76-
printToSerialOrRS485("trying to copy file without overwrite: %d\n", success);
79+
debugPrint("trying to copy file without overwrite: %d", success);
7780

7881
success = someFile.copyTo(someOtherFolder,true);
79-
printToSerialOrRS485("trying to copy file with overwrite: %d \n", success);
82+
debugPrint("trying to copy file with overwrite: %d ", success);
8083

8184
}
8285

0 commit comments

Comments
 (0)