Skip to content

Commit

Permalink
Added processing of .RX1/.RX2 file extensions for SD/DD media detection.
Browse files Browse the repository at this point in the history
Updated readme; fixed a couple of typos.
  • Loading branch information
AK6DN committed Dec 5, 2016
1 parent ee83562 commit 458a435
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 12 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<B>rx02_emulator</B> is a hardware/software emulation of a DEC RX02 dual 8" floppy disk drive. The software runs on an Arduino Mega2560 processor board with a custom hardware interface shield that maps a dozen or so digital port bits to the custom DEC RX02 interface hardware protocol.
<B>rx02_emulator</B> is a hardware/software emulation of a DEC RX02 (or RX01) dual 8" floppy disk drive. The software runs on an Arduino Mega2560 processor board with a custom hardware interface shield that maps a dozen or so digital port bits to the custom DEC RX drive interface protocol.

The emulator simulates two RX02 drives mapped to files on an attached MicroSD card.

Expand All @@ -10,6 +10,8 @@ Testing to date has been performed as an RX02/RX211 interface combo in a UNIBUS

The MicroSD card in the emulator is a FAT32 formatted filesystem, and it can be inserted (offline) into a WindowsPC to copy files to/from the device. By default, the files 'RX0.DSK' and 'RX1.DSK' are mapped to drive 0 and 1 on initialization.

Detection of single density media (SD; 256,256 bytes total) and double density media (DD; 512,512 bytes total) is done thru two differrent mechanisms. Files with the extension .RX1 will be forced to be SD, and resized appropriately (zero padded at the end, and truncated to size if required). Similarly files with the extension .RX2 will be forced to DD, and resized if necessary. Files with any other extension (ie, like .DSK) will be detected as SD if they are EXACTLY 256,256 bytes in size; and detected as DD if they are EXACTLY 512,512 bytes in size. Files that are other sizes will NOT be capable of being mounted until they are resized appropriately (the E and F commands can do this).

The emulator interfaces thru a simple ASCII terminal command line via the USB port on the Arduino device. After booting, typing: H<cr> types out the available commands. Here is a sample interaction showing the use of the H, L, S and 0 commands, and the debug level 1 log of what happens when 'b dy0' is typed on the attached PDP-11/44 console terminal.

Startup configuration is saved in an ASCII text file SETUP.INI that contains user interface commands that are replayed on startup. The SETUP.INI file is written using the W command, and the current 0/1/Y/N/D/M/T options are saved in the file.
Expand All @@ -25,7 +27,7 @@ Normal operation will see the GRN/YEL LEDs blinking rapidly or mostly ON. For no

