|
|
@ -157,7 +157,7 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m
|
|
|
|
|
|
|
|
|
|
|
|
case LS_SerialPrint:
|
|
|
|
case LS_SerialPrint:
|
|
|
|
createFilename(filename, p);
|
|
|
|
createFilename(filename, p);
|
|
|
|
SERIAL_PROTOCOL_P(port, prepend);
|
|
|
|
if (prepend) SERIAL_PROTOCOL_P(port, prepend);
|
|
|
|
SERIAL_PROTOCOL_P(port, filename);
|
|
|
|
SERIAL_PROTOCOL_P(port, filename);
|
|
|
|
SERIAL_PROTOCOLCHAR_P(port, ' ');
|
|
|
|
SERIAL_PROTOCOLCHAR_P(port, ' ');
|
|
|
|
SERIAL_PROTOCOLLN_P(port, p.fileSize);
|
|
|
|
SERIAL_PROTOCOLLN_P(port, p.fileSize);
|
|
|
@ -184,7 +184,7 @@ void CardReader::ls(
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
lsAction = LS_SerialPrint;
|
|
|
|
lsAction = LS_SerialPrint;
|
|
|
|
root.rewind();
|
|
|
|
root.rewind();
|
|
|
|
lsDive("", root
|
|
|
|
lsDive(NULL, root
|
|
|
|
#if NUM_SERIAL > 1
|
|
|
|
#if NUM_SERIAL > 1
|
|
|
|
, NULL, port
|
|
|
|
, NULL, port
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
@ -227,7 +227,7 @@ void CardReader::ls(
|
|
|
|
|
|
|
|
|
|
|
|
// Find the item, setting the long filename
|
|
|
|
// Find the item, setting the long filename
|
|
|
|
diveDir.rewind();
|
|
|
|
diveDir.rewind();
|
|
|
|
lsDive("", diveDir, segment
|
|
|
|
lsDive(NULL, diveDir, segment
|
|
|
|
#if NUM_SERIAL > 1
|
|
|
|
#if NUM_SERIAL > 1
|
|
|
|
, port
|
|
|
|
, port
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
@ -262,6 +262,32 @@ void CardReader::ls(
|
|
|
|
|
|
|
|
|
|
|
|
#endif // LONG_FILENAME_HOST_SUPPORT
|
|
|
|
#endif // LONG_FILENAME_HOST_SUPPORT
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Echo the DOS 8.3 filename (and long filename, if any)
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
void CardReader::printFilename(
|
|
|
|
|
|
|
|
#if NUM_SERIAL > 1
|
|
|
|
|
|
|
|
const int8_t port/*= -1*/
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
if (file.isOpen()) {
|
|
|
|
|
|
|
|
char lfilename[FILENAME_LENGTH];
|
|
|
|
|
|
|
|
file.getFilename(lfilename);
|
|
|
|
|
|
|
|
SERIAL_ECHO_P(port, lfilename);
|
|
|
|
|
|
|
|
#if ENABLED(LONG_FILENAME_HOST_SUPPORT)
|
|
|
|
|
|
|
|
getfilename(0, lfilename);
|
|
|
|
|
|
|
|
if (longFilename[0]) {
|
|
|
|
|
|
|
|
SERIAL_ECHO_P(port, ' ');
|
|
|
|
|
|
|
|
SERIAL_ECHO_P(port, longFilename);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
SERIAL_ECHOPGM_P(port, "(no file)");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SERIAL_EOL_P(port);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CardReader::initsd() {
|
|
|
|
void CardReader::initsd() {
|
|
|
|
cardOK = false;
|
|
|
|
cardOK = false;
|
|
|
|
if (root.isOpen()) root.close();
|
|
|
|
if (root.isOpen()) root.close();
|
|
|
@ -322,7 +348,7 @@ void CardReader::openAndPrintFile(const char *name) {
|
|
|
|
void CardReader::startFileprint() {
|
|
|
|
void CardReader::startFileprint() {
|
|
|
|
if (cardOK) {
|
|
|
|
if (cardOK) {
|
|
|
|
sdprinting = true;
|
|
|
|
sdprinting = true;
|
|
|
|
#if ENABLED(SDCARD_SORT_ALPHA)
|
|
|
|
#if SD_RESORT
|
|
|
|
flush_presort();
|
|
|
|
flush_presort();
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -460,8 +486,12 @@ void CardReader::openFile(char* name, const bool read, const bool subcall/*=fals
|
|
|
|
SERIAL_PROTOCOLPAIR(MSG_SD_FILE_OPENED, fname);
|
|
|
|
SERIAL_PROTOCOLPAIR(MSG_SD_FILE_OPENED, fname);
|
|
|
|
SERIAL_PROTOCOLLNPAIR(MSG_SD_SIZE, filesize);
|
|
|
|
SERIAL_PROTOCOLLNPAIR(MSG_SD_SIZE, filesize);
|
|
|
|
SERIAL_PROTOCOLLNPGM(MSG_SD_FILE_SELECTED);
|
|
|
|
SERIAL_PROTOCOLLNPGM(MSG_SD_FILE_SELECTED);
|
|
|
|
|
|
|
|
|
|
|
|
getfilename(0, fname);
|
|
|
|
getfilename(0, fname);
|
|
|
|
lcd_setstatus(longFilename[0] ? longFilename : fname);
|
|
|
|
lcd_setstatus(longFilename[0] ? longFilename : fname);
|
|
|
|
|
|
|
|
//if (longFilename[0]) {
|
|
|
|
|
|
|
|
// SERIAL_PROTOCOLPAIR(MSG_SD_FILE_LONG_NAME, longFilename);
|
|
|
|
|
|
|
|
//}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
SERIAL_PROTOCOLPAIR(MSG_SD_OPEN_FILE_FAIL, fname);
|
|
|
|
SERIAL_PROTOCOLPAIR(MSG_SD_OPEN_FILE_FAIL, fname);
|
|
|
@ -639,7 +669,7 @@ void CardReader::getfilename(uint16_t nr, const char * const match/*=NULL*/) {
|
|
|
|
lsAction = LS_GetFilename;
|
|
|
|
lsAction = LS_GetFilename;
|
|
|
|
nrFile_index = nr;
|
|
|
|
nrFile_index = nr;
|
|
|
|
curDir->rewind();
|
|
|
|
curDir->rewind();
|
|
|
|
lsDive("", *curDir, match);
|
|
|
|
lsDive(NULL, *curDir, match);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
uint16_t CardReader::getnrfilenames() {
|
|
|
|
uint16_t CardReader::getnrfilenames() {
|
|
|
@ -647,7 +677,7 @@ uint16_t CardReader::getnrfilenames() {
|
|
|
|
lsAction = LS_Count;
|
|
|
|
lsAction = LS_Count;
|
|
|
|
nrFiles = 0;
|
|
|
|
nrFiles = 0;
|
|
|
|
curDir->rewind();
|
|
|
|
curDir->rewind();
|
|
|
|
lsDive("", *curDir);
|
|
|
|
lsDive(NULL, *curDir);
|
|
|
|
//SERIAL_ECHOLN(nrFiles);
|
|
|
|
//SERIAL_ECHOLN(nrFiles);
|
|
|
|
return nrFiles;
|
|
|
|
return nrFiles;
|
|
|
|
}
|
|
|
|
}
|
|
|
|