Skip to content

Apparently there is something wrong with rewindDirectory and openNextFile in VFS API #7749

Closed
@0x0fe

Description

@0x0fe

Board

ESP32-S3FH4R2

Device Description

custom hardware based on ESP32-S3FH4R2

Hardware Configuration

SD_MMC in 1bit mode

Version

latest master (checkout manually)

IDE Name

arduino IDE

Operating System

windows 10

Flash frequency

80M

PSRAM enabled

no

Upload speed

921600 (not relevant for CDC)

Description

So, when we use rewindDirectory followed by openNextFile we do not get the first file of the directory in aphabetical order.
My test directories are composed of 3 files with identical naming conventions.
Directory K0010 contains d1f1.mp3, d1f2.mp3 and d1f3.mp3
Directory K0012 contains d2f1mp3, d2f2.mp3 and d2f3.mp3

here is the code demonstrating the problem

  sprintf(filePath,"/MKI01/K0010",suffix);
  File root = SD_MMC.open(filePath);
  root.rewindDirectory();
  File entry = root.openNextFile();
  player.setPath(entry.path());
  printf("\npath : %s\n",entry.path());
  root.close();
  entry.close();

path : /MKI01/K0010/d1f2.mp3

but it should open d1f1.mp3. Strangely, if i open K0012, it starts on the correct file (d2f1.mp3)

  sprintf(filePath,"/MKI01/K0012",suffix);
  File root = SD_MMC.open(filePath);
  root.rewindDirectory();
  File entry = root.openNextFile();
  player.setPath(entry.path());
  printf("\npath : %s\n",entry.path());
  root.close();
  entry.close();

path : /MKI01/K00102/d2f1.mp3

I discovered the issue when using audio-tools library, which also shows a problem with the total number of files per directory, it is not clear yet if this second issue is related to VFS or the audio-tools implmeentation.
pschatzmann/arduino-audio-tools#580

Sketch

sprintf(filePath,"/MKI01/K0010",suffix);
  File root = SD_MMC.open(filePath);
  root.rewindDirectory();
  File entry = root.openNextFile();
  player.setPath(entry.path());
  printf("\npath : %s\n",entry.path());
  root.close();
  entry.close();

Debug Message

`path : /MKI01/K0010/d1f2.mp3`

Other Steps to Reproduce

none

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions