@ -266,10 +266,10 @@ void CardReader::release() {
}
}
void CardReader : : openAndPrintFile ( const char * name ) {
void CardReader : : openAndPrintFile ( const char * name ) {
char cmd [ 4 + ( FILENAME_LENGTH + 1 ) * MAX_DIR_DEPTH + 2 ] ; // Room for "M23 ", names with slashes, a null, and one extra
char cmd [ 4 + strlen ( name ) + 1 ] ; // Room for "M23 ", filename, and null
sprintf_P ( cmd , PSTR ( " M23 %s " ) , name ) ;
sprintf_P ( cmd , PSTR ( " M23 %s " ) , name ) ;
for ( char * c = & cmd [ 4 ] ; * c ; c + + ) * c = tolower ( * c ) ;
for ( char * c = & cmd [ 4 ] ; * c ; c + + ) * c = tolower ( * c ) ;
enqueue_and_echo_command _now ( cmd ) ;
enqueue_and_echo_command ( cmd ) ;
enqueue_and_echo_commands_P ( PSTR ( " M24 " ) ) ;
enqueue_and_echo_commands_P ( PSTR ( " M24 " ) ) ;
}
}
@ -300,10 +300,10 @@ void CardReader::getAbsFilename(char *t) {
t [ 0 ] = 0 ;
t [ 0 ] = 0 ;
}
}
void CardReader : : openFile ( char * name , bool read , bool replace_current/*=tru e*/) {
void CardReader : : openFile ( char * name , bool read , bool push_current/*=fals e*/) {
if ( ! cardOK ) return ;
if ( ! cardOK ) return ;
if ( file . isOpen ( ) ) { //replacing current file by new file, or subfile call
if ( file . isOpen ( ) ) { //replacing current file by new file, or subfile call
if ( ! replace _current) {
if ( push _current) {
if ( file_subcall_ctr > SD_PROCEDURE_DEPTH - 1 ) {
if ( file_subcall_ctr > SD_PROCEDURE_DEPTH - 1 ) {
SERIAL_ERROR_START ;
SERIAL_ERROR_START ;
SERIAL_ERRORPGM ( " trying to call sub-gcode files with too many levels. MAX level is: " ) ;
SERIAL_ERRORPGM ( " trying to call sub-gcode files with too many levels. MAX level is: " ) ;
@ -318,9 +318,9 @@ void CardReader::openFile(char* name, bool read, bool replace_current/*=true*/)
SERIAL_ECHOPGM ( " \" parent: \" " ) ;
SERIAL_ECHOPGM ( " \" parent: \" " ) ;
//store current filename and position
//store current filename and position
getAbsFilename ( filenames[ file_subcall_ctr ] ) ;
getAbsFilename ( proc_ filenames[ file_subcall_ctr ] ) ;
SERIAL_ECHO ( filenames[ file_subcall_ctr ] ) ;
SERIAL_ECHO ( proc_ filenames[ file_subcall_ctr ] ) ;
SERIAL_ECHOPGM ( " \" pos " ) ;
SERIAL_ECHOPGM ( " \" pos " ) ;
SERIAL_ECHOLN ( sdpos ) ;
SERIAL_ECHOLN ( sdpos ) ;
filespos [ file_subcall_ctr ] = sdpos ;
filespos [ file_subcall_ctr ] = sdpos ;
@ -584,22 +584,15 @@ void CardReader::chdir(const char * relpath) {
SERIAL_ECHOLN ( relpath ) ;
SERIAL_ECHOLN ( relpath ) ;
}
}
else {
else {
if ( workDirDepth < MAX_DIR_DEPTH ) {
if ( workDirDepth < MAX_DIR_DEPTH )
+ + workDirDepth ;
workDirParents [ workDirDepth + + ] = * parent ;
for ( int d = workDirDepth ; d - - ; ) workDirParents [ d + 1 ] = workDirParents [ d ] ;
workDirParents [ 0 ] = * parent ;
}
workDir = newfile ;
workDir = newfile ;
}
}
}
}
void CardReader : : updir ( ) {
void CardReader : : updir ( ) {
if ( workDirDepth > 0 ) {
if ( workDirDepth > 0 )
- - workDirDepth ;
workDir = workDirParents [ - - workDirDepth ] ;
workDir = workDirParents [ 0 ] ;
for ( uint16_t d = 0 ; d < workDirDepth ; d + + )
workDirParents [ d ] = workDirParents [ d + 1 ] ;
}
}
}
void CardReader : : printingHasFinished ( ) {
void CardReader : : printingHasFinished ( ) {
@ -607,17 +600,15 @@ void CardReader::printingHasFinished() {
if ( file_subcall_ctr > 0 ) { // Heading up to a parent file that called current as a procedure.
if ( file_subcall_ctr > 0 ) { // Heading up to a parent file that called current as a procedure.
file . close ( ) ;
file . close ( ) ;
file_subcall_ctr - - ;
file_subcall_ctr - - ;
openFile ( filenames[ file_subcall_ctr ] , true , true ) ;
openFile ( proc_ filenames[ file_subcall_ctr ] , true , true ) ;
setIndex ( filespos [ file_subcall_ctr ] ) ;
setIndex ( filespos [ file_subcall_ctr ] ) ;
startFileprint ( ) ;
startFileprint ( ) ;
}
}
else {
else {
file . close ( ) ;
file . close ( ) ;
sdprinting = false ;
sdprinting = false ;
if ( SD_FINISHED_STEPPERRELEASE ) {
if ( SD_FINISHED_STEPPERRELEASE )
//finishAndDisableSteppers();
enqueue_and_echo_commands_P ( PSTR ( SD_FINISHED_RELEASECOMMAND ) ) ;
enqueue_and_echo_commands_P ( PSTR ( SD_FINISHED_RELEASECOMMAND ) ) ;
}
autotempShutdown ( ) ;
autotempShutdown ( ) ;
}
}
}
}