Sfoglia il codice sorgente

Add reporting for eject button

There is basic messaging around using an eject button for removable
drives.  On board with I2C can be hijacked for Eject GPIOs or with
the v1.2 the is an eject button. This will list the devices
that the eject button(s) are hooked into or messaging about where
to look up instructions for setting up eject buttons.
Morio 1 anno fa
parent
commit
6dbab0150a
6 ha cambiato i file con 94 aggiunte e 8 eliminazioni
  1. 1 1
      platformio.ini
  2. 73 4
      src/ZuluSCSI.cpp
  3. 14 2
      src/ZuluSCSI_disk.cpp
  4. 4 0
      src/ZuluSCSI_disk.h
  5. 1 0
      src/ZuluSCSI_settings.cpp
  6. 1 1
      zuluscsi.ini

+ 1 - 1
platformio.ini

@@ -211,7 +211,7 @@ build_flags =
     -DROMDRIVE_OFFSET=${env:ZuluSCSI_Pico_DaynaPORT.program_flash_allocation}
 ; These take a large portion of the SRAM and can be adjusted
     -DLOGBUFSIZE=8192
-    -DPREFETCH_BUFFER_SIZE=5376
+    -DPREFETCH_BUFFER_SIZE=4608
     -DSCSI2SD_BUFFER_SIZE=57344
 ; This controls the depth of NETWORK_PACKET_MAX_SIZE (1520 bytes)
 ; For example a queue size of 10 would be 10 x 1520 = 15200 bytes

+ 73 - 4
src/ZuluSCSI.cpp

@@ -310,6 +310,22 @@ bool createImage(const char *cmd_filename, char imgname[MAX_FILE_PATH + 1])
   return true;
 }
 
+static bool typeIsRemovable(S2S_CFG_TYPE type)
+{
+  switch (type)
+  {
+  case S2S_CFG_OPTICAL:
+  case S2S_CFG_MO:
+  case S2S_CFG_FLOPPY_14MB:
+  case S2S_CFG_ZIP100:
+  case S2S_CFG_REMOVABLE:
+  case S2S_CFG_SEQUENTIAL:
+    return true;
+  default:
+    return false;
+  }
+}
+
 // Iterate over the root path in the SD card looking for candidate image files.
 bool findHDDImages()
 {
@@ -336,6 +352,9 @@ bool findHDDImages()
   bool imageReady;
   bool foundImage = false;
   int usedDefaultId = 0;
+  uint8_t removable_count = 0;
+  uint8_t eject_btn_set = 0;
+  uint8_t last_removable_device = 255;
   while (1)
   {
     if (!file.openNext(&root, O_READ))
@@ -451,8 +470,6 @@ bool findHDDImages()
           }
         }
 
-
-
         // Add the directory name to get the full file path
         char fullname[MAX_FILE_PATH * 2 + 2] = {0};
         strncpy(fullname, imgdir, MAX_FILE_PATH);
@@ -556,11 +573,63 @@ bool findHDDImages()
               ", BlockSize: ", (int)cfg->bytesPerSector,
               ", Type: ", (int)cfg->deviceType,
               ", Quirks: ", (int)cfg->quirks,
-              ", Size: ", capacity_kB, "kB");
-      };
+              ", Size: ", capacity_kB, "kB",
+              typeIsRemovable((S2S_CFG_TYPE)cfg->deviceType) ? ", Removable" : ""
+              );
+       }
     }
   }
+  // count the removable drives and drive with eject enabled
+  for (uint8_t id; id < S2S_MAX_TARGETS; id++)
+  {
+    const S2S_TargetCfg* cfg = s2s_getConfigByIndex(id);
+    if (cfg  && (cfg->scsiId & S2S_CFG_TARGET_ENABLED ))
+    {
+       if (typeIsRemovable((S2S_CFG_TYPE)cfg->deviceType))
+        {
+          removable_count++;
+          last_removable_device = id;
+          if ( getEjectButton(id) !=0 )
+          {
+            eject_btn_set++;
+          }
+        }
+    }
+  } 
 