Sample boot log in the Arduino USB serial monitor window:
```
RX02 Emulator v1.5 - Nov 11 2016 - 23:47:10
RX02 Emulator v1.6 (IDE 1.6.13/gcc 4.9.2) - Dec 4 2016 - 12:34:56
SD: cardType=SD3
SD: cardSize=3781MB
Expand Down Expand Up @@ -151,6 +153,6 @@ Refer to: http://playground.arduino.cc/Main/Printf for instructions on how to

(3) This code was written with tap stops set at 4 (versus the default of 2). Manually edit the Arduino <B>preferences.txt</B> file tab size line to be: <B>editor.tabs.size=4</B> if desired.

(4) Right now there is a lot of 'extraneous' code (ie, the TU58 driver interface) that is included by default but not currently used. A future plan is to add support to map a backend TU58 server to a file connection (ie, by using a pseudo filename) so that not only local MicroSD card file access can be supported, but simultaenous access to a backend PC-based file storage server can happen.
(4) Right now there is some 'extraneous' code (ie, the TU58 driver interface) that is included by default but not currently used. A future plan is to add support to map a backend TU58 server to a file connection (ie, by using a pseudo filename) so that not only local MicroSD card file access can be supported, but simultaenous access to a backend PC-based file storage server can happen.

Don
35 changes: 26 additions & 9 deletions rx02_emulator.ino
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@
//
#define USE_TU58 0
#define TEST_TU58 0
#define DEBUG_TU58
#define DEBUG_TU58 0

// program version id
#define VERSION "v1.5"
#define VERSION "v1.6"

// baud rate for USB serial debug port
//
Expand Down Expand Up @@ -183,6 +183,14 @@ void run_command (char *cmd)
case '1':
i = *cmd-'0';
if (arg) {
size = sd_get_file_size(arg);
if (sd_file_ext_matches(arg, ".RX1") && size != rx_dsk_size(RX_DEN_SD)) {
size = sd_set_file_size(arg, rx_dsk_size(RX_DEN_SD), SD_POS_AT_END);
tty->printf(F("Updated file: '%s' to %lu. bytes\n"), arg, size);
} else if (sd_file_ext_matches(arg, ".RX2") && size != rx_dsk_size(RX_DEN_DD)) {
size = sd_set_file_size(arg, rx_dsk_size(RX_DEN_DD), SD_POS_AT_END);
tty->printf(F("Updated file: '%s' to %lu. bytes\n"), arg, size);
}
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)) {
Expand All @@ -204,12 +212,15 @@ void run_command (char *cmd)
}
break;

// "e FILENAME" extend/create file name as single density sized
// "e FILENAME" extend/create file name as single density sized (but not .RX2 files)
case 'E':
if (arg) {
if (sd_get_file_size(arg) == rx_dsk_size(RX_DEN_SD)) {
size = sd_get_file_size(arg);
if (sd_file_ext_matches(arg, ".RX2")) {
tty->printf(F("Unchanged file: '%s' is %lu. bytes (use F command)\n"), arg, size);
} else if (size == rx_dsk_size(RX_DEN_SD)) {
tty->printf(F("Unchanged file: '%s' is %lu. bytes (SD)\n"), arg, size);
} else if (sd_get_file_size(arg) < rx_dsk_size(RX_DEN_SD)) {
} else if (size < rx_dsk_size(RX_DEN_SD)) {
size = sd_set_file_size(arg, rx_dsk_size(RX_DEN_SD), SD_POS_AT_END);
tty->printf(F("Extended file: '%s' to %lu. bytes (SD)\n"), arg, size);
} else {
Expand All @@ -219,12 +230,15 @@ void run_command (char *cmd)
}
break;

// "f FILENAME" extend/create file name as double density sized
// "f FILENAME" extend/create file name as double density sized (but not .RX1 files)
case 'F':
if (arg) {
if (sd_get_file_size(arg) == rx_dsk_size(RX_DEN_DD)) {
size = sd_get_file_size(arg);
if (sd_file_ext_matches(arg, ".RX1")) {
tty->printf(F("Unchanged file: '%s' is %lu. bytes (use E command)\n"), arg, size);
} else if (size == rx_dsk_size(RX_DEN_DD)) {
tty->printf(F("Unchanged file: '%s' is %lu. bytes (DD)\n"), arg, size);
} else if (sd_get_file_size(arg) < rx_dsk_size(RX_DEN_DD)) {
} else if (size < rx_dsk_size(RX_DEN_DD)) {
size = sd_set_file_size(arg, rx_dsk_size(RX_DEN_DD), SD_POS_AT_END);
tty->printf(F("Extended file: '%s' to %lu. bytes (DD)\n"), arg, size);
} else {
Expand Down Expand Up @@ -549,7 +563,10 @@ void setup (void)
led_initialize();

// say hello
tty->printf(F("RX02 Emulator %s - %s - %s\n"), VERSION, __DATE__, __TIME__);
tty->printf(F("RX02 Emulator %s (IDE %u.%u.%u/gcc %s) - %s - %s\n"),
VERSION,
(ARDUINO/10000)%100, (ARDUINO/100)%100, (ARDUINO/1)%100,
__VERSION__, __DATE__, __TIME__);
delay(1000);

#if USE_SD
Expand Down
14 changes: 14 additions & 0 deletions sdcard_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,20 @@ uint8_t sd_remove_file (char *name)



//
// check that file extension matches supplied string, return true/false
//
uint8_t sd_file_ext_matches (char *name, char *ext)
{
// get ptr to the last filename dot, or NULL
char *ptr = strrchr(name, '.');

// if no extension, return false; else return TRUE if extension matches string
return ptr == NULL ? FALSE : (strcasecmp(ptr, ext) == 0 ? TRUE : FALSE);
}



//
// read bytes from an sdcard file
//
Expand Down
1 change: 1 addition & 0 deletions sdcard_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ uint8_t sd_initialize (void);
void sd_debug (HardwareSerial *serialPort, uint8_t level);
void sd_list_files (HardwareSerial *serialPort);
uint8_t sd_remove_file (char *name);
uint8_t sd_file_ext_matches (char *name, char *ext);
uint16_t sd_read_bytes (char *name, uint32_t pos, uint8_t *buf, uint16_t len);
uint16_t sd_write_bytes (char *name, uint32_t pos, uint8_t *buf, uint16_t len);
uint32_t sd_get_file_size (char *name);
Expand Down

0 comments on commit 458a435

Please sign in to comment.