Browse Source

Merge pull request #2108 from thinkyhead/m33_long_filename_host_support

M33 LONG_FILENAME_HOST_SUPPORT
pull/1/head
Scott Lahteine 10 years ago
parent
commit
50bd7493cc
  1. 3
      Marlin/Configuration_adv.h
  2. 30
      Marlin/Marlin_main.cpp
  3. 67
      Marlin/cardreader.cpp
  4. 4
      Marlin/cardreader.h
  5. 3
      Marlin/configurator/config/Configuration_adv.h
  6. 3
      Marlin/example_configurations/Felix/Configuration_adv.h
  7. 3
      Marlin/example_configurations/Hephestos/Configuration_adv.h
  8. 3
      Marlin/example_configurations/K8200/Configuration_adv.h
  9. 3
      Marlin/example_configurations/SCARA/Configuration_adv.h
  10. 3
      Marlin/example_configurations/WITBOX/Configuration_adv.h
  11. 3
      Marlin/example_configurations/delta/biv2.5/Configuration_adv.h
  12. 3
      Marlin/example_configurations/delta/generic/Configuration_adv.h
  13. 3
      Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h
  14. 3
      Marlin/example_configurations/makibox/Configuration_adv.h
  15. 3
      Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h

3
Marlin/Configuration_adv.h

@ -313,6 +313,9 @@
//#define PROGRESS_MSG_ONCE
#endif
// This allows hosts to request long names for files and folders with M33
//#define LONG_FILENAME_HOST_SUPPORT
#endif // SDSUPPORT
// for dogm lcd displays you can choose some additional fonts:

30
Marlin/Marlin_main.cpp

