Browse Source

Merge pull request #2108 from thinkyhead/m33_long_filename_host_support

M33 LONG_FILENAME_HOST_SUPPORT
Scott Lahteine 10 years ago
parent
commit
50bd7493cc

+ 3
- 0
Marlin/Configuration_adv.h View File

313
     //#define PROGRESS_MSG_ONCE
313
     //#define PROGRESS_MSG_ONCE
314
   #endif
314
   #endif
315
 
315
 
316
+  // This allows hosts to request long names for files and folders with M33
317
+  //#define LONG_FILENAME_HOST_SUPPORT
318
+
316
 #endif // SDSUPPORT
319
 #endif // SDSUPPORT
317
 
320
 
318
 // for dogm lcd displays you can choose some additional fonts:
321
 // for dogm lcd displays you can choose some additional fonts:

+ 30
- 0
Marlin/Marlin_main.cpp View File

120
  *        syntax "M32 /path/filename#", or "M32 S<startpos bytes> !filename#"
120
  *        syntax "M32 /path/filename#", or "M32 S<startpos bytes> !filename#"
121
  *        Call gcode file : "M32 P !filename#" and return to caller file after finishing (similar to #include).
121
  *        Call gcode file : "M32 P !filename#" and return to caller file after finishing (similar to #include).
122
  *        The '#' is necessary when calling from within sd files, as it stops buffer prereading
122
  *        The '#' is necessary when calling from within sd files, as it stops buffer prereading
123
+ * M33  - Get the longname version of a path
123
  * 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.
124
  * 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.
124
  * M48  - Measure Z_Probe repeatability. M48 [P # of points] [X position] [Y position] [V_erboseness #] [E_ngage Probe] [L # of legs of travel]
125
  * M48  - Measure Z_Probe repeatability. M48 [P # of points] [X position] [Y position] [V_erboseness #] [E_ngage Probe] [L # of legs of travel]
125
  * M80  - Turn on Power Supply
126
  * M80  - Turn on Power Supply
3039
     }
3040
     }
3040
   }
3041
   }
3041
 
3042
 
3043
+  #ifdef LONG_FILENAME_HOST_SUPPORT
3044
+
3045
+    /**
3046
+     * M33: Get the long full path of a file or folder
3047
+     *
3048
+     * Parameters:
3049
+     *   <dospath> Case-insensitive DOS-style path to a file or folder
3050
+     *
3051
+     * Example:
3052
+     *   M33 miscel~1/armchair/armcha~1.gco
3053
+     *
3054
+     * Output:
3055
+     *   /Miscellaneous/Armchair/Armchair.gcode
3056
+     */
3057
+    inline void gcode_M33() {
3058
+      char *args = strchr_pointer + 4;
3059
+      while (*args == ' ') ++args;
3060
+      clear_asterisk(args);
3061
+      card.printLongPath(args);
3062
+    }
3063
+
3064
+  #endif
3065
+
3042
   /**
3066
   /**
3043
    * M928: Start SD Write
3067
    * M928: Start SD Write
3044
    */
3068
    */
5313
           gcode_M30(); break;
5337
           gcode_M30(); break;
5314
         case 32: //M32 - Select file and start SD print
5338
         case 32: //M32 - Select file and start SD print
5315
           gcode_M32(); break;
5339
           gcode_M32(); break;
5340
+
5341
+        #ifdef LONG_FILENAME_HOST_SUPPORT
5342
+          case 33: //M33 - Get the long full path to a file or folder
5343
+            gcode_M33(); break;
5344
+        #endif // LONG_FILENAME_HOST_SUPPORT
5345
+
5316
         case 928: //M928 - Start SD write
5346
         case 928: //M928 - Start SD write
5317
           gcode_M928(); break;
5347
           gcode_M928(); break;
5318
 
5348
 

+ 65
- 2
Marlin/cardreader.cpp View File

129
   lsDive("", root);
129
   lsDive("", root);
130
 }
130
 }
