Skip to content

Commit

Permalink
Fix handling of special filename NONE for unmounted unit.
Browse files Browse the repository at this point in the history
  • Loading branch information
AK6DN committed Jun 28, 2017
1 parent fbcb807 commit ddecb03
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
6 changes: 3 additions & 3 deletions rx02_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -832,11 +832,11 @@ char *rx_unit_file (uint8_t unit, char *name)
// zap the deleted data state to normal
memset(rx.drv[unit].dd, RX_DATA_NORMAL, sizeof(rx.drv[unit].dd));

// special file name of "NONE" (any capitalization) maps to an unmounted drive
if (strcasecmp(rx.drv[unit].name, "NONE") == 0) {
// special file name (any capitalization) maps to an unmounted drive
if (strcasecmp(rx.drv[unit].name, RX_FILENAME_NONE) == 0) {
// no online disk
rx.drv[unit].rdy = FALSE;
rx.drv[unit].den = RX_DEN_SD;
rx.drv[unit].den = (rx.type == RX_TYPE_RX01) ? RX_DEN_SD : RX_DEN_DD;
rx.drv[unit].mode = RX_FILE_READ_ONLY;
// return the name
return rx.drv[unit].name;
Expand Down
4 changes: 4 additions & 0 deletions rx02_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@
#define RX_FILE_READ_WRITE 0 // file is read write (default)
#define RX_FILE_READ_ONLY 1 // file is read only

// special filename(s)
//
#define RX_FILENAME_NONE "NONE" // special filename for unmounted file

// drive density
//
#define RX_DEN_SD 0 // single density mode (128B/sector)
Expand Down
11 changes: 5 additions & 6 deletions rx02_emulator.ino
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
#define DEBUG_TU58 0

// program version id
#define VERSION "v1.8"
#define VERSION "v1.9"

// baud rate for USB serial debug port
//
Expand All @@ -63,10 +63,9 @@
//
#if ARDUINO >= 10802
// IDE 1.8.2 and later enable 500Kb, 1Mb, and 2Mb baud rates.
// Note last baud rate listed will be the one used.
#define SERIAL_BAUD_RATE 2000000L
#define SERIAL_BAUD_RATE 1000000L
#define SERIAL_BAUD_RATE 500000L
//#define SERIAL_BAUD_RATE 2000000L
//#define SERIAL_BAUD_RATE 1000000L
//#define SERIAL_BAUD_RATE 500000L
#define SERIAL_BAUD_RATE 250000L
#else
// IDE 1.8.1 and earlier 250Kb is the max baud rate.
Expand Down Expand Up @@ -210,7 +209,7 @@ void run_command (char *cmd)
}
tty->printf(F("Setting file[%d]: '%s'\n"), i, rx_unit_file(i, arg));
size = sd_get_file_size(arg);
if (size != rx_dsk_size(RX_DEN_SD) && size != rx_dsk_size(RX_DEN_DD)) {
if (size != 0 && size != rx_dsk_size(RX_DEN_SD) && size != rx_dsk_size(RX_DEN_DD)) {
tty->printf(F("WARNING: file size not SD or DD ... use E/F command to correct!\n"));
} else if (size == rx_dsk_size(RX_DEN_DD) && rx_emulation_type() == RX_TYPE_RX01) {
tty->printf(F("WARNING: file size DD mounted in mode RX01!\n"));
Expand Down
3 changes: 3 additions & 0 deletions sdcard_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,9 @@ uint32_t sd_get_file_size (char *name)
// error if not setup
if (!initOk) return 0;

// missing files have zero size
if (!sdcard.exists(name)) return 0;

// close existing file, if open
if (sdfile.isOpen()) sdfile.close();

Expand Down

0 comments on commit ddecb03

Please sign in to comment.