+  if (removable_count == 1)
+  {
+    // If there is a removable device
+    if (eject_btn_set == 1)
+      logmsg("Eject set to device with ID: ", last_removable_device);
+    else if (eject_btn_set == 0)
+    {
+      logmsg("Found 1 removable device, to set an eject button see EjectButton in the, '", CONFIGFILE,"', or the http://zuluscsi.com/manual");
+    } 
+  }
+  else if (removable_count > 1)
+  {
+
+    if (removable_count >= eject_btn_set && eject_btn_set > 0)
+    {
+      if (eject_btn_set == removable_count)
+        logmsg("Eject set on all removable devices:");
+      else
+        logmsg("Eject set on the following SCSI IDs:");
+
+      for (uint8_t id = 0; id < S2S_MAX_TARGETS; id++)
+      {
+        if( getEjectButton(id) != 0)
+        {
+          logmsg("-- SCSI ID: ", (int)id, " type: ", (int) s2s_getConfigById(id)->deviceType, " button mask: ", getEjectButton(id));
+        }
+      }
+    }
+    else
+    {
+      logmsg("Multiple removable devices, to set an eject button see EjectButton in the, '", CONFIGFILE,"', or the http://zuluscsi.com/manual");
+    }
+  }
   return foundImage;
 }
 

+ 14 - 2
src/ZuluSCSI_disk.cpp

@@ -863,6 +863,18 @@ uint32_t getBlockSize(char *filename, uint8_t scsi_id)
     }
     return block_size;
 }
+
+uint8_t getEjectButton(uint8_t idx)
+{
+    return g_DiskImages[idx].ejectButton;
+}
+
+void setEjectButton(uint8_t idx, int8_t eject_button)
+{
+    g_DiskImages[idx].ejectButton = eject_button;
+    g_scsi_settings.getDevice(idx)->ejectButton = eject_button;
+}
+
 // Check if we have multiple drive images to cycle when drive is ejected.
 bool switchNextImage(image_config_t &img, const char* next_filename)
 {
@@ -942,7 +954,7 @@ static void diskEjectAction(uint8_t buttonId)
     for (uint8_t i = 0; i < S2S_MAX_TARGETS; i++)
     {
         image_config_t &img = g_DiskImages[i];
-        if (img.ejectButton == buttonId)
+        if (img.ejectButton & buttonId)
         {
             if (img.deviceType == S2S_CFG_OPTICAL)
             {
@@ -994,7 +1006,7 @@ uint8_t diskEjectButtonUpdate(bool immediate)
             uint8_t mask = 1;
             for (uint8_t i = 0; i < 8; i++)
             {
-                if (ejectors & mask) diskEjectAction(i + 1);
+                if (ejectors & mask) diskEjectAction(ejectors & mask);
                 mask = mask << 1;
             }
         }

+ 4 - 0
src/ZuluSCSI_disk.h

@@ -113,6 +113,10 @@ void scsiDiskCloseSDCardImages();
 // Get blocksize from filename or use device setting in ini file
 uint32_t getBlockSize(char *filename, uint8_t scsi_id);
 
+// Get and set the eject button bit flags
+uint8_t getEjectButton(uint8_t idx);
+void    setEjectButton(uint8_t idx, int8_t eject_button);
+
 bool scsiDiskOpenHDDImage(int target_idx, const char *filename, int scsi_lun, int blocksize, S2S_CFG_TYPE type = S2S_CFG_FIXED, bool use_prefix = false);
 void scsiDiskLoadConfig(int target_idx);
 

+ 1 - 0
src/ZuluSCSI_settings.cpp

@@ -266,6 +266,7 @@ static void readIniSCSIDeviceSetting(scsi_device_settings_t &cfg, const char *se
         memset(cfg.serial, 0, sizeof(cfg.serial));
         strncpy(cfg.serial, tmp, sizeof(cfg.serial));
     }
+
 }
 
 scsi_system_settings_t *ZuluSCSISettings::initSystem(const char *presetName)

+ 1 - 1
zuluscsi.ini

@@ -36,7 +36,7 @@
 #InitiatorMaxRetry = 5 #  number of retries on failed reads 0-255, default is 5
 #InitiatorImageHandling = 0 # 0: skip exisitng images, 1: create new image with incrementing suffix, 2: overwrite exising image
 
-#EnableCDAudio = 0 # Enable CD audio - an external I2S DAC on the v1.2 is required
+#EnableCDAudio = 0 # 1: Enable CD audio - an external I2S DAC on the v1.2 is required
 
 # Settings that can be specified either per-device or for all devices.