mirror of
https://github.com/erichelgeson/BlueSCSI.git
synced 2024-06-10 08:29:39 +00:00
Clean up logging in setup functions
This commit is contained in:
parent
0a30396c3b
commit
1d49003fe1
134
src/BlueSCSI.cpp
134
src/BlueSCSI.cpp
|
@ -147,6 +147,9 @@ void readSCSIDeviceConfig(uint8_t scsi_id, SCSI_DEVICE *dev) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LOG_FILE.println();
|
||||||
|
LOG_FILE.print("\t\tINI Overrides: ");
|
||||||
|
|
||||||
// create section name from id
|
// create section name from id
|
||||||
section[4] = INT_TO_CHAR(scsi_id);
|
section[4] = INT_TO_CHAR(scsi_id);
|
||||||
|
|
||||||
|
@ -155,13 +158,13 @@ void readSCSIDeviceConfig(uint8_t scsi_id, SCSI_DEVICE *dev) {
|
||||||
case 0:
|
case 0:
|
||||||
dev->m_type = SCSI_DEVICE_HDD;
|
dev->m_type = SCSI_DEVICE_HDD;
|
||||||
memcpy(iq, &default_hdd, sizeof(default_hdd));
|
memcpy(iq, &default_hdd, sizeof(default_hdd));
|
||||||
LOG_FILE.println("Forced HDD");
|
LOG_FILE.print("Forced HDD");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
dev->m_type = SCSI_DEVICE_OPTICAL;
|
dev->m_type = SCSI_DEVICE_OPTICAL;
|
||||||
memcpy(iq, &default_optical, sizeof(default_optical));
|
memcpy(iq, &default_optical, sizeof(default_optical));
|
||||||
LOG_FILE.println("Forced Optical");
|
LOG_FILE.print("Forced CDROM");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 99:
|
case 99:
|
||||||
|
@ -169,25 +172,25 @@ void readSCSIDeviceConfig(uint8_t scsi_id, SCSI_DEVICE *dev) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
LOG_FILE.println("Unsupported override type");
|
LOG_FILE.print("Unsupported type override");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ini_gets(section, "vendor", NULL, buf, SCSI_BUF_SIZE, BLUESCSI_INI)) {
|
if(ini_gets(section, "vendor", NULL, buf, SCSI_BUF_SIZE, BLUESCSI_INI)) {
|
||||||
memcpy(iq->vendor, buf, SCSI_VENDOR_LENGTH);
|
memcpy(iq->vendor, buf, SCSI_VENDOR_LENGTH);
|
||||||
LOG_FILE.print("vendor:");
|
LOG_FILE.print(" / Vendor: ");
|
||||||
LOG_FILE.println(buf);
|
LOG_FILE.print(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ini_gets(section, "product", NULL, buf, SCSI_BUF_SIZE, BLUESCSI_INI)) {
|
if(ini_gets(section, "product", NULL, buf, SCSI_BUF_SIZE, BLUESCSI_INI)) {
|
||||||
memcpy(iq->product, buf, SCSI_PRODUCT_LENGTH);
|
memcpy(iq->product, buf, SCSI_PRODUCT_LENGTH);
|
||||||
LOG_FILE.print("product:");
|
LOG_FILE.print(" / Product: ");
|
||||||
LOG_FILE.println(buf);
|
LOG_FILE.print(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ini_gets(section, "revision", NULL, buf, SCSI_BUF_SIZE, BLUESCSI_INI)) {
|
if(ini_gets(section, "revision", NULL, buf, SCSI_BUF_SIZE, BLUESCSI_INI)) {
|
||||||
memcpy(iq->revision, buf, SCSI_REVISION_LENGTH);
|
memcpy(iq->revision, buf, SCSI_REVISION_LENGTH);
|
||||||
LOG_FILE.print("revision:");
|
LOG_FILE.print(" / Revision: ");
|
||||||
LOG_FILE.println(buf);
|
LOG_FILE.print(buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -197,42 +200,44 @@ void readSDCardInfo(int success_mhz)
|
||||||
cid_t sd_cid;
|
cid_t sd_cid;
|
||||||
|
|
||||||
LOG_FILE.println("SDCard Info:");
|
LOG_FILE.println("SDCard Info:");
|
||||||
LOG_FILE.print(" Format:");
|
LOG_FILE.print("\tFormat: ");
|
||||||
switch(SD.vol()->fatType()) {
|
switch(SD.vol()->fatType()) {
|
||||||
case FAT_TYPE_EXFAT:
|
case FAT_TYPE_EXFAT:
|
||||||
LOG_FILE.println("exFAT");
|
LOG_FILE.println("exFAT");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
LOG_FILE.print("FAT32/16/12 - exFAT may improve performance");
|
LOG_FILE.println("FAT32/16/12 - exFAT may improve performance");
|
||||||
}
|
}
|
||||||
LOG_FILE.print("SPI speed: ");
|
LOG_FILE.print("\tSPI Speed: ");
|
||||||
LOG_FILE.print(success_mhz);
|
LOG_FILE.print(success_mhz);
|
||||||
LOG_FILE.println("Mhz");
|
LOG_FILE.println("MHz");
|
||||||
LOG_FILE.print(" Max Filename Length:");
|
LOG_FILE.print("\tMax Filename Length: ");
|
||||||
LOG_FILE.println(MAX_FILE_PATH);
|
LOG_FILE.println(MAX_FILE_PATH);
|
||||||
|
|
||||||
if(SD.card()->readCID(&sd_cid))
|
if(SD.card()->readCID(&sd_cid))
|
||||||
{
|
{
|
||||||
LOG_FILE.print(" MID:");
|
LOG_FILE.print("\tMID: ");
|
||||||
LOG_FILE.print(sd_cid.mid, 16);
|
LOG_FILE.print(sd_cid.mid, 16);
|
||||||
LOG_FILE.print(" OID:");
|
LOG_FILE.print(" OID: ");
|
||||||
LOG_FILE.print(sd_cid.oid[0]);
|
LOG_FILE.print(sd_cid.oid[0]);
|
||||||
LOG_FILE.println(sd_cid.oid[1]);
|
LOG_FILE.println(sd_cid.oid[1]);
|
||||||
|
|
||||||
LOG_FILE.print(" Name:");
|
LOG_FILE.print("\tName: ");
|
||||||
LOG_FILE.print(sd_cid.pnm[0]);
|
LOG_FILE.print(sd_cid.pnm[0]);
|
||||||
LOG_FILE.print(sd_cid.pnm[1]);
|
LOG_FILE.print(sd_cid.pnm[1]);
|
||||||
LOG_FILE.print(sd_cid.pnm[2]);
|
LOG_FILE.print(sd_cid.pnm[2]);
|
||||||
LOG_FILE.print(sd_cid.pnm[3]);
|
LOG_FILE.print(sd_cid.pnm[3]);
|
||||||
LOG_FILE.print(sd_cid.pnm[4]);
|
LOG_FILE.print(sd_cid.pnm[4]);
|
||||||
|
|
||||||
LOG_FILE.print(" Date:");
|
LOG_FILE.print(" Date: ");
|
||||||
LOG_FILE.print(sd_cid.mdtMonth());
|
LOG_FILE.print(sd_cid.mdtMonth());
|
||||||
LOG_FILE.print("/");
|
LOG_FILE.print("/");
|
||||||
LOG_FILE.println(sd_cid.mdtYear());
|
LOG_FILE.println(sd_cid.mdtYear());
|
||||||
|
|
||||||
LOG_FILE.print(" Serial:");
|
LOG_FILE.print("\tSerial: ");
|
||||||
LOG_FILE.println(sd_cid.psn());
|
LOG_FILE.println(sd_cid.psn());
|
||||||
|
} else {
|
||||||
|
LOG_FILE.println("\tWARNING: Unable to read SDCard CID data");
|
||||||
}
|
}
|
||||||
LOG_FILE.sync();
|
LOG_FILE.sync();
|
||||||
}
|
}
|
||||||
|
@ -271,16 +276,16 @@ bool hddimageOpen(SCSI_DEVICE *dev, FsFile *file,int id,int lun,int blocksize)
|
||||||
dev->m_fileSize = dev->m_file.size();
|
dev->m_fileSize = dev->m_file.size();
|
||||||
|
|
||||||
if(dev->m_fileSize < 1) {
|
if(dev->m_fileSize < 1) {
|
||||||
LOG_FILE.println(" - file is 0 bytes, can not use.");
|
LOG_FILE.println("\t\tERROR: File is 0 bytes");
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!dev->m_file.isContiguous())
|
if(!dev->m_file.isContiguous())
|
||||||
{
|
{
|
||||||
LOG_FILE.println(" - file is fragmented, see https://github.com/erichelgeson/BlueSCSI/wiki/Image-File-Fragmentation");
|
LOG_FILE.println("\t\tWARNING: File is fragmented, see https://github.com/erichelgeson/BlueSCSI/wiki/Image-File-Fragmentation");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(dev->m_type == SCSI_DEVICE_OPTICAL) {
|
if(dev->m_type == SCSI_DEVICE_OPTICAL) {
|
||||||
LOG_FILE.print(" CDROM");
|
|
||||||
dev->m_blocksize = CDROM_COMMON_SECTORSIZE;
|
dev->m_blocksize = CDROM_COMMON_SECTORSIZE;
|
||||||
|
|
||||||
// Borrowed from PCEM
|
// Borrowed from PCEM
|
||||||
|
@ -303,6 +308,7 @@ bool hddimageOpen(SCSI_DEVICE *dev, FsFile *file,int id,int lun,int blocksize)
|
||||||
// Last ditch effort
|
// Last ditch effort
|
||||||
// size must be less than 700MB
|
// size must be less than 700MB
|
||||||
if(dev->m_fileSize > 912579600) {
|
if(dev->m_fileSize > 912579600) {
|
||||||
|
LOG_FILE.println("\t\tERROR: ISO too large!");
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -314,27 +320,25 @@ bool hddimageOpen(SCSI_DEVICE *dev, FsFile *file,int id,int lun,int blocksize)
|
||||||
dev->m_rawblocksize = CDROM_COMMON_SECTORSIZE;
|
dev->m_rawblocksize = CDROM_COMMON_SECTORSIZE;
|
||||||
} else {
|
} else {
|
||||||
// I give up!
|
// I give up!
|
||||||
LOG_FILE.println(" InvalidISO");
|
LOG_FILE.println("\t\tERROR: Invalid ISO!");
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
LOG_FILE.print(" HDD");
|
|
||||||
}
|
}
|
||||||
dev->m_blockcount = dev->m_fileSize / dev->m_blocksize;
|
dev->m_blockcount = dev->m_fileSize / dev->m_blocksize;
|
||||||
|
|
||||||
// check blocksize dummy file
|
// check blocksize dummy file
|
||||||
LOG_FILE.print(" / ");
|
LOG_FILE.print("\t\tFile size: ");
|
||||||
LOG_FILE.print(dev->m_fileSize);
|
LOG_FILE.print(dev->m_fileSize);
|
||||||
LOG_FILE.print("bytes / ");
|
LOG_FILE.print(" bytes, ");
|
||||||
LOG_FILE.print(dev->m_fileSize / 1024);
|
LOG_FILE.print(dev->m_fileSize / 1024);
|
||||||
LOG_FILE.print("KiB / ");
|
LOG_FILE.print("KiB, ");
|
||||||
LOG_FILE.print(dev->m_fileSize / 1024 / 1024);
|
LOG_FILE.print(dev->m_fileSize / 1024 / 1024);
|
||||||
LOG_FILE.println("MiB");
|
LOG_FILE.println("MiB");
|
||||||
|
|
||||||
if(dev->m_type == SCSI_DEVICE_OPTICAL) {
|
if(dev->m_type == SCSI_DEVICE_OPTICAL) {
|
||||||
LOG_FILE.print(" MODE2:");LOG_FILE.print(IS_MODE2(dev->flags));
|
LOG_FILE.print(" MODE2: ");LOG_FILE.print(IS_MODE2(dev->flags));
|
||||||
LOG_FILE.print(" BlockSize:");LOG_FILE.println(IS_RAW(dev->flags));
|
LOG_FILE.print(" BlockSize: ");LOG_FILE.println(IS_RAW(dev->flags));
|
||||||
}
|
}
|
||||||
return true; // File opened
|
return true; // File opened
|
||||||
|
|
||||||
|
@ -527,10 +531,11 @@ void setup()
|
||||||
#endif
|
#endif
|
||||||
flashError(ERROR_NO_SDCARD);
|
flashError(ERROR_NO_SDCARD);
|
||||||
}
|
}
|
||||||
|
|
||||||
initFileLog();
|
initFileLog();
|
||||||
readSDCardInfo(mhz);
|
readSDCardInfo(mhz);
|
||||||
|
|
||||||
//HD image file open
|
// HD image file open
|
||||||
scsi_id_mask = 0x00;
|
scsi_id_mask = 0x00;
|
||||||
|
|
||||||
if(ini_getl("SCSI", "MapLunsToIDs", 0, BLUESCSI_INI))
|
if(ini_getl("SCSI", "MapLunsToIDs", 0, BLUESCSI_INI))
|
||||||
|
@ -553,12 +558,13 @@ void setup()
|
||||||
if (root.isDirectory()) {
|
if (root.isDirectory()) {
|
||||||
LOG_FILE.print("Looking for images in: ");
|
LOG_FILE.print("Looking for images in: ");
|
||||||
LOG_FILE.println(image_set_dir_name);
|
LOG_FILE.println(image_set_dir_name);
|
||||||
LOG_FILE.sync();
|
|
||||||
} else {
|
} else {
|
||||||
root.close();
|
root.close();
|
||||||
root.open("/");
|
root.open("/");
|
||||||
|
LOG_FILE.println("Looking for images in: /");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LOG_FILE.sync();
|
||||||
findDriveImages(root);
|
findDriveImages(root);
|
||||||
root.close();
|
root.close();
|
||||||
|
|
||||||
|
@ -578,8 +584,8 @@ void setup()
|
||||||
}
|
}
|
||||||
|
|
||||||
finalizeFileLog();
|
finalizeFileLog();
|
||||||
LED_OFF();
|
|
||||||
//Occurs when the RST pin state changes from HIGH to LOW
|
// Occurs when the RST pin state changes from HIGH to LOW
|
||||||
attachInterrupt(RST, onBusReset, FALLING);
|
attachInterrupt(RST, onBusReset, FALLING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -635,6 +641,8 @@ void findDriveImages(FsFile root) {
|
||||||
int lun = DEFAULT_SCSI_LUN;
|
int lun = DEFAULT_SCSI_LUN;
|
||||||
int blk = HDD_BLOCK_SIZE;
|
int blk = HDD_BLOCK_SIZE;
|
||||||
|
|
||||||
|
LOG_FILE.print("\t- "); LOG_FILE.println(name);
|
||||||
|
|
||||||
// Positionally read in and coerce the chars to integers.
|
// Positionally read in and coerce the chars to integers.
|
||||||
// We only require the minimum and read in the next if provided.
|
// We only require the minimum and read in the next if provided.
|
||||||
int file_name_length = strlen(name);
|
int file_name_length = strlen(name);
|
||||||
|
@ -645,8 +653,7 @@ void findDriveImages(FsFile root) {
|
||||||
if(tmp_id > -1 && tmp_id <= MAX_SCSIID) {
|
if(tmp_id > -1 && tmp_id <= MAX_SCSIID) {
|
||||||
id = tmp_id;
|
id = tmp_id;
|
||||||
} else {
|
} else {
|
||||||
LOG_FILE.print(name);
|
LOG_FILE.println("\t\tWARNING: Bad SCSI ID in filename, Using default ID 1");
|
||||||
LOG_FILE.println(" - bad SCSI id in filename, Using default ID 1");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -657,8 +664,7 @@ void findDriveImages(FsFile root) {
|
||||||
if(tmp_lun > -1 && tmp_lun <= NUM_SCSILUN) {
|
if(tmp_lun > -1 && tmp_lun <= NUM_SCSILUN) {
|
||||||
lun = tmp_lun;
|
lun = tmp_lun;
|
||||||
} else {
|
} else {
|
||||||
LOG_FILE.print(name);
|
LOG_FILE.println("\t\tWARNING: Bad SCSI LUN in filename, Using default LUN ID 0");
|
||||||
LOG_FILE.println(" - bad SCSI LUN in filename, Using default LUN ID 0");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -678,30 +684,36 @@ void findDriveImages(FsFile root) {
|
||||||
blk = 2048;
|
blk = 2048;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(id < NUM_SCSIID && lun < NUM_SCSILUN) {
|
LOG_FILE.print("\t\tParsed: ");
|
||||||
dev = &scsi_device_list[id][lun];
|
if(device_type == SCSI_DEVICE_OPTICAL) {
|
||||||
LOG_FILE.print(" - ");
|
LOG_FILE.print("CDROM");
|
||||||
LOG_FILE.print(name);
|
} else {
|
||||||
dev->m_type = device_type;
|
LOG_FILE.print("HDD");
|
||||||
image_ready = hddimageOpen(dev, &file, id, lun, blk);
|
}
|
||||||
if(image_ready) { // Marked as a responsive ID
|
LOG_FILE.print(" ID "); LOG_FILE.print(id);
|
||||||
scsi_id_mask |= 1<<id;
|
LOG_FILE.print(" LUN "); LOG_FILE.print(lun);
|
||||||
|
LOG_FILE.print(" Blocksize "); LOG_FILE.print(blk); LOG_FILE.println("k");
|
||||||
|
|
||||||
switch(dev->m_type)
|
dev = &scsi_device_list[id][lun];
|
||||||
{
|
dev->m_type = device_type;
|
||||||
case SCSI_DEVICE_HDD:
|
image_ready = hddimageOpen(dev, &file, id, lun, blk);
|
||||||
// default SCSI HDD
|
if(image_ready) { // Marked as a responsive ID
|
||||||
dev->inquiry_block = default_hdd;
|
scsi_id_mask |= 1<<id;
|
||||||
break;
|
|
||||||
|
|
||||||
case SCSI_DEVICE_OPTICAL:
|
switch(dev->m_type)
|
||||||
// default SCSI CDROM
|
{
|
||||||
dev->inquiry_block = default_optical;
|
case SCSI_DEVICE_HDD:
|
||||||
break;
|
// default SCSI HDD
|
||||||
}
|
dev->inquiry_block = default_hdd;
|
||||||
|
break;
|
||||||
|
|
||||||
readSCSIDeviceConfig(id, dev);
|
case SCSI_DEVICE_OPTICAL:
|
||||||
|
// default SCSI CDROM
|
||||||
|
dev->inquiry_block = default_optical;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
readSCSIDeviceConfig(id, dev);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LOG_FILE.sync();
|
LOG_FILE.sync();
|
||||||
|
@ -719,7 +731,7 @@ void initFileLog() {
|
||||||
LOG_FILE.print("VER: ");
|
LOG_FILE.print("VER: ");
|
||||||
LOG_FILE.print(VERSION);
|
LOG_FILE.print(VERSION);
|
||||||
LOG_FILE.println(BUILD_TAGS);
|
LOG_FILE.println(BUILD_TAGS);
|
||||||
LOG_FILE.print("DEBUG:");
|
LOG_FILE.print("DEBUG: ");
|
||||||
LOG_FILE.println(DEBUG);
|
LOG_FILE.println(DEBUG);
|
||||||
LOG_FILE.sync();
|
LOG_FILE.sync();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user