mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Added tests for Media Card Pass Through commands.
This commit is contained in:
@@ -39,30 +39,22 @@ namespace DiscImageChef.Devices
|
|||||||
{
|
{
|
||||||
public bool EnableMediaCardPassThrough(out AtaErrorRegistersCHS statusRegisters, uint timeout, out double duration)
|
public bool EnableMediaCardPassThrough(out AtaErrorRegistersCHS statusRegisters, uint timeout, out double duration)
|
||||||
{
|
{
|
||||||
byte[] buffer = new byte[0];
|
return CheckMediaCardType(1, out statusRegisters, timeout, out duration);
|
||||||
AtaRegistersCHS registers = new AtaRegistersCHS();
|
|
||||||
bool sense;
|
|
||||||
|
|
||||||
registers.command = (byte)AtaCommands.CheckMediaCardType;
|
|
||||||
registers.feature = 1;
|
|
||||||
|
|
||||||
lastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData, AtaTransferRegister.NoTransfer,
|
|
||||||
ref buffer, timeout, false, out duration, out sense);
|
|
||||||
error = lastError != 0;
|
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("ATA Device", "CHECK MEDIA CARD TYPE took {0} ms.", duration);
|
|
||||||
|
|
||||||
return sense;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool DisableMediaCardPassThrough(out AtaErrorRegistersCHS statusRegisters, uint timeout, out double duration)
|
public bool DisableMediaCardPassThrough(out AtaErrorRegistersCHS statusRegisters, uint timeout, out double duration)
|
||||||
|
{
|
||||||
|
return CheckMediaCardType(0, out statusRegisters, timeout, out duration);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool CheckMediaCardType(byte feature, out AtaErrorRegistersCHS statusRegisters, uint timeout, out double duration)
|
||||||
{
|
{
|
||||||
byte[] buffer = new byte[0];
|
byte[] buffer = new byte[0];
|
||||||
AtaRegistersCHS registers = new AtaRegistersCHS();
|
AtaRegistersCHS registers = new AtaRegistersCHS();
|
||||||
bool sense;
|
bool sense;
|
||||||
|
|
||||||
registers.command = (byte)AtaCommands.CheckMediaCardType;
|
registers.command = (byte)AtaCommands.CheckMediaCardType;
|
||||||
registers.feature = 0;
|
registers.feature = feature;
|
||||||
|
|
||||||
lastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData, AtaTransferRegister.NoTransfer,
|
lastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData, AtaTransferRegister.NoTransfer,
|
||||||
ref buffer, timeout, false, out duration, out sense);
|
ref buffer, timeout, false, out duration, out sense);
|
||||||
|
|||||||
@@ -848,7 +848,6 @@ namespace DiscImageChef.Tests.Devices.ATA
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void Seek(string devPath, Device dev)
|
public static void Seek(string devPath, Device dev)
|
||||||
{
|
{
|
||||||
ushort cylinder = 0;
|
ushort cylinder = 0;
|
||||||
|
|||||||
@@ -37,6 +37,7 @@
|
|||||||
// //$Id$
|
// //$Id$
|
||||||
using DiscImageChef.Console;
|
using DiscImageChef.Console;
|
||||||
using DiscImageChef.Devices;
|
using DiscImageChef.Devices;
|
||||||
|
using DiscImageChef.Decoders.ATA;
|
||||||
|
|
||||||
namespace DiscImageChef.Tests.Devices.ATA
|
namespace DiscImageChef.Tests.Devices.ATA
|
||||||
{
|
{
|
||||||
@@ -66,6 +67,9 @@ namespace DiscImageChef.Tests.Devices.ATA
|
|||||||
case 0:
|
case 0:
|
||||||
DicConsole.WriteLine("Returning to ATA commands menu...");
|
DicConsole.WriteLine("Returning to ATA commands menu...");
|
||||||
return;
|
return;
|
||||||
|
case 1:
|
||||||
|
CheckMediaCardType(devPath, dev);
|
||||||
|
continue;
|
||||||
default:
|
default:
|
||||||
DicConsole.WriteLine("Incorrect option. Press any key to continue...");
|
DicConsole.WriteLine("Incorrect option. Press any key to continue...");
|
||||||
System.Console.ReadKey();
|
System.Console.ReadKey();
|
||||||
@@ -73,6 +77,98 @@ namespace DiscImageChef.Tests.Devices.ATA
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void CheckMediaCardType(string devPath, Device dev)
|
||||||
|
{
|
||||||
|
byte feature = 0;
|
||||||
|
string strDev;
|
||||||
|
int item;
|
||||||
|
|
||||||
|
parameters:
|
||||||
|
while(true)
|
||||||
|
{
|
||||||
|
System.Console.Clear();
|
||||||
|
DicConsole.WriteLine("Device: {0}", devPath);
|
||||||
|
DicConsole.WriteLine("Parameters for CHECK MEDIA CARD TYPE command:");
|
||||||
|
DicConsole.WriteLine("Feature: {0}", feature);
|
||||||
|
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 Media Card Pass Through 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 Media Card Pass Through commands menu...");
|
||||||
|
return;
|
||||||
|
case 1:
|
||||||
|
DicConsole.Write("Feature?: ");
|
||||||
|
strDev = System.Console.ReadLine();
|
||||||
|
if(!byte.TryParse(strDev, out feature))
|
||||||
|
{
|
||||||
|
DicConsole.WriteLine("Not a number. Press any key to continue...");
|
||||||
|
feature = 0;
|
||||||
|
System.Console.ReadKey();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
goto start;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
start:
|
||||||
|
System.Console.Clear();
|
||||||
|
bool sense = dev.CheckMediaCardType(feature, out AtaErrorRegistersCHS errorRegisters, dev.Timeout, out double duration);
|
||||||
|
|
||||||
|
menu:
|
||||||
|
DicConsole.WriteLine("Device: {0}", devPath);
|
||||||
|
DicConsole.WriteLine("Sending CHECK MEDIA CARD TYPE to the device:");
|
||||||
|
DicConsole.WriteLine("Command took {0} ms.", duration);
|
||||||
|
DicConsole.WriteLine("Sense is {0}.", sense);
|
||||||
|
DicConsole.WriteLine("CHECK MEDIA CARD TYPE status registers:");
|
||||||
|
DicConsole.Write("{0}", MainClass.DecodeATARegisters(errorRegisters));
|
||||||
|
DicConsole.WriteLine();
|
||||||
|
DicConsole.WriteLine("Choose what to do:");
|
||||||
|
DicConsole.WriteLine("1.- Send command again.");
|
||||||
|
DicConsole.WriteLine("2.- Change parameters.");
|
||||||
|
DicConsole.WriteLine("0.- Return to Media Card Pass Through 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 Media Card Pass Through commands menu...");
|
||||||
|
return;
|
||||||
|
case 1:
|
||||||
|
goto start;
|
||||||
|
case 2:
|
||||||
|
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