mirror of
https://github.com/sanni/cartreader.git
synced 2024-11-30 16:34:14 +01:00
Copy latest log to dump dir
This commit is contained in:
parent
f0639e20ad
commit
fac6f8eab2
@ -4,7 +4,7 @@
|
|||||||
This project represents a community-driven effort to provide
|
This project represents a community-driven effort to provide
|
||||||
an easy to build and easy to modify cartridge dumper.
|
an easy to build and easy to modify cartridge dumper.
|
||||||
|
|
||||||
Date: 14.06.2022
|
Date: 16.06.2022
|
||||||
Version: 8.5 BETA
|
Version: 8.5 BETA
|
||||||
|
|
||||||
SD lib: https://github.com/greiman/SdFat
|
SD lib: https://github.com/greiman/SdFat
|
||||||
@ -907,7 +907,87 @@ void wait() {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_Msg(const __FlashStringHelper *string) {
|
#ifdef global_log
|
||||||
|
// Copies the last part of the current log file to the dump folder
|
||||||
|
void save_log() {
|
||||||
|
// Last found position
|
||||||
|
uint64_t lastPosition = 0;
|
||||||
|
|
||||||
|
// Go to first line of log
|
||||||
|
myLog.rewind();
|
||||||
|
|
||||||
|
// Find location of OSCR string to determine start of current log
|
||||||
|
char tempStr[5];
|
||||||
|
while (myLog.available()) {
|
||||||
|
// Read first 4 chars of line
|
||||||
|
tempStr[0] = myLog.read();
|
||||||
|
|
||||||
|
// Check if it's an empty line
|
||||||
|
if (tempStr[0] == '\r') {
|
||||||
|
// skip \n
|
||||||
|
myLog.read();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Read more lines
|
||||||
|
tempStr[1] = myLog.read();
|
||||||
|
tempStr[2] = myLog.read();
|
||||||
|
tempStr[3] = myLog.read();
|
||||||
|
tempStr[4] = '\0';
|
||||||
|
char str_buf;
|
||||||
|
|
||||||
|
// Skip rest of line
|
||||||
|
while (myLog.available()) {
|
||||||
|
str_buf = myLog.read();
|
||||||
|
|
||||||
|
//break out of loop if CRLF is found
|
||||||
|
if (str_buf == '\r')
|
||||||
|
{
|
||||||
|
myLog.read(); //dispose \n because \r\n
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If string is OSCR remember position in file and test if it's the lastest log entry
|
||||||
|
if (strncmp(tempStr, "OSCR", 4) == 0) {
|
||||||
|
// Check if current position is newer as old position
|
||||||
|
if (myLog.position() > lastPosition) {
|
||||||
|
lastPosition = myLog.position();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Go to position of last log entry
|
||||||
|
myLog.seek(lastPosition - 16);
|
||||||
|
|
||||||
|
// Copy log from there to dump dir
|
||||||
|
sd.chdir(folder);
|
||||||
|
strcpy(fileName, romName);
|
||||||
|
strcat(fileName, ".txt");
|
||||||
|
if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
|
||||||
|
print_Error(F("SD Error"), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
while (myLog.available()) {
|
||||||
|
if (myLog.available() >= 512) {
|
||||||
|
for (word i = 0; i < 512; i++) {
|
||||||
|
sdBuffer[i] = myLog.read();
|
||||||
|
}
|
||||||
|
myFile.write(sdBuffer, 512);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
word i = 0;
|
||||||
|
for (i = 0; i < myLog.available(); i++) {
|
||||||
|
sdBuffer[i] = myLog.read();
|
||||||
|
}
|
||||||
|
myFile.write(sdBuffer, i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Close the file:
|
||||||
|
myFile.close();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void print_Msg(const __FlashStringHelper * string) {
|
||||||
#ifdef enable_LCD
|
#ifdef enable_LCD
|
||||||
display.print(string);
|
display.print(string);
|
||||||
#endif
|
#endif
|
||||||
@ -1082,7 +1162,7 @@ void println_Msg(const char myString[]) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void println_Msg(const __FlashStringHelper *string) {
|
void println_Msg(const __FlashStringHelper * string) {
|
||||||
#ifdef enable_LCD
|
#ifdef enable_LCD
|
||||||
display.print(string);
|
display.print(string);
|
||||||
display.setCursor(0, display.ty + 8);
|
display.setCursor(0, display.ty + 8);
|
||||||
@ -1147,7 +1227,7 @@ void display_Clear() {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char question_box(const __FlashStringHelper* question, char answers[7][20], int num_answers, int default_choice) {
|
unsigned char question_box(const __FlashStringHelper * question, char answers[7][20], int num_answers, int default_choice) {
|
||||||
#ifdef enable_LCD
|
#ifdef enable_LCD
|
||||||
return questionBox_LCD(question, answers, num_answers, default_choice);
|
return questionBox_LCD(question, answers, num_answers, default_choice);
|
||||||
#endif
|
#endif
|
||||||
@ -1206,7 +1286,7 @@ void wait_serial() {
|
|||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
byte questionBox_Serial(const __FlashStringHelper* question, char answers[7][20], int num_answers, int default_choice) {
|
byte questionBox_Serial(const __FlashStringHelper * question, char answers[7][20], int num_answers, int default_choice) {
|
||||||
// Print menu to serial monitor
|
// Print menu to serial monitor
|
||||||
//Serial.println(question);
|
//Serial.println(question);
|
||||||
Serial.println("");
|
Serial.println("");
|
||||||
|
@ -300,6 +300,9 @@ void gbMenu() {
|
|||||||
sd.chdir("/");
|
sd.chdir("/");
|
||||||
readROM_GB();
|
readROM_GB();
|
||||||
compare_checksums_GB();
|
compare_checksums_GB();
|
||||||
|
#ifdef global_log
|
||||||
|
save_log();
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
@ -997,7 +1000,7 @@ void compare_checksums_GB() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
println_Msg("gb.txt not found");
|
println_Msg(" -> gb.txt not found");
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
println_Msg("");
|
println_Msg("");
|
||||||
|
@ -128,6 +128,9 @@ void gbaMenu() {
|
|||||||
readROM_GBA();
|
readROM_GBA();
|
||||||
sd.chdir("/");
|
sd.chdir("/");
|
||||||
compare_checksum_GBA();
|
compare_checksum_GBA();
|
||||||
|
#ifdef global_log
|
||||||
|
save_log();
|
||||||
|
#endif
|
||||||
println_Msg(F(""));
|
println_Msg(F(""));
|
||||||
println_Msg(F("Press Button..."));
|
println_Msg(F("Press Button..."));
|
||||||
display_Update();
|
display_Update();
|
||||||
|
@ -311,6 +311,9 @@ void mdCartMenu() {
|
|||||||
else
|
else
|
||||||
readROM_MD();
|
readROM_MD();
|
||||||
//compare_checksum_MD();
|
//compare_checksum_MD();
|
||||||
|
#ifdef global_log
|
||||||
|
save_log();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
print_Error(F("Cart has no ROM"), false);
|
print_Error(F("Cart has no ROM"), false);
|
||||||
|
@ -3575,6 +3575,9 @@ redumpsamefolder:
|
|||||||
// This saves a tt file with rom info next to the dumped rom
|
// This saves a tt file with rom info next to the dumped rom
|
||||||
#ifdef savesummarytotxt
|
#ifdef savesummarytotxt
|
||||||
savesummary_N64(1, crcStr, timeElapsed);
|
savesummary_N64(1, crcStr, timeElapsed);
|
||||||
|
#endif
|
||||||
|
#ifdef global_log
|
||||||
|
save_log();
|
||||||
#endif
|
#endif
|
||||||
wait();
|
wait();
|
||||||
}
|
}
|
||||||
|
@ -246,6 +246,9 @@ void nesMenu() {
|
|||||||
delay(2000);
|
delay(2000);
|
||||||
resetROM();
|
resetROM();
|
||||||
CartFinish();
|
CartFinish();
|
||||||
|
#ifdef global_log
|
||||||
|
save_log();
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Read single chip
|
// Read single chip
|
||||||
|
@ -68,6 +68,9 @@ void _smsMenu() {
|
|||||||
// Change working dir to root
|
// Change working dir to root
|
||||||
sd.chdir("/");
|
sd.chdir("/");
|
||||||
readROM_SMS();
|
readROM_SMS();
|
||||||
|
#ifdef global_log
|
||||||
|
save_log();
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
|
@ -216,10 +216,14 @@ void snesMenu() {
|
|||||||
// start reading from cart
|
// start reading from cart
|
||||||
readROM_SNES();
|
readROM_SNES();
|
||||||
compare_checksum();
|
compare_checksum();
|
||||||
|
|
||||||
// print elapsed time
|
// print elapsed time
|
||||||
print_Msg(F("Time elapsed: "));
|
print_Msg(F("Time elapsed: "));
|
||||||
print_Msg((millis() - startTime) / 1000);
|
print_Msg((millis() - startTime) / 1000);
|
||||||
println_Msg(F("s"));
|
println_Msg(F("s"));
|
||||||
|
#ifdef global_log
|
||||||
|
save_log();
|
||||||
|
#endif
|
||||||
display_Update();
|
display_Update();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
Loading…
Reference in New Issue
Block a user