Remove commented debug code

the whole PR is ready for review after successfull tests
This commit is contained in:
D.R.racer 2021-02-10 11:18:59 +01:00
parent 15d76a7501
commit c1ead75a73
6 changed files with 18 additions and 71 deletions

View File

@ -3987,12 +3987,10 @@ void process_commands()
#endif
}else if (code_seen_P("fv")) { // PRUSA fv
// get file version
#if 0
//@@TODO
def SDSUPPORT
card.openFile(strchr_pointer + 3,true);
#ifdef SDSUPPORT
card.openFileReadFilteredGcode(strchr_pointer + 3,true);
while (true) {
uint16_t readByte = card.get();
uint16_t readByte = card.getFilteredGcodeChar();
MYSERIAL.write(readByte);
if (readByte=='\n') {
break;

View File

@ -31,7 +31,6 @@
SdFile::SdFile(const char* path, uint8_t oflag) : SdBaseFile(path, oflag) {
}
//size=100B
bool SdFile::openFilteredGcode(SdBaseFile* dirFile, const char* path){
if( open(dirFile, path, O_READ) ){
// 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){
// SERIAL_PROTOCOLPGM("Seek:");
// SERIAL_PROTOCOLLN(pos);
if(! seekSet(pos) )return false;
if(! gfComputeNextFileBlock() )return false;
gfReset();
@ -63,11 +59,6 @@ void SdFile::gfReset(){
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
// 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){
@ -85,21 +76,12 @@ __asm__ __volatile__ ( \
: "r22" /* modifying register R22 - so that the compiler knows */ \
)
//size=400B
// avoid calling the default heavy-weight read() for just one byte
int16_t SdFile::readFilteredGcode(){
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
}
// 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;
@ -152,9 +134,6 @@ int16_t SdFile::readFilteredGcode(){
rdPtr = start = blockBuffBegin;
} else {
if(consecutiveCommentLines >= 250){
// SERIAL_ECHO("ccl=");
// SERIAL_ECHOLN((int)consecutiveCommentLines);
// SERIAL_PROTOCOLLN(sd->curPosition_);
--rdPtr; // unget the already consumed newline
goto emit_char;
}
@ -185,13 +164,6 @@ emit_char:
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
gfReadPtr = rdPtr;
return rv;
@ -200,17 +172,12 @@ emit_char:
}
eof_or_fail:
// SERIAL_PROTOCOLPGM("CacheFAIL:");
// make the rdptr point to a safe location - end of file
gfReadPtr = gfBlockBuffBegin() + 512;
return -1;
}
//size=70B
bool SdFile::gfEnsureBlock(){
// SERIAL_PROTOCOLPGM("EB:");
// SERIAL_PROTOCOLLN(gfBlock);
if ( vol_->cacheRawBlock(gfBlock, SdVolume::CACHE_FOR_READ)){
// terminate with a '\n'
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() {
// error if not open or write only
if (!isOpen() || !(flags_ & O_READ)) return false;

View File

@ -38,7 +38,7 @@ class SdFile : public SdBaseFile/*, public Print*/ {
// 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
// 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;
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

View File

@ -456,8 +456,9 @@ void CardReader::openFileWrite(const char* name)
if(!cardOK)
return;
if(file.isOpen()){ //replacing current file by new file, or subfile call
// @@TODO I doubt this is necessary for file saving:
#if 0
// 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){
// SERIAL_ERROR_START;
@ -481,6 +482,9 @@ void CardReader::openFileWrite(const char* name)
filespos[file_subcall_ctr]=sdpos;
file_subcall_ctr++;
file.close();
#else
SERIAL_ECHOLNPGM("File already opened");
#endif
} else { //opening fresh file
file_subcall_ctr=0; //resetting procedure depth in case user cancels print while in procedure
SERIAL_ECHO_START;

View File

@ -61,12 +61,11 @@ public:
#endif
FORCE_INLINE bool isFileOpen() { return file.isOpen(); }
FORCE_INLINE bool eof() { return sdpos>=filesize ;};
// FORCE_INLINE int16_t getX() { sdpos = file.curPosition();return (int16_t)file.read();};
//@@TODO potential performance problem - when the comment reading fails, sdpos points to the last correctly read character.
bool eof() { return sdpos>=filesize; }
// There may be a 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
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 char* getWorkDirName(){workDir.getFilename(filename);return filename;};
FORCE_INLINE uint32_t get_sdpos() { if (!isFileOpen()) return 0; else return(sdpos); };

View File

@ -588,7 +588,7 @@ void get_command()
char serial_char = (char)n;
if( serial_char == '\n'
|| serial_char == '\r'
|| ((serial_char == '#' || serial_char == ':') /*&& comment_mode == false*/)
|| ((serial_char == '#' || serial_char == ':') )
|| serial_count >= (MAX_CMD_SIZE - 1)
|| n==-1
){
@ -602,9 +602,7 @@ void get_command()
// read from the sdcard into sd_count,
// so that the lenght of the already read empty lines and comments will be added
// to the following non-empty line.
// comment_mode = false;
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
// to be inside the active queue.
@ -620,10 +618,10 @@ void get_command()
// MYSERIAL.print(sd_count.value, DEC);
// SERIAL_ECHOPGM(") ");
// SERIAL_ECHOLN(cmdbuffer+bufindw+CMDHDRSIZE);
// SERIAL_ECHOPGM("cmdbuffer:");
// MYSERIAL.print(cmdbuffer);
// SERIAL_ECHOPGM("buflen:");
// MYSERIAL.print(buflen+1);
// SERIAL_ECHOPGM("cmdbuffer:");
// MYSERIAL.print(cmdbuffer);
// SERIAL_ECHOPGM("buflen:");
// MYSERIAL.print(buflen+1);
sd_count.value = 0;
cli();
@ -640,7 +638,6 @@ void get_command()
comment_mode = false; //for new command
serial_count = 0; //clear buffer
// consecutiveEmptyLines = 0; // reached a non-empty line which shall be enqueued
if(card.eof()) break;
@ -650,8 +647,6 @@ void get_command()
}
else
{
/*if(serial_char == ';') comment_mode = true;
else if(!comment_mode)*/
// there are no comments coming from the filtered file
cmdbuffer[bufindw+CMDHDRSIZE+serial_count++] = serial_char;
}