Browse Source

Start added json config support

Per Mårtensson 3 years ago
parent
commit
278415fba7
5 changed files with 34 additions and 9 deletions
  1. 1 0
      sw/Todo
  2. 1 1
      sw/include/config.h
  3. 16 4
      sw/json/blacksasi.json
  4. 14 2
      sw/src/config.cpp
  5. 2 2
      sw/src/main.cpp

+ 1 - 0
sw/Todo

@@ -4,3 +4,4 @@ Short list of todos
 *   Implement json config file that uses the switch for which config in uses
 *   Fix clock and DMA
 *   Use detection of termination power
+*   Fix so that different disc can be used, SCSI_INFO_BUF needs to be an array

+ 1 - 1
sw/include/config.h

@@ -3,5 +3,5 @@
 #include <SdFat.h>
 #include "sdios.h"
 #include "blacksasi.h"
-void readSCSIDeviceConfig();
+void readSCSIDeviceConfig(uint8_t disc);
 #endif // __BLACKSASI_CONFIG_H__

+ 16 - 4
sw/json/blacksasi.json

@@ -16,7 +16,10 @@
                     "lun": 0,
                     "file": "abc1600_example1.dsk",
                     "sectorsize": 512,
-                    "readonly": "false"
+                    "readonly": "false",
+                    "vendor": "SWEPROJ",
+                    "product": "BLACKSASI",
+                    "version": "1.0"
                 },
                 {
                     "name": "ABC1600 disc 2",
@@ -24,7 +27,10 @@
                     "lun": 0,
                     "file": "abc1600_example2.dsk",
                     "sectorsize": 512,
-                    "readonly": "false"
+                    "readonly": "false",
+                    "vendor": "SWEPROJ",
+                    "product": "BLACKSASI",
+                    "version": "1.0"
                 }
             ]
         },
@@ -39,7 +45,10 @@
                     "lun": 0,
                     "file": "x37_example1.dsk",
                     "sectorsize": 512,
-                    "readonly": "false"
+                    "readonly": "false",
+                    "vendor": "SWEPROJ",
+                    "product": "BLACKSASI",
+                    "version": "1.0"
                 },
                 {
                     "name": "ABC1600 disc 2",
@@ -47,7 +56,10 @@
                     "lun": 0,
                     "file": "x37_example2.dsk",
                     "sectorsize": 512,
-                    "readonly": "false"
+                    "readonly": "false",
+                    "vendor": "SWEPROJ",
+                    "product": "BLACKSASI",
+                    "version": "1.0"
                 }
             ]
         }

+ 14 - 2
sw/src/config.cpp

@@ -1,16 +1,27 @@
 #include <Arduino.h>
 #include "config.h"
 #include "sdcard.h"
+#include "ArduinoJson.h"
 extern SdFs SD;
 extern FsFile LOG_FILE;
 extern byte SCSI_INFO_BUF[SCSI_INFO_BUF_SIZE];
 // If config file exists, read the first three lines and copy the contents.
 // File must be well formed or you will get junk in the SCSI Vendor fields.
-void readSCSIDeviceConfig() {
-  FsFile config_file = SD.open("scsi-config.txt", O_RDONLY);
+void readSCSIDeviceConfig(uint8_t disc) {
+  StaticJsonDocument<2048> config;
+  FsFile config_file = SD.open("blacksasi.json", O_RDONLY);
   if (!config_file.isOpen()) {
     return;
   }
+  
+  DeserializationError error = deserializeJson(config, config_file);
+  if (error){
+    Serial.println(F("Failed to read file"));
+    return;
+  }
+  String configx =config["config"];
+  Serial.println(configx);
+  /*
   char vendor[SCSI_INFO_VENDOR_SIZE];
   memset(vendor, 0, sizeof(vendor));
   config_file.readBytes(vendor, sizeof(vendor));
@@ -32,4 +43,5 @@ void readSCSIDeviceConfig() {
   LOG_FILE.println(version);
   memcpy(&(SCSI_INFO_BUF[32]), version, 4);
   config_file.close();
+  */
 }

+ 2 - 2
sw/src/main.cpp

@@ -315,7 +315,7 @@ void setup()
 #if DEBUG > 0
   Serial.begin(19200);
   delay(3000);
-  Serial.println("BLACKSASI");
+  Serial.println("--- BLACKSASI ---");
   Serial.print("Board rev: ");
   Serial.println(board_rev);
   Serial.flush();
@@ -346,7 +346,7 @@ void setup()
   }
   readSDCardInfo();
   dmpVol();
-  readSCSIDeviceConfig();
+  readSCSIDeviceConfig(imageSelect);
   initFileLog();
  
   //Sector data overrun byte setting