From 1d518edb7e78114ccca80b1ad9752b9804b2fce4 Mon Sep 17 00:00:00 2001 From: Bob Applegate Date: Fri, 8 May 2020 08:53:09 -0400 Subject: [PATCH] Fixed sector update, fixed version number reported, removed one useless debug message, changed version number to 1.4 --- Disk.cpp | 22 +++++++++++++++------- SD_Drive.ino | 13 +++++++------ 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/Disk.cpp b/Disk.cpp index 9db0bf1..3d5c3eb 100644 --- a/Disk.cpp +++ b/Disk.cpp @@ -93,7 +93,7 @@ bool Disk::mount(char *afilename, bool readOnly) } else { - openFlag = FILE_WRITE; + openFlag = O_RDWR; } // Open the file! @@ -202,7 +202,11 @@ bool Disk::write(unsigned long offset, byte *buf) } else { - file.seek(offset); + if (file.seek(offset) == false) + { + Serial.print("Failed seeing to offset "); + Serial.println(offset); + } if (file.available() < SECTOR_SIZE) { Serial.print("Not enough bytes: "); @@ -226,9 +230,15 @@ bool Disk::write(unsigned long offset, byte *buf) else { ret = true; // success! -// Serial.print("Just wrote "); -// Serial.print(wrote); -// Serial.println(" bytes"); +#if 0 + Serial.print("Just wrote "); + Serial.print(wrote); + Serial.print(" bytes at offset "); + Serial.println(offset); +#endif +#ifdef DUMP_SECTORS + hexdump(buf, SECTOR_SIZE); +#endif } } } @@ -269,5 +279,3 @@ byte Disk::getStatus(void) return ret; } - - diff --git a/SD_Drive.ino b/SD_Drive.ino index 9f068c4..e050bf6 100644 --- a/SD_Drive.ino +++ b/SD_Drive.ino @@ -61,7 +61,10 @@ // // Revision 1.3: // * General code clean-up. Added debounce code for all digital inputs. - +// +// Revision 1.4: +// * Fixed bug that caused all DSK file updates to be appended rather than applied +// to the requested sector. Removed a bit of excess debugging output. #include @@ -149,7 +152,7 @@ void setup() Serial.begin(9600); Serial.println(""); - Serial.println("SD Drive version 1.3"); + Serial.println("SD Drive version 1.4"); Serial.println("Brought to you by Bob Applegate and Corsham Technologies"); Serial.println("bob@corshamtech.com, www.corshamtech.com"); @@ -394,7 +397,7 @@ static bool processEvent(Event *ep) { ep->clean(EVT_VERSION_INFO); // same event type but clear all other data byte *ptr = ep->getData(); - strcpy((char *)ptr, "Corsham Technology\r\nv0.1"); + strcpy((char *)ptr, "Corsham Technology\r\nv1.4"); link->sendEvent(ep); break; } @@ -507,7 +510,7 @@ static void readSector(Event *ep) byte drive = *bptr++; byte sectorSize = *bptr++; // note used for now unsigned long track = (unsigned long)(*bptr++); - Serial.println(*bptr); + //Serial.println(*bptr); unsigned long sector = (unsigned long)(*bptr++); unsigned long sectorsPerTrack = (unsigned long)(*bptr++); @@ -949,5 +952,3 @@ bool debounceInputPin(int pin) return val; } - -