mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Added tests for Archive Corp. vendor commands.
This commit is contained in:
@@ -43,7 +43,7 @@ namespace DiscImageChef.Devices
|
|||||||
/// <param name="senseBuffer">Sense buffer.</param>
|
/// <param name="senseBuffer">Sense buffer.</param>
|
||||||
/// <param name="timeout">Timeout.</param>
|
/// <param name="timeout">Timeout.</param>
|
||||||
/// <param name="duration">Duration.</param>
|
/// <param name="duration">Duration.</param>
|
||||||
public bool ArchiveCorpRequestBlockAddress(out byte[] buffer, out byte[] senseBuffer, uint timeout, out double duration)
|
public bool ArchiveCorpRequestBlockAddress(out byte[] buffer, out byte[] senseBuffer, uint lba, uint timeout, out double duration)
|
||||||
{
|
{
|
||||||
buffer = new byte[3];
|
buffer = new byte[3];
|
||||||
byte[] cdb = new byte[6];
|
byte[] cdb = new byte[6];
|
||||||
@@ -51,6 +51,9 @@ namespace DiscImageChef.Devices
|
|||||||
bool sense;
|
bool sense;
|
||||||
|
|
||||||
cdb[0] = (byte)ScsiCommands.Archive_RequestBlockAddress;
|
cdb[0] = (byte)ScsiCommands.Archive_RequestBlockAddress;
|
||||||
|
cdb[1] = (byte)((lba & 0x1F0000) >> 16);
|
||||||
|
cdb[2] = (byte)((lba & 0xFF00) >> 8);
|
||||||
|
cdb[3] = (byte)(lba & 0xFF);
|
||||||
cdb[4] = 3;
|
cdb[4] = 3;
|
||||||
|
|
||||||
lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense);
|
lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense);
|
||||||
|
|||||||
@@ -74,5 +74,252 @@ namespace DiscImageChef.Tests.Devices.SCSI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void RequestBlockAddress(string devPath, Device dev)
|
||||||
|
{
|
||||||
|
uint lba = 0;
|
||||||
|
string strDev;
|
||||||
|
int item;
|
||||||
|
|
||||||
|
parameters:
|
||||||
|
while(true)
|
||||||
|
{
|
||||||
|
System.Console.Clear();
|
||||||
|
DicConsole.WriteLine("Device: {0}", devPath);
|
||||||
|
DicConsole.WriteLine("Parameters for REQUEST BLOCK ADDRESS command:");
|
||||||
|
DicConsole.WriteLine("LBA: {0}", lba);
|
||||||
|
DicConsole.WriteLine();
|
||||||
|
DicConsole.WriteLine("Choose what to do:");
|
||||||
|
DicConsole.WriteLine("1.- Change parameters.");
|
||||||
|
DicConsole.WriteLine("2.- Send command with these parameters.");
|
||||||
|
DicConsole.WriteLine("0.- Return to Archive vendor commands menu.");
|
||||||
|
|
||||||
|
strDev = System.Console.ReadLine();
|
||||||
|
if(!int.TryParse(strDev, out item))
|
||||||
|
{
|
||||||
|
DicConsole.WriteLine("Not a number. Press any key to continue...");
|
||||||
|
System.Console.ReadKey();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch(item)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
DicConsole.WriteLine("Returning to Archive vendor commands menu...");
|
||||||
|
return;
|
||||||
|
case 1:
|
||||||
|
DicConsole.Write("LBA?: ");
|
||||||
|
strDev = System.Console.ReadLine();
|
||||||
|
if(!uint.TryParse(strDev, out lba))
|
||||||
|
{
|
||||||
|
DicConsole.WriteLine("Not a number. Press any key to continue...");
|
||||||
|
lba = 0;
|
||||||
|
System.Console.ReadKey();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
goto start;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
start:
|
||||||
|
System.Console.Clear();
|
||||||
|
bool sense = dev.ArchiveCorpRequestBlockAddress(out byte[] buffer, out byte[] senseBuffer, lba, dev.Timeout, out double duration);
|
||||||
|
|
||||||
|
menu:
|
||||||
|
DicConsole.WriteLine("Device: {0}", devPath);
|
||||||
|
DicConsole.WriteLine("Sending REQUEST BLOCK ADDRESS to the device:");
|
||||||
|
DicConsole.WriteLine("Command took {0} ms.", duration);
|
||||||
|
DicConsole.WriteLine("Sense is {0}.", sense);
|
||||||
|
DicConsole.WriteLine("Buffer is {0} bytes.", buffer == null ? "null" : buffer.Length.ToString());
|
||||||
|
DicConsole.WriteLine("Buffer is null or empty? {0}", ArrayHelpers.ArrayIsNullOrEmpty(buffer));
|
||||||
|
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();
|
||||||
|
DicConsole.WriteLine("Choose what to do:");
|
||||||
|
DicConsole.WriteLine("1.- Print buffer.");
|
||||||
|
DicConsole.WriteLine("2.- Print sense buffer.");
|
||||||
|
DicConsole.WriteLine("3.- Decode sense buffer.");
|
||||||
|
DicConsole.WriteLine("4.- Send command again.");
|
||||||
|
DicConsole.WriteLine("5.- Change parameters.");
|
||||||
|
DicConsole.WriteLine("0.- Return to Archive vendor commands menu.");
|
||||||
|
DicConsole.Write("Choose: ");
|
||||||
|
|
||||||
|
strDev = System.Console.ReadLine();
|
||||||
|
if(!int.TryParse(strDev, out 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 Archive vendor commands menu...");
|
||||||
|
return;
|
||||||
|
case 1:
|
||||||
|
System.Console.Clear();
|
||||||
|
DicConsole.WriteLine("Device: {0}", devPath);
|
||||||
|
DicConsole.WriteLine("REQUEST BLOCK ADDRESS response:");
|
||||||
|
if(buffer != null)
|
||||||
|
PrintHex.PrintHexArray(buffer, 64);
|
||||||
|
DicConsole.WriteLine("Press any key to continue...");
|
||||||
|
System.Console.ReadKey();
|
||||||
|
System.Console.Clear();
|
||||||
|
DicConsole.WriteLine("Device: {0}", devPath);
|
||||||
|
goto menu;
|
||||||
|
case 2:
|
||||||
|
System.Console.Clear();
|
||||||
|
DicConsole.WriteLine("Device: {0}", devPath);
|
||||||
|
DicConsole.WriteLine("REQUEST BLOCK ADDRESS 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 3:
|
||||||
|
System.Console.Clear();
|
||||||
|
DicConsole.WriteLine("Device: {0}", devPath);
|
||||||
|
DicConsole.WriteLine("REQUEST BLOCK ADDRESS decoded sense:");
|
||||||
|
DicConsole.Write("{0}", Decoders.SCSI.Sense.PrettifySense(senseBuffer));
|
||||||
|
DicConsole.WriteLine("Press any key to continue...");
|
||||||
|
System.Console.ReadKey();
|
||||||
|
System.Console.Clear();
|
||||||
|
DicConsole.WriteLine("Device: {0}", devPath);
|
||||||
|
goto menu;
|
||||||
|
case 4:
|
||||||
|
goto start;
|
||||||
|
case 5:
|
||||||
|
goto parameters;
|
||||||
|
default:
|
||||||
|
DicConsole.WriteLine("Incorrect option. Press any key to continue...");
|
||||||
|
System.Console.ReadKey();
|
||||||
|
System.Console.Clear();
|
||||||
|
goto menu;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void SeekBlock(string devPath, Device dev)
|
||||||
|
{
|
||||||
|
bool immediate = false;
|
||||||
|
uint lba = 0;
|
||||||
|
string strDev;
|
||||||
|
int item;
|
||||||
|
|
||||||
|
parameters:
|
||||||
|
while(true)
|
||||||
|
{
|
||||||
|
System.Console.Clear();
|
||||||
|
DicConsole.WriteLine("Device: {0}", devPath);
|
||||||
|
DicConsole.WriteLine("Parameters for SEEK BLOCK command:");
|
||||||
|
DicConsole.WriteLine("Immediate?: {0}", immediate);
|
||||||
|
DicConsole.WriteLine("LBA: {0}", lba);
|
||||||
|
DicConsole.WriteLine();
|
||||||
|
DicConsole.WriteLine("Choose what to do:");
|
||||||
|
DicConsole.WriteLine("1.- Change parameters.");
|
||||||
|
DicConsole.WriteLine("2.- Send command with these parameters.");
|
||||||
|
DicConsole.WriteLine("0.- Return to Archive vendor commands menu.");
|
||||||
|
|
||||||
|
strDev = System.Console.ReadLine();
|
||||||
|
if(!int.TryParse(strDev, out item))
|
||||||
|
{
|
||||||
|
DicConsole.WriteLine("Not a number. Press any key to continue...");
|
||||||
|
System.Console.ReadKey();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch(item)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
DicConsole.WriteLine("Returning to Archive vendor commands menu...");
|
||||||
|
return;
|
||||||
|
case 1:
|
||||||
|
DicConsole.Write("Immediate?: ");
|
||||||
|
strDev = System.Console.ReadLine();
|
||||||
|
if(!bool.TryParse(strDev, out immediate))
|
||||||
|
{
|
||||||
|
DicConsole.WriteLine("Not a boolean. Press any key to continue...");
|
||||||
|
immediate = false;
|
||||||
|
System.Console.ReadKey();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
DicConsole.Write("LBA?: ");
|
||||||
|
strDev = System.Console.ReadLine();
|
||||||
|
if(!uint.TryParse(strDev, out lba))
|
||||||
|
{
|
||||||
|
DicConsole.WriteLine("Not a number. Press any key to continue...");
|
||||||
|
lba = 0;
|
||||||
|
System.Console.ReadKey();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
goto start;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
start:
|
||||||
|
System.Console.Clear();
|
||||||
|
bool sense = dev.ArchiveCorpSeekBlock(out byte[] senseBuffer, immediate, lba, dev.Timeout, out double duration);
|
||||||
|
|
||||||
|
menu:
|
||||||
|
DicConsole.WriteLine("Device: {0}", devPath);
|
||||||
|
DicConsole.WriteLine("Sending SEEK BLOCK 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("SEEK BLOCK 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("3.- Change parameters.");
|
||||||
|
DicConsole.WriteLine("0.- Return to Archive vendor commands menu.");
|
||||||
|
DicConsole.Write("Choose: ");
|
||||||
|
|
||||||
|
strDev = System.Console.ReadLine();
|
||||||
|
if(!int.TryParse(strDev, out 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 Archive vendor commands menu...");
|
||||||
|
return;
|
||||||
|
case 1:
|
||||||
|
System.Console.Clear();
|
||||||
|
DicConsole.WriteLine("Device: {0}", devPath);
|
||||||
|
DicConsole.WriteLine("SEEK BLOCK 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;
|
||||||
|
case 3:
|
||||||
|
goto parameters;
|
||||||
|
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