mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Code restyling.
This commit is contained in:
@@ -32,38 +32,43 @@ using Aaru.Devices;
|
||||
|
||||
namespace Aaru.Tests.Devices.ATA
|
||||
{
|
||||
static class Atapi
|
||||
internal static class Atapi
|
||||
{
|
||||
internal static void Menu(string devPath, Device dev)
|
||||
{
|
||||
while(true)
|
||||
{
|
||||
System.Console.Clear();
|
||||
DicConsole.WriteLine("Device: {0}", devPath);
|
||||
DicConsole.WriteLine("Send an ATAPI command to the device:");
|
||||
DicConsole.WriteLine("1.- Send IDENTIFY PACKET DEVICE command.");
|
||||
DicConsole.WriteLine("0.- Return to ATA commands menu.");
|
||||
DicConsole.Write("Choose: ");
|
||||
AaruConsole.WriteLine("Device: {0}", devPath);
|
||||
AaruConsole.WriteLine("Send an ATAPI command to the device:");
|
||||
AaruConsole.WriteLine("1.- Send IDENTIFY PACKET DEVICE command.");
|
||||
AaruConsole.WriteLine("0.- Return to ATA commands menu.");
|
||||
AaruConsole.Write("Choose: ");
|
||||
|
||||
string strDev = System.Console.ReadLine();
|
||||
|
||||
if(!int.TryParse(strDev, out int item))
|
||||
{
|
||||
DicConsole.WriteLine("Not a number. Press any key to continue...");
|
||||
AaruConsole.WriteLine("Not a number. Press any key to continue...");
|
||||
System.Console.ReadKey();
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
switch(item)
|
||||
{
|
||||
case 0:
|
||||
DicConsole.WriteLine("Returning to ATA commands menu...");
|
||||
AaruConsole.WriteLine("Returning to ATA commands menu...");
|
||||
|
||||
return;
|
||||
case 1:
|
||||
Identify(devPath, dev);
|
||||
|
||||
continue;
|
||||
default:
|
||||
DicConsole.WriteLine("Incorrect option. Press any key to continue...");
|
||||
AaruConsole.WriteLine("Incorrect option. Press any key to continue...");
|
||||
System.Console.ReadKey();
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -73,74 +78,88 @@ namespace Aaru.Tests.Devices.ATA
|
||||
{
|
||||
start:
|
||||
System.Console.Clear();
|
||||
|
||||
bool sense = dev.AtapiIdentify(out byte[] buffer, out AtaErrorRegistersChs errorRegisters,
|
||||
out double duration);
|
||||
|
||||
menu:
|
||||
DicConsole.WriteLine("Device: {0}", devPath);
|
||||
DicConsole.WriteLine("Sending IDENTIFY PACKET DEVICE to the device:");
|
||||
DicConsole.WriteLine("Command took {0} ms.", duration);
|
||||
DicConsole.WriteLine("Sense is {0}.", sense);
|
||||
DicConsole.WriteLine("Buffer is {0} bytes.", buffer?.Length.ToString() ?? "null");
|
||||
DicConsole.WriteLine("Buffer is null or empty? {0}", ArrayHelpers.ArrayIsNullOrEmpty(buffer));
|
||||
DicConsole.WriteLine();
|
||||
DicConsole.WriteLine("Choose what to do:");
|
||||
DicConsole.WriteLine("1.- Print buffer.");
|
||||
DicConsole.WriteLine("2.- Decode buffer.");
|
||||
DicConsole.WriteLine("3.- Decode error registers.");
|
||||
DicConsole.WriteLine("4.- Send command again.");
|
||||
DicConsole.WriteLine("0.- Return to ATAPI commands menu.");
|
||||
DicConsole.Write("Choose: ");
|
||||
AaruConsole.WriteLine("Device: {0}", devPath);
|
||||
AaruConsole.WriteLine("Sending IDENTIFY PACKET DEVICE to the device:");
|
||||
AaruConsole.WriteLine("Command took {0} ms.", duration);
|
||||
AaruConsole.WriteLine("Sense is {0}.", sense);
|
||||
AaruConsole.WriteLine("Buffer is {0} bytes.", buffer?.Length.ToString() ?? "null");
|
||||
AaruConsole.WriteLine("Buffer is null or empty? {0}", ArrayHelpers.ArrayIsNullOrEmpty(buffer));
|
||||
AaruConsole.WriteLine();
|
||||
AaruConsole.WriteLine("Choose what to do:");
|
||||
AaruConsole.WriteLine("1.- Print buffer.");
|
||||
AaruConsole.WriteLine("2.- Decode buffer.");
|
||||
AaruConsole.WriteLine("3.- Decode error registers.");
|
||||
AaruConsole.WriteLine("4.- Send command again.");
|
||||
AaruConsole.WriteLine("0.- Return to ATAPI commands menu.");
|
||||
AaruConsole.Write("Choose: ");
|
||||
|
||||
string strDev = System.Console.ReadLine();
|
||||
|
||||
if(!int.TryParse(strDev, out int item))
|
||||
{
|
||||
DicConsole.WriteLine("Not a number. Press any key to continue...");
|
||||
AaruConsole.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 ATAPI commands menu...");
|
||||
AaruConsole.WriteLine("Returning to ATAPI commands menu...");
|
||||
|
||||
return;
|
||||
case 1:
|
||||
System.Console.Clear();
|
||||
DicConsole.WriteLine("Device: {0}", devPath);
|
||||
DicConsole.WriteLine("IDENTIFY PACKET DEVICE response:");
|
||||
if(buffer != null) PrintHex.PrintHexArray(buffer, 64);
|
||||
DicConsole.WriteLine("Press any key to continue...");
|
||||
AaruConsole.WriteLine("Device: {0}", devPath);
|
||||
AaruConsole.WriteLine("IDENTIFY PACKET DEVICE response:");
|
||||
|
||||
if(buffer != null)
|
||||
PrintHex.PrintHexArray(buffer, 64);
|
||||
|
||||
AaruConsole.WriteLine("Press any key to continue...");
|
||||
System.Console.ReadKey();
|
||||
System.Console.Clear();
|
||||
DicConsole.WriteLine("Device: {0}", devPath);
|
||||
AaruConsole.WriteLine("Device: {0}", devPath);
|
||||
|
||||
goto menu;
|
||||
case 2:
|
||||
System.Console.Clear();
|
||||
DicConsole.WriteLine("Device: {0}", devPath);
|
||||
DicConsole.WriteLine("IDENTIFY PACKET DEVICE decoded response:");
|
||||
if(buffer != null) DicConsole.WriteLine("{0}", Decoders.ATA.Identify.Prettify(buffer));
|
||||
DicConsole.WriteLine("Press any key to continue...");
|
||||
AaruConsole.WriteLine("Device: {0}", devPath);
|
||||
AaruConsole.WriteLine("IDENTIFY PACKET DEVICE decoded response:");
|
||||
|
||||
if(buffer != null)
|
||||
AaruConsole.WriteLine("{0}", Decoders.ATA.Identify.Prettify(buffer));
|
||||
|
||||
AaruConsole.WriteLine("Press any key to continue...");
|
||||
System.Console.ReadKey();
|
||||
System.Console.Clear();
|
||||
DicConsole.WriteLine("Device: {0}", devPath);
|
||||
AaruConsole.WriteLine("Device: {0}", devPath);
|
||||
|
||||
goto menu;
|
||||
case 3:
|
||||
System.Console.Clear();
|
||||
DicConsole.WriteLine("Device: {0}", devPath);
|
||||
DicConsole.WriteLine("IDENTIFY PACKET DEVICE status registers:");
|
||||
DicConsole.Write("{0}", MainClass.DecodeAtaRegisters(errorRegisters));
|
||||
DicConsole.WriteLine("Press any key to continue...");
|
||||
AaruConsole.WriteLine("Device: {0}", devPath);
|
||||
AaruConsole.WriteLine("IDENTIFY PACKET DEVICE status registers:");
|
||||
AaruConsole.Write("{0}", MainClass.DecodeAtaRegisters(errorRegisters));
|
||||
AaruConsole.WriteLine("Press any key to continue...");
|
||||
System.Console.ReadKey();
|
||||
System.Console.Clear();
|
||||
DicConsole.WriteLine("Device: {0}", devPath);
|
||||
AaruConsole.WriteLine("Device: {0}", devPath);
|
||||
|
||||
goto menu;
|
||||
case 4: goto start;
|
||||
default:
|
||||
DicConsole.WriteLine("Incorrect option. Press any key to continue...");
|
||||
AaruConsole.WriteLine("Incorrect option. Press any key to continue...");
|
||||
System.Console.ReadKey();
|
||||
System.Console.Clear();
|
||||
|
||||
goto menu;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user