M33 LONG_FILENAME_HOST_SUPPORT

master
Scott Lahteine 10 years ago
parent c5feb9c6a1
commit 0f2c9bacfd

@ -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
// @section more

@ -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
@ -3051,6 +3052,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
*/
@ -5307,6 +5331,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;

@ -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"));

@ -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();

@ -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
// @section more

@ -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
// @section more

@ -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
// @section more

@ -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
// @section more

@ -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
// @section more

@ -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
// @section more

@ -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
// @section more

@ -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
// @section more

@ -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
// @section more

@ -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
// @section more

@ -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
// @section more

Loading…
Cancel
Save