Skip to content

Commit

Permalink
initiator: dont make user grep through file to see if there were bad …
Browse files Browse the repository at this point in the history
…sectors, just tell them at the end.
  • Loading branch information
erichelgeson committed Feb 11, 2024
1 parent b4cf5b7 commit 71ce1da
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/BlueSCSI_initiator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ static struct {
uint32_t sectorcount_all;
uint32_t sectors_done;
uint32_t max_sector_per_transfer;
uint32_t badSectorCount;
uint8_t ansiVersion;

// Retry information for sector reads.
Expand Down Expand Up @@ -99,6 +100,7 @@ void scsiInitiatorInit()
g_initiator_state.failposition = 0;
g_initiator_state.max_sector_per_transfer = 512;
g_initiator_state.ansiVersion = 0;
g_initiator_state.badSectorCount = 0;
}

// Update progress bar LED during transfers
Expand Down Expand Up @@ -151,6 +153,7 @@ void scsiInitiatorMainLoop()
g_initiator_state.sectors_done = 0;
g_initiator_state.retrycount = 0;
g_initiator_state.max_sector_per_transfer = 512;
g_initiator_state.badSectorCount = 0;

if (!(g_initiator_state.drives_imaged & (1 << g_initiator_state.target_id)))
{
Expand Down Expand Up @@ -286,6 +289,11 @@ void scsiInitiatorMainLoop()
log("Please reformat the SD card with exFAT format to image this drive fully");
}

if(g_initiator_state.badSectorCount != 0)
{
log_f("NOTE: There were %d bad sectors that could not be read off this drive.", g_initiator_state.badSectorCount);
}

g_initiator_state.drives_imaged |= (1 << g_initiator_state.target_id);
g_initiator_state.imaging = false;
g_initiator_state.target_file.close();
Expand Down Expand Up @@ -334,6 +342,7 @@ void scsiInitiatorMainLoop()
log("Retry limit exceeded, skipping one sector");
g_initiator_state.retrycount = 0;
g_initiator_state.sectors_done++;
g_initiator_state.badSectorCount++;
g_initiator_state.target_file.seek((uint64_t)g_initiator_state.sectors_done * g_initiator_state.sectorsize);
}
}
Expand Down

0 comments on commit 71ce1da

Please sign in to comment.