diff --git a/CHANGELIST.md b/CHANGELIST.md
index f1555a82..bd35b85d 100644
--- a/CHANGELIST.md
+++ b/CHANGELIST.md
@@ -159,6 +159,7 @@
- Fix short name test
- Update RedumpLib to 1.6.4
- Fix misunderstanding on perfect offset
+- Handle SCSI error count
### 3.2.4 (2024-11-24)
diff --git a/MPF.Processors.Test/RedumperTests.cs b/MPF.Processors.Test/RedumperTests.cs
index f7b29e97..111632a6 100644
--- a/MPF.Processors.Test/RedumperTests.cs
+++ b/MPF.Processors.Test/RedumperTests.cs
@@ -974,6 +974,37 @@ namespace MPF.Processors.Test
#endregion
+ #region GetSCSIErrorCount
+
+ [Fact]
+ public void GetSCSIErrorCount_Empty_Null()
+ {
+ long expected = -1;
+ string log = string.Empty;
+ long actual = Redumper.GetSCSIErrorCount(log);
+ Assert.Equal(expected, actual);
+ }
+
+ [Fact]
+ public void GetSCSIErrorCount_Invalid_Null()
+ {
+ long expected = -1;
+ string log = "INVALID";
+ long actual = Redumper.GetSCSIErrorCount(log);
+ Assert.Equal(expected, actual);
+ }
+
+ [Fact]
+ public void GetSCSIErrorCount_Valid_Filled()
+ {
+ long expected = 12345;
+ string log = Path.Combine(Environment.CurrentDirectory, "TestData", "Redumper", "CDROM", "test.log");
+ long actual = Redumper.GetSCSIErrorCount(log);
+ Assert.Equal(expected, actual);
+ }
+
+ #endregion
+
#region GetSecuROMData
[Fact]
diff --git a/MPF.Processors.Test/TestData/Redumper/CDROM/test.log b/MPF.Processors.Test/TestData/Redumper/CDROM/test.log
index 4de2dd2e..c21df533 100644
--- a/MPF.Processors.Test/TestData/Redumper/CDROM/test.log
+++ b/MPF.Processors.Test/TestData/Redumper/CDROM/test.log
@@ -126,6 +126,10 @@ SS [
00E0 TEST DATA
00F0 TEST DATA
+<< GetSCSIErrorCount >>
+SCSI: 23456 samples
+SCSI: 12345
+
<< GetSecuROMData >>
SecuROM [
version: 0
diff --git a/MPF.Processors/Redumper.cs b/MPF.Processors/Redumper.cs
index 2e801f72..1aec10c8 100644
--- a/MPF.Processors/Redumper.cs
+++ b/MPF.Processors/Redumper.cs
@@ -111,6 +111,10 @@ namespace MPF.Processors
info.SizeAndChecksums!.Layerbreak3 = !string.IsNullOrEmpty(layerbreak3) ? long.Parse(layerbreak3) : default;
}
+ // Attempt to get the error count
+ long scsiErrors = GetSCSIErrorCount($"{basePath}.log");
+ info.CommonDiscInfo!.ErrorsCount = (scsiErrors == -1 ? "Error retrieving error count" : scsiErrors.ToString());;
+
// Bluray-specific options
if (Type == MediaType.BluRay)
{
@@ -1757,6 +1761,50 @@ namespace MPF.Processors
}
}
+ ///
+ /// Get the SCSI error count from the input files, if possible
+ ///
+ /// Log file location
+ /// SCSI error count on success, -1 on error
+ /// TODO: Remove when Redumper adds this to normal errors
+ internal static long GetSCSIErrorCount(string log)
+ {
+ // If the file doesn't exist, we can't get info from it
+ if (string.IsNullOrEmpty(log))
+ return -1;
+ if (!File.Exists(log))
+ return -1;
+
+ try
+ {
+ using var sr = File.OpenText(log);
+
+ // Find the error counts
+ while (!sr.EndOfStream)
+ {
+ var line = sr.ReadLine()?.Trim();
+ if (line == null)
+ break;
+
+ // SCSI:
+ if (line.StartsWith("SCSI: ") && !line.EndsWith("samples"))
+ {
+ string[] parts = line.Split(' ');
+ if (long.TryParse(parts[1], out long scsiErrors))
+ return scsiErrors;
+ }
+ }
+
+ // We couldn't detect it then
+ return -1;
+ }
+ catch
+ {
+ // We don't care what the exception is right now
+ return -1;
+ }
+ }
+
///
/// Get the SecuROM data from the input file, if possible
///