erichelgeson / BlueSCSI

A small SCSI device based on stm32
Other
386 stars 61 forks source link

Reformatted Logging #262

Closed dotsam closed 6 months ago

dotsam commented 7 months ago

This PR is mainly focused on cleaner/more informative logging, keeping information grouped with the section/file it belongs with.

The PR also endeavours to make better use of constants and macros, and use a consistent convention around char array lengths. There's also some light whitespace cleanup and fixing of a few typos.

The largest functional change in the PR is the change from finalizeFileLog to finalizeDevices. This function now contains the call to readSCSIDeviceConfig in the case that two files are defined with the same ID, so that it is only called once, and the function now also outputs the filename that is being served for the ID to make absolutely clear on what IDs the drive image should be appearing.

This PR doesn't make any changes to anything that runs in the loop, so hopefully there will not be any performance impacts, although some of the discussion in #118 leads me to worry that even changes outside the loop could have performance impacts.

(I also see that PR #261 just came in, I'm happy to rebase if that PR is merged)

Here's an example of the new log output, including the case where two files with the same ID are seen, to show that the "devices table" indicates that the last ID detected is the one used:

BlueSCSI https://github.com/erichelgeson/BlueSCSI
VER: 1.1-20231117-SNAPSHOT-USB DEBUG: 0
SD Card Info:
 SPI Speed: 50MHz
 Format: FAT32/16/12 - exFAT may improve performance
 Max Filename Length: 64
 MID: 1B OID: SM
 Name: GC1S5 Date: 9/2021
 Serial: 3782502390
Looking for images in: /
 HD10_512 200MB.hda
 Parsed: HDD ID 1 LUN 0 Blocksize 512k
 WARNING: Fragmented, see https://github.com/erichelgeson/BlueSCSI/wiki/Image-File-Fragmentation
 File size: 209780736 bytes, 204864KiB, 200MiB

 HD10_512 200MB Duplicate.hda
 Parsed: HDD ID 1 LUN 0 Blocksize 512k
 WARNING: Fragmented, see https://github.com/erichelgeson/BlueSCSI/wiki/Image-File-Fragmentation
 File size: 209780736 bytes, 204864KiB, 200MiB

SCSI Devices
ID  LUN Name
0   0   -
1   0   HD10_512 200MB Duplicate.hda
        INI Overrides: Forced HDD / Vendor: SEAGATE / Product: ST225N / Revision: 9
2   0   -
3   0   -
4   0   -
5   0   -
6   0   -
Finished configuration - Starting BlueSCSI
erichelgeson commented 6 months ago

Thanks for this, and offering to rebase. Please rebase and I'll merge!

dotsam commented 6 months ago

Rebased, should be good to go. Tried my best to not increase firmware size too much, this looks to add about 92 bytes to the USB firmware.