Skip to content

Commit

Permalink
Fixed sector update, fixed version number reported, removed one usele…
Browse files Browse the repository at this point in the history
…ss debug message, changed version number to 1.4
  • Loading branch information
CorshamTech committed May 8, 2020
1 parent 4eb43e6 commit 1d518ed
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
22 changes: 15 additions & 7 deletions Disk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ bool Disk::mount(char *afilename, bool readOnly)
}
else
{
openFlag = FILE_WRITE;
openFlag = O_RDWR;
}

// Open the file!
Expand Down Expand Up @@ -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: ");
Expand All @@ -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
}
}
}
Expand Down Expand Up @@ -269,5 +279,3 @@ byte Disk::getStatus(void)

return ret;
}


13 changes: 7 additions & 6 deletions SD_Drive.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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 <Arduino.h>

Expand Down Expand Up @@ -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("[email protected], www.corshamtech.com");

Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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++);

Expand Down Expand Up @@ -949,5 +952,3 @@ bool debounceInputPin(int pin)

return val;
}


0 comments on commit 1d518ed

Please sign in to comment.