131
 
131
 
132
+#ifdef LONG_FILENAME_HOST_SUPPORT
133
+
134
+  /**
135
+   * Get a long pretty path based on a DOS 8.3 path
136
+   */
137
+  void CardReader::printLongPath(char *path) {
138
+    lsAction = LS_GetFilename;
139
+
140
+    int i, pathLen = strlen(path);
141
+
142
+    // SERIAL_ECHOPGM("Full Path: "); SERIAL_ECHOLN(path);
143
+
144
+    // Zero out slashes to make segments
145
+    for (i = 0; i < pathLen; i++) if (path[i] == '/') path[i] = '\0';
146
+
147
+    SdFile diveDir = root; // start from the root for segment 1
148
+    for (i = 0; i < pathLen;) {
149
+
150
+      if (path[i] == '\0') i++; // move past a single nul
151
+
152
+      char *segment = &path[i]; // The segment after most slashes
153
+
154
+      // If a segment is empty (extra-slash) then exit
155
+      if (!*segment) break;
156
+
157
+      // Go to the next segment
158
+      while (path[++i]) { }
159
+
160
+      // SERIAL_ECHOPGM("Looking for segment: "); SERIAL_ECHOLN(segment);
161
+
162
+      // Find the item, setting the long filename
163
+      diveDir.rewind();
164
+      lsDive("", diveDir, segment);
165
+
166
+      // Print /LongNamePart to serial output
167
+      SERIAL_PROTOCOLCHAR('/');
168
+      SERIAL_PROTOCOL(longFilename[0] ? longFilename : "???");
169
+
170
+      // If the filename was printed then that's it
171
+      if (!filenameIsDir) break;
172
+
173
+      // SERIAL_ECHOPGM("Opening dir: "); SERIAL_ECHOLN(segment);
174
+
175
+      // Open the sub-item as the new dive parent
176
+      SdFile dir;
177
+      if (!dir.open(diveDir, segment, O_READ)) {
178
+        SERIAL_EOL;
179
+        SERIAL_ECHO_START;
180
+        SERIAL_ECHOPGM(MSG_SD_CANT_OPEN_SUBDIR);
181
+        SERIAL_ECHO(segment);
182
+        break;
183
+      }
184
+
185
+      diveDir.close();
186
+      diveDir = dir;
187
+
188
+    } // while i<pathLen
189
+
190
+    SERIAL_EOL;
191
+  }
192
+
193
+#endif // LONG_FILENAME_HOST_SUPPORT
194
+
132
 void CardReader::initsd() {
195
 void CardReader::initsd() {
133
   cardOK = false;
196
   cardOK = false;
134
   if (root.isOpen()) root.close();
197
   if (root.isOpen()) root.close();
429
     if (!cardOK) return; // fail
492
     if (!cardOK) return; // fail
430
   }
493
   }
431
 
494
 
432
-  char autoname[30];
495
+  char autoname[10];
433
   sprintf_P(autoname, PSTR("auto%i.g"), autostart_index);
496
   sprintf_P(autoname, PSTR("auto%i.g"), autostart_index);
434
   for (int8_t i = 0; i < (int8_t)strlen(autoname); i++) autoname[i] = tolower(autoname[i]);
497
   for (int8_t i = 0; i < (int8_t)strlen(autoname); i++) autoname[i] = tolower(autoname[i]);
435
 
498
 
