Browse Source

M33 LONG_FILENAME_HOST_SUPPORT

Scott Lahteine 10 years ago
parent
commit
0f2c9bacfd

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

+ 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
3051
     }
3052
     }
3052
   }
3053
   }
3053
 
3054
 
3055
+  #ifdef LONG_FILENAME_HOST_SUPPORT
3056
+
3057
+    /**
3058
+     * M33: Get the long full path of a file or folder
3059
+     *
3060
+     * Parameters:
3061
+     *   <dospath> Case-insensitive DOS-style path to a file or folder
3062
+     *
3063
+     * Example:
3064
+     *   M33 miscel~1/armchair/armcha~1.gco
3065
+     *
3066
+     * Output:
3067
+     *   /Miscellaneous/Armchair/Armchair.gcode
3068
+     */
3069
+    inline void gcode_M33() {
3070
+      char *args = strchr_pointer + 4;
3071
+      while (*args == ' ') ++args;
3072
+      clear_asterisk(args);
3073
+      card.printLongPath(args);
3074
+    }
3075
+
3076
+  #endif
3077
+
3054
   /**
3078
   /**
3055
    * M928: Start SD Write
3079
    * M928: Start SD Write
3056
    */
3080
    */
5307
           gcode_M30(); break;
5331
           gcode_M30(); break;
5308
         case 32: //M32 - Select file and start SD print
5332
         case 32: //M32 - Select file and start SD print
5309
           gcode_M32(); break;
5333
           gcode_M32(); break;
5334
+
5335
+        #ifdef LONG_FILENAME_HOST_SUPPORT
5336
+          case 33: //M33 - Get the long full path to a file or folder
5337
+            gcode_M33(); break;
5338
+        #endif // LONG_FILENAME_HOST_SUPPORT
5339
+
5310
         case 928: //M928 - Start SD write
5340
         case 928: //M928 - Start SD write
5311
           gcode_M928(); break;
5341
           gcode_M928(); break;
5312
 
5342
 

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

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

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

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

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

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

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

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

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

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

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

Loading…
Cancel
Save