From ae269a522c126c9e7c29efb6b7f0e63d33c98b2a Mon Sep 17 00:00:00 2001 From: Eric Helgeson Date: Mon, 21 Dec 2020 11:22:13 -0600 Subject: [PATCH] Add logging to a file for init --- ArdSCSinoV2/ArdSCSinoV2.ino | 108 +++++++++++++++++++++--------------- 1 file changed, 62 insertions(+), 46 deletions(-) diff --git a/ArdSCSinoV2/ArdSCSinoV2.ino b/ArdSCSinoV2/ArdSCSinoV2.ino index bb5f30c..779230c 100644 --- a/ArdSCSinoV2/ArdSCSinoV2.ino +++ b/ArdSCSinoV2/ArdSCSinoV2.ino @@ -245,6 +245,11 @@ static const byte db2scsiid[256]={ }; #endif +// Log File +#define VERSION "1.0-b" +#define LOG_FILENAME "LOG.txt" +FsFile LOG_FILE; + void onFalseInit(void); void onBusReset(void); @@ -282,31 +287,25 @@ bool hddimageOpen(HDDIMG *h,const char *image_name,int id,int lun,int blocksize) if(h->m_file.isOpen()) { h->m_fileSize = h->m_file.size(); -#if DEBUG - Serial.print("Imagefile:"); - Serial.print(h->m_file.name() ); -#endif + LOG_FILE.print("Imagefile: "); + LOG_FILE.print(file_path); if(h->m_fileSize>0) { // check blocksize dummy file -#if DEBUG - Serial.print(" / "); - Serial.print(h->m_fileSize); - Serial.print("bytes / "); - Serial.print(h->m_fileSize / 1024); - Serial.print("KiB / "); - Serial.print(h->m_fileSize / 1024 / 1024); - Serial.println("MiB"); -#endif - return true; // ファイルが開けた + LOG_FILE.print(" / "); + LOG_FILE.print(h->m_fileSize); + LOG_FILE.print("bytes / "); + LOG_FILE.print(h->m_fileSize / 1024); + LOG_FILE.print("KiB / "); + LOG_FILE.print(h->m_fileSize / 1024 / 1024); + LOG_FILE.println("MiB"); + return true; // File opened } else { h->m_file.close(); h->m_fileSize = h->m_blocksize = 0; // no file -#if DEBUG - Serial.println("FileSizeError"); -#endif + LOG_FILE.println("FileSizeError"); } } return false; @@ -367,6 +366,7 @@ void setup() #endif onFalseInit(); } + initFileLog(); //Sector data overrun byte setting m_buf[MAX_BLOCKSIZE] = 0xff; // DB0 all off,DBP off @@ -382,57 +382,73 @@ void setup() { imageReady = hddimageOpen(h,HDIMG_FILE_256,id,lun,256); } - if(!imageReady) - { - imageReady = hddimageOpen(h,HDIMG_FILE_512,id,lun,512); - } - if(!imageReady) - { - imageReady = hddimageOpen(h,HDIMG_FILE_1024,id,lun, 1024); - } - if(imageReady) - { - // Marked as a responsive ID - scsi_id_mask |= 1<m_file)) { - Serial.print((h->m_blocksize<1000) ? ": " : ":"); - Serial.print(h->m_blocksize); + LOG_FILE.print((h->m_blocksize<1000) ? ": " : ":"); + LOG_FILE.print(h->m_blocksize); } else - Serial.print(":----"); + LOG_FILE.print(":----"); } - Serial.println(":"); + LOG_FILE.println(":"); } -#endif - LED_OFF(); - //Occurs when the RST pin state changes from HIGH to LOW - attachInterrupt(PIN_MAP[RST].gpio_bit, onBusReset, FALLING); + LOG_FILE.println("Finished initialization of SCSI Devices - Entering main loop."); + LOG_FILE.sync(); + LOG_FILE.close(); } /*