441
   while (root.readDir(p, NULL) > 0) {
504
   while (root.readDir(p, NULL) > 0) {
442
     for (int8_t i = 0; i < (int8_t)strlen((char*)p.name); i++) p.name[i] = tolower(p.name[i]);
505
     for (int8_t i = 0; i < (int8_t)strlen((char*)p.name); i++) p.name[i] = tolower(p.name[i]);
443
     if (p.name[9] != '~' && strncmp((char*)p.name, autoname, 5) == 0) {
506
     if (p.name[9] != '~' && strncmp((char*)p.name, autoname, 5) == 0) {
444
-      char cmd[30];
507
+      char cmd[4 + (FILENAME_LENGTH + 1) * MAX_DIR_DEPTH + 2];
445
       sprintf_P(cmd, PSTR("M23 %s"), autoname);
508
       sprintf_P(cmd, PSTR("M23 %s"), autoname);
446
       enqueuecommand(cmd);
509
       enqueuecommand(cmd);
447
       enqueuecommands_P(PSTR("M24"));
510
       enqueuecommands_P(PSTR("M24"));

+ 4
- 0
Marlin/cardreader.h View File

28
   void getStatus();
28
   void getStatus();
29
   void printingHasFinished();
29
   void printingHasFinished();
30
 
30
 
31
+  #ifdef LONG_FILENAME_HOST_SUPPORT
32
+    void printLongPath(char *path);
33
+  #endif
34
+
31
   void getfilename(uint16_t nr, const char* const match=NULL);
35
   void getfilename(uint16_t nr, const char* const match=NULL);
32
   uint16_t getnrfilenames();
36
   uint16_t getnrfilenames();
33
 
37
 

+ 3
- 0
Marlin/configurator/config/Configuration_adv.h View File

321
     //#define PROGRESS_MSG_ONCE
321
     //#define PROGRESS_MSG_ONCE
322
   #endif
322
   #endif
323
 
323
 
324
+  // This allows hosts to request long names for files and folders with M33
325
+  //#define LONG_FILENAME_HOST_SUPPORT
326
+
324
 #endif // SDSUPPORT
327
 #endif // SDSUPPORT
325
 
328
 
326
 // for dogm lcd displays you can choose some additional fonts:
329
 // for dogm lcd displays you can choose some additional fonts:

+ 3
- 0
Marlin/example_configurations/Felix/Configuration_adv.h View File

321
     //#define PROGRESS_MSG_ONCE
321
     //#define PROGRESS_MSG_ONCE
322
   #endif
322
   #endif
323
 
323
 
324
+  // This allows hosts to request long names for files and folders with M33
325
+  //#define LONG_FILENAME_HOST_SUPPORT
326
+
324
 #endif // SDSUPPORT
327
 #endif // SDSUPPORT
325
 
328
 
326
 // for dogm lcd displays you can choose some additional fonts:
329
 // for dogm lcd displays you can choose some additional fonts:

+ 3
- 0
Marlin/example_configurations/Hephestos/Configuration_adv.h View File

321
     //#define PROGRESS_MSG_ONCE
321
     //#define PROGRESS_MSG_ONCE
322
   #endif
322
   #endif
323
 
323
 
324
+  // This allows hosts to request long names for files and folders with M33
325
+  //#define LONG_FILENAME_HOST_SUPPORT
326
+
324
 #endif // SDSUPPORT
327
 #endif // SDSUPPORT
325
 
328
 
326
 // for dogm lcd displays you can choose some additional fonts:
329
 // for dogm lcd displays you can choose some additional fonts:

+ 3
- 0
Marlin/example_configurations/K8200/Configuration_adv.h View File

321
     //#define PROGRESS_MSG_ONCE
321
     //#define PROGRESS_MSG_ONCE
322
   #endif
322
   #endif
323
 
323
 
324
+  // This allows hosts to request long names for files and folders with M33
325
+  //#define LONG_FILENAME_HOST_SUPPORT
326
+
324
 #endif // SDSUPPORT
327
 #endif // SDSUPPORT
325
 
328
 
326
 // for dogm lcd displays you can choose some additional fonts:
329
 // for dogm lcd displays you can choose some additional fonts:

+ 3
- 0
Marlin/example_configurations/SCARA/Configuration_adv.h View File

321
     //#define PROGRESS_MSG_ONCE
321
     //#define PROGRESS_MSG_ONCE
322
   #endif
322
   #endif
323
 
323
 
324
+  // This allows hosts to request long names for files and folders with M33
325
+  //#define LONG_FILENAME_HOST_SUPPORT
326
+
324
 #endif // SDSUPPORT
327
 #endif // SDSUPPORT
325
 
328
 
326
 // for dogm lcd displays you can choose some additional fonts:
329
 // for dogm lcd displays you can choose some additional fonts:

+ 3
- 0
Marlin/example_configurations/WITBOX/Configuration_adv.h View File

321
     //#define PROGRESS_MSG_ONCE
321
     //#define PROGRESS_MSG_ONCE
322
   #endif
322
   #endif
323
 
323
 
324
+  // This allows hosts to request long names for files and folders with M33
325
+  //#define LONG_FILENAME_HOST_SUPPORT
326
+
324
 #endif // SDSUPPORT
327
 #endif // SDSUPPORT
325
 
328
 
326
 // for dogm lcd displays you can choose some additional fonts:
329
 // for dogm lcd displays you can choose some additional fonts:

+ 3
- 0
Marlin/example_configurations/delta/biv2.5/Configuration_adv.h View File

322
     //#define PROGRESS_MSG_ONCE
322
     //#define PROGRESS_MSG_ONCE
323
   #endif
323
   #endif
324
 
324
 
325
+  // This allows hosts to request long names for files and folders with M33
326
+  //#define LONG_FILENAME_HOST_SUPPORT
327
+
325
 #endif // SDSUPPORT
328
 #endif // SDSUPPORT
326
 
329
 
327
 // for dogm lcd displays you can choose some additional fonts:
330
 // for dogm lcd displays you can choose some additional fonts:

+ 3
- 0
Marlin/example_configurations/delta/generic/Configuration_adv.h View File

322
     //#define PROGRESS_MSG_ONCE
322
     //#define PROGRESS_MSG_ONCE
323
   #endif
323
   #endif
324
 
324
 
325
+  // This allows hosts to request long names for files and folders with M33
326
+  //#define LONG_FILENAME_HOST_SUPPORT
327
+
325
 #endif // SDSUPPORT
328
 #endif // SDSUPPORT
326
 
329
 
327
 // for dogm lcd displays you can choose some additional fonts:
330
 // for dogm lcd displays you can choose some additional fonts:

+ 3
- 0
Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h View File

321
     //#define PROGRESS_MSG_ONCE
321
     //#define PROGRESS_MSG_ONCE
322
   #endif
322
   #endif
323
 
323
 
324
+  // This allows hosts to request long names for files and folders with M33
325
+  //#define LONG_FILENAME_HOST_SUPPORT
326
+
324
 #endif // SDSUPPORT
327
 #endif // SDSUPPORT
325
 
328
 
326
 // for dogm lcd displays you can choose some additional fonts:
329
 // for dogm lcd displays you can choose some additional fonts:

+ 3
- 0
Marlin/example_configurations/makibox/Configuration_adv.h View File

321
     //#define PROGRESS_MSG_ONCE
321
     //#define PROGRESS_MSG_ONCE
322
   #endif
322
   #endif
323
 
323
 
324
+  // This allows hosts to request long names for files and folders with M33
325
+  //#define LONG_FILENAME_HOST_SUPPORT
326
+
324
 #endif // SDSUPPORT
327
 #endif // SDSUPPORT
325
 
328
 
326
 // for dogm lcd displays you can choose some additional fonts:
329
 // for dogm lcd displays you can choose some additional fonts:

+ 3
- 0
Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h View File

321
     //#define PROGRESS_MSG_ONCE
321
     //#define PROGRESS_MSG_ONCE
322
   #endif
322
   #endif
323
 
323
 
324
+  // This allows hosts to request long names for files and folders with M33
325
+  //#define LONG_FILENAME_HOST_SUPPORT
326
+
324
 #endif // SDSUPPORT
327
 #endif // SDSUPPORT
325
 
328
 
326
 // for dogm lcd displays you can choose some additional fonts:
329
 // for dogm lcd displays you can choose some additional fonts:

Loading…
Cancel
Save