Skip to content

Commit 04351b7

Browse files
authored
Merge pull request #11 from alrvid/main
Adds full Opta support
2 parents b0e2846 + e3eff1d commit 04351b7

File tree

5 files changed

+41
-13
lines changed

5 files changed

+41
-13
lines changed

docs/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ The library supports and is tested on:
88
- Portenta H7 with Portenta Breakout Board (SD Card and USB Thumb Drive)
99
- Portenta H7 with Portenta Vision Shield (SD Card)
1010
- Portenta Machine Control (USB Thumb Drive)
11+
- Opta (USB Thumb Drive)
1112

1213

1314
## Usage

extras/tests/Arduino_POSIXStorage_Test/Arduino_POSIXStorage_Test.ino

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ enum TestTypes : uint8_t
1717
TEST_PORTENTA_H7_SDCARD,
1818
TEST_PORTENTA_H7_USB,
1919
TEST_PORTENTA_MACHINE_CONTROL_SDCARD,
20-
TEST_PORTENTA_MACHINE_CONTROL_USB
20+
TEST_PORTENTA_MACHINE_CONTROL_USB,
21+
TEST_OPTA_SDCARD,
22+
TEST_OPTA_USB
2123
};
2224

2325
// !!! TEST CONFIGURATION !!! -->
@@ -45,11 +47,11 @@ void setup() {
4547
int fileDescriptor = 0;
4648
int retVal = -1;
4749

48-
if ((TEST_PORTENTA_C33_USB == selectedTest) || (TEST_PORTENTA_H7_USB == selectedTest) || (TEST_PORTENTA_MACHINE_CONTROL_USB == selectedTest))
50+
if ((TEST_PORTENTA_C33_USB == selectedTest) || (TEST_PORTENTA_H7_USB == selectedTest) || (TEST_PORTENTA_MACHINE_CONTROL_USB == selectedTest) || (TEST_OPTA_USB == selectedTest))
4951
{
5052
deviceName = DEV_USB;
5153
}
52-
else if ((TEST_PORTENTA_C33_SDCARD == selectedTest) || (TEST_PORTENTA_H7_SDCARD == selectedTest) || (TEST_PORTENTA_MACHINE_CONTROL_SDCARD == selectedTest))
54+
else if ((TEST_PORTENTA_C33_SDCARD == selectedTest) || (TEST_PORTENTA_H7_SDCARD == selectedTest) || (TEST_PORTENTA_MACHINE_CONTROL_SDCARD == selectedTest) || (TEST_OPTA_SDCARD == selectedTest))
5355
{
5456
deviceName = DEV_SDCARD;
5557
}
@@ -59,18 +61,23 @@ void setup() {
5961
}
6062

6163
Serial.begin(9600);
62-
while (!Serial) ; // Wait for the serial port to be ready
64+
// We can't have the Serial Monitor connected when we test USB on the Opta, and this will cause
65+
// the test to freeze unless we skip it
66+
if (TEST_OPTA_USB != selectedTest)
67+
{
68+
while (!Serial) ; // Wait for the serial port to be ready
69+
}
6370

6471
Serial.println("Testing started, please wait...");
6572
Serial.println();
6673

67-
if (TEST_PORTENTA_MACHINE_CONTROL_SDCARD == selectedTest)
74+
if ((TEST_PORTENTA_MACHINE_CONTROL_SDCARD == selectedTest) || (TEST_OPTA_SDCARD == selectedTest))
6875
{
69-
// Machine Control no SD Card supported test -->
76+
// Machine Control and Opta no SD Card supported test -->
7077
retVal = mount(DEV_SDCARD, FS_FAT, MNT_DEFAULT);
7178
if ((-1 != retVal) || (ENOTBLK != errno))
7279
{
73-
Serial.println("[FAIL] Machine Control no SD Card supported test failed");
80+
Serial.println("[FAIL] Machine Control and Opta no SD Card supported test failed");
7481
}
7582
else
7683
{
@@ -80,7 +87,7 @@ void setup() {
8087
(void) umount(DEV_SDCARD);
8188
for ( ; ; ) ; // Stop testing here
8289
}
83-
// <-- Machine Control no SD Card supported test
90+
// <-- Machine Control and Opta no SD Card supported test
8491
}
8592

8693
// Register hotplug callback for SD Card test -->
@@ -110,7 +117,7 @@ void setup() {
110117
// <-- Register nullptr callback test
111118
}
112119

113-
if ((TEST_PORTENTA_H7_USB == selectedTest) || (TEST_PORTENTA_MACHINE_CONTROL_USB == selectedTest))
120+
if ((TEST_PORTENTA_H7_USB == selectedTest) || (TEST_PORTENTA_MACHINE_CONTROL_USB == selectedTest) || (TEST_OPTA_USB == selectedTest))
114121
{
115122
// Register unsupported callback test -->
116123
retVal = register_hotplug_callback(DEV_USB, usbCallback);
@@ -135,7 +142,7 @@ void setup() {
135142
delay(500);
136143
}
137144
}
138-
else if ((TEST_PORTENTA_H7_USB == selectedTest) || (TEST_PORTENTA_MACHINE_CONTROL_USB == selectedTest))
145+
else if ((TEST_PORTENTA_H7_USB == selectedTest) || (TEST_PORTENTA_MACHINE_CONTROL_USB == selectedTest) || (TEST_OPTA_USB == selectedTest))
139146
{
140147
// These boards don't support hotplug callbacks, so loop on mount() tries
141148
while (0 != mount(DEV_USB, FS_FAT, MNT_DEFAULT)) {
@@ -457,6 +464,25 @@ void setup() {
457464
Serial.println("FAILURE: Finished with errors (see list above for details)");
458465
}
459466
// <-- Final report
467+
468+
// Opta final report -->
469+
if (TEST_OPTA_USB == selectedTest)
470+
{
471+
(void) mount(deviceName, FS_FAT, MNT_DEFAULT);
472+
FILE *logFile = fopen("/usb/testlog.txt", "w");
473+
if (true == allTestsOk)
474+
{
475+
fprintf(logFile, "SUCCESS: Finished without errors");
476+
fclose(logFile);
477+
}
478+
else
479+
{
480+
fprintf(logFile, "FAILURE: Finished with errors");
481+
fclose(logFile);
482+
}
483+
(void) umount(deviceName);
484+
}
485+
// <--
460486
}
461487

462488
void loop() {

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name=Arduino_POSIXStorage
22
version=1.0.0
33
author=Arduino
44
maintainer=Arduino <[email protected]>
5-
sentence=POSIX Storage Library for the Portenta C33, Portenta H7, and Portenta Machine Control
5+
sentence=POSIX Storage Library for the Portenta C33, Portenta H7, Portenta Machine Control, and Opta
66
paragraph=One-stop solution for using POSIX storage functions with SD cards and USB thumb drives with a unified API and without the need for separate libraries.
77
category=Data Storage
88
url=https://github.com/arduino-libraries/Arduino_POSIXStorage/

src/Arduino_POSIXStorage.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
* - Portenta H7 with Portenta Breakout Board (SD Card and USB Thumb Drive)
1717
* - Portenta H7 with Portenta Vision Shield (SD Card)
1818
* - Portenta Machine Control (USB Thumb Drive)
19+
* - Opta (USB Thumb Drive)
1920
*
2021
* After making changes:
2122
*
@@ -67,7 +68,6 @@
6768
#elif defined(ARDUINO_OPTA)
6869
#include <Arduino_USBHostMbed5.h>
6970
#include <BlockDevice.h>
70-
#include <DigitalIn.h>
7171
#else
7272
#error "The POSIXStorage library does not support this board"
7373
#endif
@@ -240,7 +240,7 @@ void deleteDevice(const enum StorageDevices deviceName, struct DeviceFileSystemC
240240
// The USBHostMSD class for the H7 doesn't correctly support object destruction, so we only delete
241241
// the device object on other platforms or if the device is an SD Card -->
242242
bool deleteDevice = false;
243-
#if (!defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_OPTA))
243+
#if (!(defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_OPTA)))
244244
(void) deviceName; // Silence -Wunused-parameter, because this variable is only used on the H7
245245
deleteDevice = true;
246246
#else

src/Arduino_POSIXStorage.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
* - Portenta H7 with Portenta Breakout Board (SD Card and USB Thumb Drive)
1818
* - Portenta H7 with Portenta Vision Shield (SD Card)
1919
* - Portenta Machine Control (USB Thumb Drive)
20+
* - Opta (USB Thumb Drive)
2021
*
2122
* After making changes:
2223
*

0 commit comments

Comments
 (0)