mirror of
https://github.com/aaru-dps/Aaru.Server.git
synced 2025-12-16 19:24:27 +00:00
Added tests for Certance vendor commands.
This commit is contained in:
@@ -67,6 +67,12 @@ namespace DiscImageChef.Tests.Devices.SCSI
|
||||
case 0:
|
||||
DicConsole.WriteLine("Returning to SCSI commands menu...");
|
||||
return;
|
||||
case 1:
|
||||
RequestBlockAddress(devPath, dev);
|
||||
continue;
|
||||
case 2:
|
||||
SeekBlock(devPath, dev);
|
||||
continue;
|
||||
default:
|
||||
DicConsole.WriteLine("Incorrect option. Press any key to continue...");
|
||||
System.Console.ReadKey();
|
||||
|
||||
@@ -49,7 +49,8 @@ namespace DiscImageChef.Tests.Devices.SCSI
|
||||
System.Console.Clear();
|
||||
DicConsole.WriteLine("Device: {0}", devPath);
|
||||
DicConsole.WriteLine("Send a Certance vendor command to the device:");
|
||||
DicConsole.WriteLine("1.- Send PARK UNPARK command.");
|
||||
DicConsole.WriteLine("1.- Send PARK command.");
|
||||
DicConsole.WriteLine("2.- Send UNPARK command.");
|
||||
DicConsole.WriteLine("0.- Return to SCSI commands menu.");
|
||||
DicConsole.Write("Choose: ");
|
||||
|
||||
@@ -66,6 +67,12 @@ namespace DiscImageChef.Tests.Devices.SCSI
|
||||
case 0:
|
||||
DicConsole.WriteLine("Returning to SCSI commands menu...");
|
||||
return;
|
||||
case 1:
|
||||
Park(devPath, dev);
|
||||
continue;
|
||||
case 2:
|
||||
Unpark(devPath, dev);
|
||||
continue;
|
||||
default:
|
||||
DicConsole.WriteLine("Incorrect option. Press any key to continue...");
|
||||
System.Console.ReadKey();
|
||||
@@ -73,5 +80,119 @@ namespace DiscImageChef.Tests.Devices.SCSI
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void Park(string devPath, Device dev)
|
||||
{
|
||||
start:
|
||||
System.Console.Clear();
|
||||
bool sense = dev.CertancePark(out byte[] senseBuffer, dev.Timeout, out double duration);
|
||||
|
||||
menu:
|
||||
DicConsole.WriteLine("Device: {0}", devPath);
|
||||
DicConsole.WriteLine("Sending PARK to the device:");
|
||||
DicConsole.WriteLine("Command took {0} ms.", duration);
|
||||
DicConsole.WriteLine("Sense is {0}.", sense);
|
||||
DicConsole.WriteLine("Sense buffer is {0} bytes.", senseBuffer == null ? "null" : senseBuffer.Length.ToString());
|
||||
DicConsole.WriteLine("Sense buffer is null or empty? {0}", ArrayHelpers.ArrayIsNullOrEmpty(senseBuffer));
|
||||
DicConsole.WriteLine("PARK decoded sense:");
|
||||
DicConsole.Write("{0}", Decoders.SCSI.Sense.PrettifySense(senseBuffer));
|
||||
DicConsole.WriteLine();
|
||||
DicConsole.WriteLine("Choose what to do:");
|
||||
DicConsole.WriteLine("1.- Print sense buffer.");
|
||||
DicConsole.WriteLine("2.- Send command again.");
|
||||
DicConsole.WriteLine("0.- Return to Certance vendor commands menu.");
|
||||
DicConsole.Write("Choose: ");
|
||||
|
||||
string strDev = System.Console.ReadLine();
|
||||
if(!int.TryParse(strDev, out int item))
|
||||
{
|
||||
DicConsole.WriteLine("Not a number. Press any key to continue...");
|
||||
System.Console.ReadKey();
|
||||
System.Console.Clear();
|
||||
goto menu;
|
||||
}
|
||||
|
||||
switch(item)
|
||||
{
|
||||
case 0:
|
||||
DicConsole.WriteLine("Returning to Certance vendor commands menu...");
|
||||
return;
|
||||
case 1:
|
||||
System.Console.Clear();
|
||||
DicConsole.WriteLine("Device: {0}", devPath);
|
||||
DicConsole.WriteLine("PARK sense:");
|
||||
if(senseBuffer != null)
|
||||
PrintHex.PrintHexArray(senseBuffer, 64);
|
||||
DicConsole.WriteLine("Press any key to continue...");
|
||||
System.Console.ReadKey();
|
||||
System.Console.Clear();
|
||||
DicConsole.WriteLine("Device: {0}", devPath);
|
||||
goto menu;
|
||||
case 2:
|
||||
goto start;
|
||||
default:
|
||||
DicConsole.WriteLine("Incorrect option. Press any key to continue...");
|
||||
System.Console.ReadKey();
|
||||
System.Console.Clear();
|
||||
goto menu;
|
||||
}
|
||||
}
|
||||
|
||||
static void Unpark(string devPath, Device dev)
|
||||
{
|
||||
start:
|
||||
System.Console.Clear();
|
||||
bool sense = dev.CertanceUnpark(out byte[] senseBuffer, dev.Timeout, out double duration);
|
||||
|
||||
menu:
|
||||
DicConsole.WriteLine("Device: {0}", devPath);
|
||||
DicConsole.WriteLine("Sending UNPARK to the device:");
|
||||
DicConsole.WriteLine("Command took {0} ms.", duration);
|
||||
DicConsole.WriteLine("Sense is {0}.", sense);
|
||||
DicConsole.WriteLine("Sense buffer is {0} bytes.", senseBuffer == null ? "null" : senseBuffer.Length.ToString());
|
||||
DicConsole.WriteLine("Sense buffer is null or empty? {0}", ArrayHelpers.ArrayIsNullOrEmpty(senseBuffer));
|
||||
DicConsole.WriteLine("UNPARK decoded sense:");
|
||||
DicConsole.Write("{0}", Decoders.SCSI.Sense.PrettifySense(senseBuffer));
|
||||
DicConsole.WriteLine();
|
||||
DicConsole.WriteLine("Choose what to do:");
|
||||
DicConsole.WriteLine("1.- Print sense buffer.");
|
||||
DicConsole.WriteLine("2.- Send command again.");
|
||||
DicConsole.WriteLine("0.- Return to Certance vendor commands menu.");
|
||||
DicConsole.Write("Choose: ");
|
||||
|
||||
string strDev = System.Console.ReadLine();
|
||||
if(!int.TryParse(strDev, out int item))
|
||||
{
|
||||
DicConsole.WriteLine("Not a number. Press any key to continue...");
|
||||
System.Console.ReadKey();
|
||||
System.Console.Clear();
|
||||
goto menu;
|
||||
}
|
||||
|
||||
switch(item)
|
||||
{
|
||||
case 0:
|
||||
DicConsole.WriteLine("Returning to Certance vendor commands menu...");
|
||||
return;
|
||||
case 1:
|
||||
System.Console.Clear();
|
||||
DicConsole.WriteLine("Device: {0}", devPath);
|
||||
DicConsole.WriteLine("UNPARK sense:");
|
||||
if(senseBuffer != null)
|
||||
PrintHex.PrintHexArray(senseBuffer, 64);
|
||||
DicConsole.WriteLine("Press any key to continue...");
|
||||
System.Console.ReadKey();
|
||||
System.Console.Clear();
|
||||
DicConsole.WriteLine("Device: {0}", devPath);
|
||||
goto menu;
|
||||
case 2:
|
||||
goto start;
|
||||
default:
|
||||
DicConsole.WriteLine("Incorrect option. Press any key to continue...");
|
||||
System.Console.ReadKey();
|
||||
System.Console.Clear();
|
||||
goto menu;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user