Remove commented debug code
the whole PR is ready for review after successfull tests
This commit is contained in:
parent
15d76a7501
commit
c1ead75a73
@ -3987,12 +3987,10 @@ void process_commands()
|
|||||||
#endif
|
#endif
|
||||||
}else if (code_seen_P("fv")) { // PRUSA fv
|
}else if (code_seen_P("fv")) { // PRUSA fv
|
||||||
// get file version
|
// get file version
|
||||||
#if 0
|
#ifdef SDSUPPORT
|
||||||
//@@TODO
|
card.openFileReadFilteredGcode(strchr_pointer + 3,true);
|
||||||
def SDSUPPORT
|
|
||||||
card.openFile(strchr_pointer + 3,true);
|
|
||||||
while (true) {
|
while (true) {
|
||||||
uint16_t readByte = card.get();
|
uint16_t readByte = card.getFilteredGcodeChar();
|
||||||
MYSERIAL.write(readByte);
|
MYSERIAL.write(readByte);
|
||||||
if (readByte=='\n') {
|
if (readByte=='\n') {
|
||||||
break;
|
break;
|
||||||
|
@ -31,7 +31,6 @@
|
|||||||
SdFile::SdFile(const char* path, uint8_t oflag) : SdBaseFile(path, oflag) {
|
SdFile::SdFile(const char* path, uint8_t oflag) : SdBaseFile(path, oflag) {
|
||||||
}
|
}
|
||||||
|
|
||||||
//size=100B
|
|
||||||
bool SdFile::openFilteredGcode(SdBaseFile* dirFile, const char* path){
|
bool SdFile::openFilteredGcode(SdBaseFile* dirFile, const char* path){
|
||||||
if( open(dirFile, path, O_READ) ){
|
if( open(dirFile, path, O_READ) ){
|
||||||
// compute the block to start with
|
// compute the block to start with
|
||||||
@ -44,10 +43,7 @@ bool SdFile::openFilteredGcode(SdBaseFile* dirFile, const char* path){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//size=90B
|
|
||||||
bool SdFile::seekSetFilteredGcode(uint32_t pos){
|
bool SdFile::seekSetFilteredGcode(uint32_t pos){
|
||||||
// SERIAL_PROTOCOLPGM("Seek:");
|
|
||||||
// SERIAL_PROTOCOLLN(pos);
|
|
||||||
if(! seekSet(pos) )return false;
|
if(! seekSet(pos) )return false;
|
||||||
if(! gfComputeNextFileBlock() )return false;
|
if(! gfComputeNextFileBlock() )return false;
|
||||||
gfReset();
|
gfReset();
|
||||||
@ -63,11 +59,6 @@ void SdFile::gfReset(){
|
|||||||
gfReadPtr = gfBlockBuffBegin() + gfOffset;
|
gfReadPtr = gfBlockBuffBegin() + gfOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
//FORCE_INLINE const uint8_t * find_endl(const uint8_t *p){
|
|
||||||
// while( *(++p) != '\n' ); // skip until a newline is found
|
|
||||||
// return p;
|
|
||||||
//}
|
|
||||||
|
|
||||||
// think twice before allowing this to inline - manipulating 4B longs is costly
|
// think twice before allowing this to inline - manipulating 4B longs is costly
|
||||||
// moreover - this function has its parameters in registers only, so no heavy stack usage besides the call/ret
|
// moreover - this function has its parameters in registers only, so no heavy stack usage besides the call/ret
|
||||||
void __attribute__((noinline)) SdFile::gfUpdateCurrentPosition(uint16_t inc){
|
void __attribute__((noinline)) SdFile::gfUpdateCurrentPosition(uint16_t inc){
|
||||||
@ -85,21 +76,12 @@ __asm__ __volatile__ ( \
|
|||||||
: "r22" /* modifying register R22 - so that the compiler knows */ \
|
: "r22" /* modifying register R22 - so that the compiler knows */ \
|
||||||
)
|
)
|
||||||
|
|
||||||
//size=400B
|
|
||||||
// avoid calling the default heavy-weight read() for just one byte
|
// avoid calling the default heavy-weight read() for just one byte
|
||||||
int16_t SdFile::readFilteredGcode(){
|
int16_t SdFile::readFilteredGcode(){
|
||||||
if( ! gfEnsureBlock() ){
|
if( ! gfEnsureBlock() ){
|
||||||
goto eof_or_fail; // this is unfortunate :( ... other calls are using the cache and we can loose the data block of our gcode file
|
goto eof_or_fail; // this is unfortunate :( ... other calls are using the cache and we can loose the data block of our gcode file
|
||||||
}
|
}
|
||||||
// assume, we have the 512B block cache filled and terminated with a '\n'
|
// assume, we have the 512B block cache filled and terminated with a '\n'
|
||||||
// SERIAL_PROTOCOLPGM("Read:");
|
|
||||||
// SERIAL_PROTOCOL(curPosition_);
|
|
||||||
// SERIAL_PROTOCOL(':');
|
|
||||||
// for(uint8_t i = 0; i < 16; ++i){
|
|
||||||
// SERIAL_PROTOCOL( gfReadPtr[i] );
|
|
||||||
// }
|
|
||||||
// SERIAL_PROTOCOLLN();
|
|
||||||
// SERIAL_PROTOCOLLN(curPosition_);
|
|
||||||
{
|
{
|
||||||
const uint8_t *start = gfReadPtr;
|
const uint8_t *start = gfReadPtr;
|
||||||
|
|
||||||
@ -152,9 +134,6 @@ int16_t SdFile::readFilteredGcode(){
|
|||||||
rdPtr = start = blockBuffBegin;
|
rdPtr = start = blockBuffBegin;
|
||||||
} else {
|
} else {
|
||||||
if(consecutiveCommentLines >= 250){
|
if(consecutiveCommentLines >= 250){
|
||||||
// SERIAL_ECHO("ccl=");
|
|
||||||
// SERIAL_ECHOLN((int)consecutiveCommentLines);
|
|
||||||
// SERIAL_PROTOCOLLN(sd->curPosition_);
|
|
||||||
--rdPtr; // unget the already consumed newline
|
--rdPtr; // unget the already consumed newline
|
||||||
goto emit_char;
|
goto emit_char;
|
||||||
}
|
}
|
||||||
@ -185,13 +164,6 @@ emit_char:
|
|||||||
rdPtr = blockBuffBegin;
|
rdPtr = blockBuffBegin;
|
||||||
}
|
}
|
||||||
|
|
||||||
// SERIAL_PROTOCOLPGM("c=");
|
|
||||||
// SERIAL_ECHO((char)rv);
|
|
||||||
// SERIAL_ECHO('|');
|
|
||||||
// SERIAL_ECHO((int)rv);
|
|
||||||
// SERIAL_PROTOCOL('|');
|
|
||||||
// SERIAL_PROTOCOLLN(curPosition_);
|
|
||||||
|
|
||||||
// save the current read ptr for the next run
|
// save the current read ptr for the next run
|
||||||
gfReadPtr = rdPtr;
|
gfReadPtr = rdPtr;
|
||||||
return rv;
|
return rv;
|
||||||
@ -200,17 +172,12 @@ emit_char:
|
|||||||
}
|
}
|
||||||
|
|
||||||
eof_or_fail:
|
eof_or_fail:
|
||||||
// SERIAL_PROTOCOLPGM("CacheFAIL:");
|
|
||||||
|
|
||||||
// make the rdptr point to a safe location - end of file
|
// make the rdptr point to a safe location - end of file
|
||||||
gfReadPtr = gfBlockBuffBegin() + 512;
|
gfReadPtr = gfBlockBuffBegin() + 512;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//size=70B
|
|
||||||
bool SdFile::gfEnsureBlock(){
|
bool SdFile::gfEnsureBlock(){
|
||||||
// SERIAL_PROTOCOLPGM("EB:");
|
|
||||||
// SERIAL_PROTOCOLLN(gfBlock);
|
|
||||||
if ( vol_->cacheRawBlock(gfBlock, SdVolume::CACHE_FOR_READ)){
|
if ( vol_->cacheRawBlock(gfBlock, SdVolume::CACHE_FOR_READ)){
|
||||||
// terminate with a '\n'
|
// terminate with a '\n'
|
||||||
const uint16_t terminateOfs = fileSize_ - gfOffset;
|
const uint16_t terminateOfs = fileSize_ - gfOffset;
|
||||||
@ -221,22 +188,6 @@ bool SdFile::gfEnsureBlock(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//#define shr9(resultCurPos, curPos) \
|
|
||||||
//__asm__ __volatile__ ( \
|
|
||||||
//"asr r23 \n" \
|
|
||||||
//"asr r22 \n" \
|
|
||||||
//"asr r21 \n" \
|
|
||||||
//"asr r20 \n" \
|
|
||||||
//"ldi r20, r21 \n" \
|
|
||||||
//"ldi r21, r22 \n" \
|
|
||||||
//"ldi r22, r23 \n" \
|
|
||||||
//"ldi r23, 0 \n" \
|
|
||||||
//: "=a" (resultCurPos) \
|
|
||||||
//: "a" (curPos) \
|
|
||||||
//)
|
|
||||||
|
|
||||||
//size=350B
|
|
||||||
bool SdFile::gfComputeNextFileBlock() {
|
bool SdFile::gfComputeNextFileBlock() {
|
||||||
// error if not open or write only
|
// error if not open or write only
|
||||||
if (!isOpen() || !(flags_ & O_READ)) return false;
|
if (!isOpen() || !(flags_ & O_READ)) return false;
|
||||||
|
@ -38,7 +38,7 @@ class SdFile : public SdBaseFile/*, public Print*/ {
|
|||||||
|
|
||||||
// beware - this read ptr is manipulated inside just 2 methods - readFilteredGcode and gfReset
|
// beware - this read ptr is manipulated inside just 2 methods - readFilteredGcode and gfReset
|
||||||
// If you even want to call gfReset from readFilteredGcode, you must make sure
|
// If you even want to call gfReset from readFilteredGcode, you must make sure
|
||||||
// to update gfCacheP inside readFilteredGcode from a local copy (see explanation of this trick in readFilteredGcode)
|
// to update gfReadPtr inside readFilteredGcode from a local copy (see explanation of this trick in readFilteredGcode)
|
||||||
const uint8_t *gfReadPtr;
|
const uint8_t *gfReadPtr;
|
||||||
|
|
||||||
uint32_t gfBlock; // remember the current file block to be kept in cache - due to reuse of the memory, the block may fall out a must be read back
|
uint32_t gfBlock; // remember the current file block to be kept in cache - due to reuse of the memory, the block may fall out a must be read back
|
||||||
|
@ -456,8 +456,9 @@ void CardReader::openFileWrite(const char* name)
|
|||||||
if(!cardOK)
|
if(!cardOK)
|
||||||
return;
|
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 0
|
||||||
// @@TODO I doubt this is necessary for file saving:
|
// I doubt chained files support is necessary for file saving:
|
||||||
|
// Intentionally disabled because it takes a lot of code size while being not used
|
||||||
|
|
||||||
if((int)file_subcall_ctr>(int)SD_PROCEDURE_DEPTH-1){
|
if((int)file_subcall_ctr>(int)SD_PROCEDURE_DEPTH-1){
|
||||||
// SERIAL_ERROR_START;
|
// SERIAL_ERROR_START;
|
||||||
@ -481,6 +482,9 @@ void CardReader::openFileWrite(const char* name)
|
|||||||
filespos[file_subcall_ctr]=sdpos;
|
filespos[file_subcall_ctr]=sdpos;
|
||||||
file_subcall_ctr++;
|
file_subcall_ctr++;
|
||||||
file.close();
|
file.close();
|
||||||
|
#else
|
||||||
|
SERIAL_ECHOLNPGM("File already opened");
|
||||||
|
#endif
|
||||||
} else { //opening fresh file
|
} else { //opening fresh file
|
||||||
file_subcall_ctr=0; //resetting procedure depth in case user cancels print while in procedure
|
file_subcall_ctr=0; //resetting procedure depth in case user cancels print while in procedure
|
||||||
SERIAL_ECHO_START;
|
SERIAL_ECHO_START;
|
||||||
|
@ -61,12 +61,11 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
FORCE_INLINE bool isFileOpen() { return file.isOpen(); }
|
FORCE_INLINE bool isFileOpen() { return file.isOpen(); }
|
||||||
FORCE_INLINE bool eof() { return sdpos>=filesize ;};
|
bool eof() { return sdpos>=filesize; }
|
||||||
// FORCE_INLINE int16_t getX() { sdpos = file.curPosition();return (int16_t)file.read();};
|
// There may be a potential performance problem - when the comment reading fails, sdpos points to the last correctly read character.
|
||||||
//@@TODO potential performance problem - when the comment reading fails, sdpos points to the last correctly read character.
|
|
||||||
// However, repeated reading (e.g. after power panic) the comment will be read again - it should survive correctly, it will just take a few moments to skip
|
// However, repeated reading (e.g. after power panic) the comment will be read again - it should survive correctly, it will just take a few moments to skip
|
||||||
FORCE_INLINE int16_t getFilteredGcodeChar() { sdpos = file.curPosition();return (int16_t)file.readFilteredGcode();};
|
FORCE_INLINE int16_t getFilteredGcodeChar() { sdpos = file.curPosition();return (int16_t)file.readFilteredGcode();};
|
||||||
/*FORCE_INLINE*/ void setIndex(long index) {sdpos = index;file.seekSetFilteredGcode(index);};
|
void setIndex(long index) {sdpos = index;file.seekSetFilteredGcode(index);};
|
||||||
FORCE_INLINE uint8_t percentDone(){if(!isFileOpen()) return 0; if(filesize) return sdpos/((filesize+99)/100); else return 0;};
|
FORCE_INLINE uint8_t percentDone(){if(!isFileOpen()) return 0; if(filesize) return sdpos/((filesize+99)/100); else return 0;};
|
||||||
FORCE_INLINE char* getWorkDirName(){workDir.getFilename(filename);return filename;};
|
FORCE_INLINE char* getWorkDirName(){workDir.getFilename(filename);return filename;};
|
||||||
FORCE_INLINE uint32_t get_sdpos() { if (!isFileOpen()) return 0; else return(sdpos); };
|
FORCE_INLINE uint32_t get_sdpos() { if (!isFileOpen()) return 0; else return(sdpos); };
|
||||||
|
@ -588,7 +588,7 @@ void get_command()
|
|||||||
char serial_char = (char)n;
|
char serial_char = (char)n;
|
||||||
if( serial_char == '\n'
|
if( serial_char == '\n'
|
||||||
|| serial_char == '\r'
|
|| serial_char == '\r'
|
||||||
|| ((serial_char == '#' || serial_char == ':') /*&& comment_mode == false*/)
|
|| ((serial_char == '#' || serial_char == ':') )
|
||||||
|| serial_count >= (MAX_CMD_SIZE - 1)
|
|| serial_count >= (MAX_CMD_SIZE - 1)
|
||||||
|| n==-1
|
|| n==-1
|
||||||
){
|
){
|
||||||
@ -602,9 +602,7 @@ void get_command()
|
|||||||
// read from the sdcard into sd_count,
|
// read from the sdcard into sd_count,
|
||||||
// so that the lenght of the already read empty lines and comments will be added
|
// so that the lenght of the already read empty lines and comments will be added
|
||||||
// to the following non-empty line.
|
// to the following non-empty line.
|
||||||
// comment_mode = false;
|
|
||||||
return; // prevent cycling indefinitely - let manage_heaters do their job
|
return; // prevent cycling indefinitely - let manage_heaters do their job
|
||||||
// continue; //if empty line
|
|
||||||
}
|
}
|
||||||
// The new command buffer could be updated non-atomically, because it is not yet considered
|
// The new command buffer could be updated non-atomically, because it is not yet considered
|
||||||
// to be inside the active queue.
|
// to be inside the active queue.
|
||||||
@ -620,10 +618,10 @@ void get_command()
|
|||||||
// MYSERIAL.print(sd_count.value, DEC);
|
// MYSERIAL.print(sd_count.value, DEC);
|
||||||
// SERIAL_ECHOPGM(") ");
|
// SERIAL_ECHOPGM(") ");
|
||||||
// SERIAL_ECHOLN(cmdbuffer+bufindw+CMDHDRSIZE);
|
// SERIAL_ECHOLN(cmdbuffer+bufindw+CMDHDRSIZE);
|
||||||
// SERIAL_ECHOPGM("cmdbuffer:");
|
// SERIAL_ECHOPGM("cmdbuffer:");
|
||||||
// MYSERIAL.print(cmdbuffer);
|
// MYSERIAL.print(cmdbuffer);
|
||||||
// SERIAL_ECHOPGM("buflen:");
|
// SERIAL_ECHOPGM("buflen:");
|
||||||
// MYSERIAL.print(buflen+1);
|
// MYSERIAL.print(buflen+1);
|
||||||
sd_count.value = 0;
|
sd_count.value = 0;
|
||||||
|
|
||||||
cli();
|
cli();
|
||||||
@ -640,7 +638,6 @@ void get_command()
|
|||||||
|
|
||||||
comment_mode = false; //for new command
|
comment_mode = false; //for new command
|
||||||
serial_count = 0; //clear buffer
|
serial_count = 0; //clear buffer
|
||||||
// consecutiveEmptyLines = 0; // reached a non-empty line which shall be enqueued
|
|
||||||
|
|
||||||
if(card.eof()) break;
|
if(card.eof()) break;
|
||||||
|
|
||||||
@ -650,8 +647,6 @@ void get_command()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/*if(serial_char == ';') comment_mode = true;
|
|
||||||
else if(!comment_mode)*/
|
|
||||||
// there are no comments coming from the filtered file
|
// there are no comments coming from the filtered file
|
||||||
cmdbuffer[bufindw+CMDHDRSIZE+serial_count++] = serial_char;
|
cmdbuffer[bufindw+CMDHDRSIZE+serial_count++] = serial_char;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user