Files
Aaru/DiscImageChef.Tests.Devices/ATA/MCPT.cs

162 lines
6.5 KiB
C#
Raw Normal View History

// /***************************************************************************
// The Disc Image Chef
// ----------------------------------------------------------------------------
//
// Filename : MCPT.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : DiscImageChef device testing.
//
// --[ License ] --------------------------------------------------------------
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
// ----------------------------------------------------------------------------
// Copyright © 2011-2018 Natalia Portillo
// ****************************************************************************/
using DiscImageChef.Console;
using DiscImageChef.Decoders.ATA;
2017-12-19 19:33:46 +00:00
using DiscImageChef.Devices;
namespace DiscImageChef.Tests.Devices.ATA
{
static class Mcpt
{
internal static void Menu(string devPath, Device dev)
{
while(true)
{
System.Console.Clear();
DicConsole.WriteLine("Device: {0}", devPath);
DicConsole.WriteLine("Send a Media Card Pass Through command to the device:");
DicConsole.WriteLine("1.- Send CHECK MEDIA CARD TYPE command.");
DicConsole.WriteLine("0.- Return to ATA 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();
continue;
}
switch(item)
{
case 0:
DicConsole.WriteLine("Returning to ATA commands menu...");
return;
case 1:
CheckMediaCardType(devPath, dev);
continue;
default:
DicConsole.WriteLine("Incorrect option. Press any key to continue...");
System.Console.ReadKey();
continue;
}
}
}
2017-09-08 18:21:52 +01:00
static void CheckMediaCardType(string devPath, Device dev)
{
2018-06-22 08:08:38 +01:00
byte feature = 0;
string strDev;
2018-06-22 08:08:38 +01:00
int item;
2017-12-19 20:33:03 +00:00
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();
}
2017-12-19 20:33:03 +00:00
break;
2017-12-19 20:33:03 +00:00
case 2: goto start;
}
}
2017-12-19 20:33:03 +00:00
start:
System.Console.Clear();
bool sense = dev.CheckMediaCardType(feature, out AtaErrorRegistersChs errorRegisters, dev.Timeout,
2017-12-19 20:33:03 +00:00
out double duration);
2017-12-19 20:33:03 +00:00
menu:
DicConsole.WriteLine("Device: {0}", devPath);
DicConsole.WriteLine("Sending CHECK MEDIA CARD TYPE to the device:");
DicConsole.WriteLine("Command took {0} ms.", duration);
2018-06-22 08:08:38 +01:00
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;
2017-12-19 20:33:03 +00:00
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;
}
}
}
2017-12-19 20:33:03 +00:00
}