@ -120,6 +120,7 @@
* syntax "M32 /path/filename#", or "M32 S<startpos bytes> !filename#"
* Call gcode file : "M32 P !filename#" and return to caller file after finishing (similar to #include).
* The '#' is necessary when calling from within sd files, as it stops buffer prereading
* M33 - Get the longname version of a path
* M42 - Change pin status via gcode Use M42 Px Sy to set pin x to value y, when omitting Px the onboard led will be used.
* M48 - Measure Z_Probe repeatability. M48 [P # of points] [X position] [Y position] [V_erboseness #] [E_ngage Probe] [L # of legs of travel]
* M80 - Turn on Power Supply
@ -3039,6 +3040,29 @@ inline void gcode_M31() {
}
}
#ifdef LONG_FILENAME_HOST_SUPPORT
/**
* M33: Get the long full path of a file or folder
*
* Parameters:
* <dospath> Case-insensitive DOS-style path to a file or folder
*
* Example:
* M33 miscel~1/armchair/armcha~1.gco
*
* Output:
* /Miscellaneous/Armchair/Armchair.gcode
*/
inline void gcode_M33() {
char *args = strchr_pointer + 4;
while (*args == ' ') ++args;
clear_asterisk(args);
card.printLongPath(args);
}
#endif
/**
* M928: Start SD Write
*/
@ -5313,6 +5337,12 @@ void process_next_command() {
gcode_M30(); break;
case 32: //M32 - Select file and start SD print
gcode_M32(); break;
#ifdef LONG_FILENAME_HOST_SUPPORT
case 33: //M33 - Get the long full path to a file or folder
gcode_M33(); break;
#endif // LONG_FILENAME_HOST_SUPPORT
case 928: //M928 - Start SD write
gcode_M928(); break;

67
Marlin/cardreader.cpp

@ -129,6 +129,69 @@ void CardReader::ls() {
lsDive("", root);
}
#ifdef LONG_FILENAME_HOST_SUPPORT
/**
* Get a long pretty path based on a DOS 8.3 path
*/
void CardReader::printLongPath(char *path) {
lsAction = LS_GetFilename;
int i, pathLen = strlen(path);
// SERIAL_ECHOPGM("Full Path: "); SERIAL_ECHOLN(path);
// Zero out slashes to make segments
for (i = 0; i < pathLen; i++) if (path[i] == '/') path[i] = '\0';
SdFile diveDir = root; // start from the root for segment 1
for (i = 0; i < pathLen;) {
if (path[i] == '\0') i++; // move past a single nul
char *segment = &path[i]; // The segment after most slashes
// If a segment is empty (extra-slash) then exit
if (!*segment) break;
// Go to the next segment
while (path[++i]) { }
// SERIAL_ECHOPGM("Looking for segment: "); SERIAL_ECHOLN(segment);
// Find the item, setting the long filename
diveDir.rewind();
lsDive("", diveDir, segment);
// Print /LongNamePart to serial output
SERIAL_PROTOCOLCHAR('/');
SERIAL_PROTOCOL(longFilename[0] ? longFilename : "???");
// If the filename was printed then that's it
if (!filenameIsDir) break;
// SERIAL_ECHOPGM("Opening dir: "); SERIAL_ECHOLN(segment);
// Open the sub-item as the new dive parent
SdFile dir;
if (!dir.open(diveDir, segment, O_READ)) {
SERIAL_EOL;
SERIAL_ECHO_START;
SERIAL_ECHOPGM(MSG_SD_CANT_OPEN_SUBDIR);
SERIAL_ECHO(segment);
break;
}
diveDir.close();
diveDir = dir;
} // while i<pathLen
SERIAL_EOL;
}
#endif // LONG_FILENAME_HOST_SUPPORT
void CardReader::initsd() {
cardOK = false;
if (root.isOpen()) root.close();
@ -429,7 +492,7 @@ void CardReader::checkautostart(bool force) {
if (!cardOK) return; // fail
}
char autoname[30];
char autoname[10];
sprintf_P(autoname, PSTR("auto%i.g"), autostart_index);
for (int8_t i = 0; i < (int8_t)strlen(autoname); i++) autoname[i] = tolower(autoname[i]);
@ -441,7 +504,7 @@ void CardReader::checkautostart(bool force) {
while (root.readDir(p, NULL) > 0) {
for (int8_t i = 0; i < (int8_t)strlen((char*)p.name); i++) p.name[i] = tolower(p.name[i]);
if (p.name[9] != '~' && strncmp((char*)p.name, autoname, 5) == 0) {
char cmd[30];
char cmd[4 + (FILENAME_LENGTH + 1) * MAX_DIR_DEPTH + 2];
sprintf_P(cmd, PSTR("M23 %s"), autoname);
enqueuecommand(cmd);
enqueuecommands_P(PSTR("M24"));

4
Marlin/cardreader.h

@ -28,6 +28,10 @@ public:
void getStatus();
void printingHasFinished();
#ifdef LONG_FILENAME_HOST_SUPPORT
void printLongPath(char *path);
#endif
void getfilename(uint16_t nr, const char* const match=NULL);
uint16_t getnrfilenames();

3
Marlin/configurator/config/Configuration_adv.h

@ -321,6 +321,9 @@
//#define PROGRESS_MSG_ONCE
#endif
// This allows hosts to request long names for files and folders with M33
//#define LONG_FILENAME_HOST_SUPPORT
#endif // SDSUPPORT
// for dogm lcd displays you can choose some additional fonts:

3
Marlin/example_configurations/Felix/Configuration_adv.h

@ -321,6 +321,9 @@
//#define PROGRESS_MSG_ONCE
#endif
// This allows hosts to request long names for files and folders with M33
//#define LONG_FILENAME_HOST_SUPPORT
#endif // SDSUPPORT
// for dogm lcd displays you can choose some additional fonts:

3
Marlin/example_configurations/Hephestos/Configuration_adv.h

@ -321,6 +321,9 @@
//#define PROGRESS_MSG_ONCE
#endif
// This allows hosts to request long names for files and folders with M33
//#define LONG_FILENAME_HOST_SUPPORT
#endif // SDSUPPORT
// for dogm lcd displays you can choose some additional fonts:

3
Marlin/example_configurations/K8200/Configuration_adv.h

@ -321,6 +321,9 @@
//#define PROGRESS_MSG_ONCE
#endif
// This allows hosts to request long names for files and folders with M33
//#define LONG_FILENAME_HOST_SUPPORT
#endif // SDSUPPORT
// for dogm lcd displays you can choose some additional fonts:

3
Marlin/example_configurations/SCARA/Configuration_adv.h

@ -321,6 +321,9 @@
//#define PROGRESS_MSG_ONCE
#endif
// This allows hosts to request long names for files and folders with M33
//#define LONG_FILENAME_HOST_SUPPORT
#endif // SDSUPPORT
// for dogm lcd displays you can choose some additional fonts:

3
Marlin/example_configurations/WITBOX/Configuration_adv.h

@ -321,6 +321,9 @@
//#define PROGRESS_MSG_ONCE
#endif
// This allows hosts to request long names for files and folders with M33
//#define LONG_FILENAME_HOST_SUPPORT
#endif // SDSUPPORT
// for dogm lcd displays you can choose some additional fonts:

3
Marlin/example_configurations/delta/biv2.5/Configuration_adv.h

@ -322,6 +322,9 @@
//#define PROGRESS_MSG_ONCE
#endif
// This allows hosts to request long names for files and folders with M33
//#define LONG_FILENAME_HOST_SUPPORT
#endif // SDSUPPORT
// for dogm lcd displays you can choose some additional fonts:

3
Marlin/example_configurations/delta/generic/Configuration_adv.h

@ -322,6 +322,9 @@
//#define PROGRESS_MSG_ONCE
#endif
// This allows hosts to request long names for files and folders with M33
//#define LONG_FILENAME_HOST_SUPPORT
#endif // SDSUPPORT
// for dogm lcd displays you can choose some additional fonts:

3
Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h

@ -321,6 +321,9 @@
//#define PROGRESS_MSG_ONCE
#endif
// This allows hosts to request long names for files and folders with M33
//#define LONG_FILENAME_HOST_SUPPORT
#endif // SDSUPPORT
// for dogm lcd displays you can choose some additional fonts:

3
Marlin/example_configurations/makibox/Configuration_adv.h

@ -321,6 +321,9 @@
//#define PROGRESS_MSG_ONCE
#endif
// This allows hosts to request long names for files and folders with M33
//#define LONG_FILENAME_HOST_SUPPORT
#endif // SDSUPPORT
// for dogm lcd displays you can choose some additional fonts:

3
Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h

@ -321,6 +321,9 @@
//#define PROGRESS_MSG_ONCE
#endif
// This allows hosts to request long names for files and folders with M33
//#define LONG_FILENAME_HOST_SUPPORT
#endif // SDSUPPORT
// for dogm lcd displays you can choose some additional fonts:

Loading…
Cancel
Save