bool eeDuplicateModel(uint8_t id) { uint8_t i; for( i=id+1; i<MAX_MODELS; i++) { if(! EFile::exists(FILE_MODEL(i))) break; } if(i==MAX_MODELS) return false; //no free space in directory left theFile.openRd(FILE_MODEL(id)); theFile2.create(FILE_MODEL(i),FILE_TYP_MODEL,600); uint8_t buf[15]; uint8_t l; while((l=theFile.read(buf,15))) { theFile2.write(buf,l); // if(theFile.write_errno()==ERR_TMO) // { // //wait for 10ms and try again // uint16_t tgtime = get_tmr10ms() + 100; // while (!=tgtime); // theFile2.write(buf,l); // } wdt_reset(); } theFile2.closeTrunc(); //todo error handling return true; }
bool eeDuplicateModel(uint8_t id) { uint8_t i; for( i=id+1; i<MAX_MODELS; i++) { if(! EFile::exists(FILE_MODEL(i))) break; } if(i==MAX_MODELS) return false; //no free space in directory left theFile.openRd(FILE_MODEL(id)); theFile2.create(FILE_MODEL(i),FILE_TYP_MODEL,200); uint8_t buf[15]; uint8_t l; while((l=theFile.read(buf,15))) { theFile2.write(buf,l); wdt_reset(); } theFile2.closeTrunc(); //todo error handling return true; }