diff options
author | sanni <[email protected]> | 2023-10-17 22:07:51 +0200 |
---|---|---|
committer | sanni <[email protected]> | 2023-10-17 22:07:51 +0200 |
commit | 029c33dfb905fd08f3b3fef8a4bfec26f3ae5843 (patch) | |
tree | 37b05bc91712c823ac870c4e137ca6c5dd4edbd6 | |
parent | 2e72842bb19143af2a5ec283df0c7846da4ddb58 (diff) | |
download | cartreader-029c33dfb905fd08f3b3fef8a4bfec26f3ae5843.tar.gz cartreader-029c33dfb905fd08f3b3fef8a4bfec26f3ae5843.zip |
N64: Add error message if eeprom does not return data
Should prevent problem as described in discussion #857
-rw-r--r-- | Cart_Reader/N64.ino | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/Cart_Reader/N64.ino b/Cart_Reader/N64.ino index 2aac5bd..dd831f6 100644 --- a/Cart_Reader/N64.ino +++ b/Cart_Reader/N64.ino @@ -2256,7 +2256,7 @@ void writeEeprom() { }
}
-void readEepromPageList(byte* output, byte page_number, byte page_count) {
+boolean readEepromPageList(byte* output, byte page_number, byte page_count) {
byte command[] = { 0x04, page_number };
// Disable interrupts for more uniform clock pulses
@@ -2267,7 +2267,12 @@ void readEepromPageList(byte* output, byte page_number, byte page_count) { noInterrupts();
sendJoyBus(command, sizeof(command));
// XXX: is it possible to read more than 8 bytes at a time ?
- recvJoyBus(output, 8);
+ if (recvJoyBus(output, 8) > 0) {
+ // If any missing bytes error out
+ interrupts();
+ return 0;
+ break;
+ }
interrupts();
if (page_count)
@@ -2276,6 +2281,7 @@ void readEepromPageList(byte* output, byte page_number, byte page_count) { command[1]++;
output += 8;
}
+ return 1;
}
// Dump Eeprom to SD
@@ -2300,14 +2306,19 @@ void readEeprom() { }
for (int i = 0; i < eepPages; i += sizeof(sdBuffer) / 8) {
- readEepromPageList(sdBuffer, i, sizeof(sdBuffer) / 8);
+ // If any missing bytes error out
+ if (readEepromPageList(sdBuffer, i, sizeof(sdBuffer) / 8) == 0) {
+ println_Msg(F(""));
+ print_STR(error_STR, 0);
+ println_Msg(F("no data received"));
+ println_Msg(F(""));
+ break;
+ }
// Write 64 pages at once to the SD card
myFile.write(sdBuffer, sizeof(sdBuffer));
}
// Close the file:
myFile.close();
- //clear the screen
- display_Clear();
print_Msg(F("Saved to "));
print_Msg(folder);
println_Msg(F("/"));
|