module:microcontroller:esp32sdcarddemo:esp32sdcarddemo
Esp32SDCardDemo
Überblick
* Permanentes Schreiben von Daten auf SDCard (/YY/MM/DD/HHMMSS.txt)
- SubDirectories müssen Ebene für Ebene einzeln angelegt werden
- SubDirectories/Files müssen mit vollem Pfadnamen angesprochen werden
* Esp32SDCardDemo zeigt folgende in der Klasse CSDCard gekapselten File- und Directory-Funktionen:
- || Instance
- CSDCard(int pinss, TMessage pmessage, TError perror);
- bool Initialise(void);
- || Property
- bool IsEndOfFile(void);
- ECardType GetCardType(void);
- uint64_t GetCardSizeMB(void);
- || WriteFile
- bool OpenWrite(const char* fileentry);
- bool OpenAppend(const char* fileentry);
- bool WriteCharacter(const char character);
- bool WriteText(const char* text);
- bool WriteLine(const char* line);
- bool CloseWrite(void);
- || ReadFile
- bool OpenRead(const char* fileentry);
- bool ReadCharacter(char &character);
- bool ReadText(char* text, unsigned &size);
- bool ReadLine(char* line);
- bool CloseRead(void);
- || File
- bool RenameFile(const char* entrysource, const char* entrytarget);
- bool RemoveFile(const char * entry);
- || Directory
- bool ListDirectory(const char* entry);
- bool CreateDirectory(const char* entry);
- bool RemoveDirectory(const char* entry);
// #ifndef SDCard_h #define SDCard_h // //---------------------- // Include //---------------------- #include "Define.h" // #include <Arduino.h> #include "FS.h" #include "SD.h" #include "SPI.h" // enum ECardType { ctNone = 0, ctMMC = 1, ctSD = 2, ctSDHC = 3, ctUnknown = 4 }; // const char* CardTypeText(ECardType cardtype); // class CSDCard { private: int FPinSS; File FFile; TMessage FPMessage; TError FPError; // public: // Instance CSDCard(int pinss, TMessage pmessage, TError perror); bool Initialise(void); // Property bool IsEndOfFile(void); ECardType GetCardType(void); uint64_t GetCardSizeMB(void); // WriteFile bool OpenWrite(const char* fileentry); bool OpenAppend(const char* fileentry); bool WriteCharacter(const char character); bool WriteText(const char* text); bool WriteLine(const char* line); bool CloseWrite(void); // ReadFile bool OpenRead(const char* fileentry); bool ReadCharacter(char &character); bool ReadText(char* text, unsigned &size); bool ReadLine(char* line); bool CloseRead(void); // File bool RenameFile(const char* entrysource, const char* entrytarget); bool RemoveFile(const char * entry); // Directory bool ListDirectory(const char* entry); bool CreateDirectory(const char* entry); bool RemoveDirectory(const char* entry); }; // #endif // SDCard_h
- Geschachteltes Anlegen von geschachtelten Verzeichnissen:
- (SubDirectories müssen Ebene für Ebene einzeln angelegt werden)
- (SubDirectories/Files müssen mit vollem Pfadnamen angesprochen werden)
const char* DIRECTORY_MAIN = "/"; const char* DIRECTORY_SUBYY = "/22"; const char* DIRECTORY_SUBMM = "/22/11"; const char* DIRECTORY_SUBDD = "/22/11/04";
_Message(LINE_SEPARATOR); sprintf(Line, "Create Directory[%s]:", DIRECTORY_SUBYY); _Message(Line); SDCard.CreateDirectory(DIRECTORY_SUBYY); // _Message(LINE_SEPARATOR); sprintf(Line, "Create Directory[%s]:", DIRECTORY_SUBMM); _Message(Line); SDCard.CreateDirectory(DIRECTORY_SUBMM); // _Message(LINE_SEPARATOR); sprintf(Line, "Create Directory[%s]:", DIRECTORY_SUBDD); _Message(Line); SDCard.CreateDirectory(DIRECTORY_SUBDD);
- Geschachteltes Listing der SubDirectories:
_Message(LINE_SEPARATOR); sprintf(Line, "List Directory[%s]:", DIRECTORY_MAIN); _Message(Line); SDCard.ListDirectory(DIRECTORY_MAIN); // _Message(LINE_SEPARATOR); sprintf(Line, "List Directory[%s]:", DIRECTORY_SUBYY); _Message(Line); SDCard.ListDirectory(DIRECTORY_SUBYY); // _Message(LINE_SEPARATOR); sprintf(Line, "List Directory[%s]:", DIRECTORY_SUBMM); _Message(Line); SDCard.ListDirectory(DIRECTORY_SUBMM); // _Message(LINE_SEPARATOR); sprintf(Line, "List Directory[%s]:", DIRECTORY_SUBDD); _Message(Line); SDCard.ListDirectory(DIRECTORY_SUBDD);
ToDo
Done
221104
- X Anlegen von geschachtelten SubDirectories
- X Listing von geschachtelten SubDirectories
- Download: 2211041559_Esp32SDCardDemo_02V03_chdir
221104
- Download (VSCode): 2211041209_Esp32SDCardDemo_02V02.zip
221103
- Neuauflage von 2208211552_Esp32SDCardInfo_01V03.zip
- zu 2211031450_Esp32SDCardDemo_02V01.zip
module/microcontroller/esp32sdcarddemo/esp32sdcarddemo.txt · Last modified: 2022/11/07 18:57 by omdevelop