2017-09-07 20:30:23 +01:00
|
|
|
|
// /***************************************************************************
|
2020-07-25 02:01:36 +01:00
|
|
|
|
// Aaru Data Preservation Suite
|
2017-09-07 20:30:23 +01:00
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
//
|
|
|
|
|
|
// Filename : MCPT.cs
|
2017-12-19 03:50:57 +00:00
|
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
2017-09-07 20:30:23 +01:00
|
|
|
|
//
|
2020-07-25 02:01:36 +01:00
|
|
|
|
// Component : Aaru device testing.
|
2017-09-07 20:30:23 +01:00
|
|
|
|
//
|
|
|
|
|
|
// --[ 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/>.
|
|
|
|
|
|
//
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2022-02-18 10:02:53 +00:00
|
|
|
|
// Copyright © 2011-2022 Natalia Portillo
|
2017-09-07 20:30:23 +01:00
|
|
|
|
// ****************************************************************************/
|
2017-12-19 03:50:57 +00:00
|
|
|
|
|
2022-03-07 07:36:44 +00:00
|
|
|
|
namespace Aaru.Tests.Devices.ATA;
|
|
|
|
|
|
|
|
|
|
|
|
using System;
|
2020-02-27 00:33:26 +00:00
|
|
|
|
using Aaru.Console;
|
|
|
|
|
|
using Aaru.Decoders.ATA;
|
|
|
|
|
|
using Aaru.Devices;
|
2017-09-07 20:30:23 +01:00
|
|
|
|
|
2022-03-07 07:36:44 +00:00
|
|
|
|
static class Mcpt
|
2017-09-07 20:30:23 +01:00
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
internal static void Menu(string devPath, Device dev)
|
2017-09-07 20:30:23 +01:00
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
while(true)
|
2017-09-07 20:30:23 +01:00
|
|
|
|
{
|
2022-03-07 07:36:44 +00:00
|
|
|
|
Console.Clear();
|
2022-03-06 13:29:38 +00:00
|
|
|
|
AaruConsole.WriteLine("Device: {0}", devPath);
|
|
|
|
|
|
AaruConsole.WriteLine("Send a Media Card Pass Through command to the device:");
|
|
|
|
|
|
AaruConsole.WriteLine("1.- Send CHECK MEDIA CARD TYPE command.");
|
|
|
|
|
|
AaruConsole.WriteLine("0.- Return to ATA commands menu.");
|
|
|
|
|
|
AaruConsole.Write("Choose: ");
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2022-03-07 07:36:44 +00:00
|
|
|
|
string strDev = Console.ReadLine();
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(!int.TryParse(strDev, out int item))
|
|
|
|
|
|
{
|
|
|
|
|
|
AaruConsole.WriteLine("Not a number. Press any key to continue...");
|
2022-03-07 07:36:44 +00:00
|
|
|
|
Console.ReadKey();
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
continue;
|
2017-09-07 20:30:23 +01:00
|
|
|
|
}
|
2017-09-08 18:00:01 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
switch(item)
|
|
|
|
|
|
{
|
|
|
|
|
|
case 0:
|
|
|
|
|
|
AaruConsole.WriteLine("Returning to ATA commands menu...");
|
2017-09-08 18:00:01 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
return;
|
|
|
|
|
|
case 1:
|
|
|
|
|
|
CheckMediaCardType(devPath, dev);
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
continue;
|
|
|
|
|
|
default:
|
|
|
|
|
|
AaruConsole.WriteLine("Incorrect option. Press any key to continue...");
|
2022-03-07 07:36:44 +00:00
|
|
|
|
Console.ReadKey();
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2017-09-08 18:00:01 +01:00
|
|
|
|
continue;
|
|
|
|
|
|
}
|
2022-03-06 13:29:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-09-08 18:00:01 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
static void CheckMediaCardType(string devPath, Device dev)
|
|
|
|
|
|
{
|
|
|
|
|
|
byte feature = 0;
|
|
|
|
|
|
string strDev;
|
|
|
|
|
|
int item;
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2022-03-07 07:36:44 +00:00
|
|
|
|
parameters:
|
2017-09-08 18:00:01 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
while(true)
|
|
|
|
|
|
{
|
2022-03-07 07:36:44 +00:00
|
|
|
|
Console.Clear();
|
2020-02-29 18:03:35 +00:00
|
|
|
|
AaruConsole.WriteLine("Device: {0}", devPath);
|
2022-03-06 13:29:38 +00:00
|
|
|
|
AaruConsole.WriteLine("Parameters for CHECK MEDIA CARD TYPE command:");
|
|
|
|
|
|
AaruConsole.WriteLine("Feature: {0}", feature);
|
2020-02-29 18:03:35 +00:00
|
|
|
|
AaruConsole.WriteLine();
|
|
|
|
|
|
AaruConsole.WriteLine("Choose what to do:");
|
2022-03-06 13:29:38 +00:00
|
|
|
|
AaruConsole.WriteLine("1.- Change parameters.");
|
|
|
|
|
|
AaruConsole.WriteLine("2.- Send command with these parameters.");
|
2020-02-29 18:03:35 +00:00
|
|
|
|
AaruConsole.WriteLine("0.- Return to Media Card Pass Through commands menu.");
|
2017-09-08 18:00:01 +01:00
|
|
|
|
|
2022-03-07 07:36:44 +00:00
|
|
|
|
strDev = Console.ReadLine();
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2017-09-08 18:00:01 +01:00
|
|
|
|
if(!int.TryParse(strDev, out item))
|
|
|
|
|
|
{
|
2020-02-29 18:03:35 +00:00
|
|
|
|
AaruConsole.WriteLine("Not a number. Press any key to continue...");
|
2022-03-07 07:36:44 +00:00
|
|
|
|
Console.ReadKey();
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
continue;
|
2017-09-08 18:00:01 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
switch(item)
|
|
|
|
|
|
{
|
|
|
|
|
|
case 0:
|
2020-02-29 18:03:35 +00:00
|
|
|
|
AaruConsole.WriteLine("Returning to Media Card Pass Through commands menu...");
|
|
|
|
|
|
|
2017-09-08 18:00:01 +01:00
|
|
|
|
return;
|
2022-03-06 13:29:38 +00:00
|
|
|
|
case 1:
|
|
|
|
|
|
AaruConsole.Write("Feature?: ");
|
2022-03-07 07:36:44 +00:00
|
|
|
|
strDev = Console.ReadLine();
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
|
|
if(!byte.TryParse(strDev, out feature))
|
|
|
|
|
|
{
|
|
|
|
|
|
AaruConsole.WriteLine("Not a number. Press any key to continue...");
|
|
|
|
|
|
feature = 0;
|
2022-03-07 07:36:44 +00:00
|
|
|
|
Console.ReadKey();
|
2022-03-06 13:29:38 +00:00
|
|
|
|
}
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
break;
|
|
|
|
|
|
case 2: goto start;
|
2017-09-08 18:00:01 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
2022-03-07 07:36:44 +00:00
|
|
|
|
start:
|
|
|
|
|
|
Console.Clear();
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
|
|
bool sense = dev.CheckMediaCardType(feature, out AtaErrorRegistersChs errorRegisters, dev.Timeout,
|
|
|
|
|
|
out double duration);
|
|
|
|
|
|
|
2022-03-07 07:36:44 +00:00
|
|
|
|
menu:
|
2022-03-06 13:29:38 +00:00
|
|
|
|
AaruConsole.WriteLine("Device: {0}", devPath);
|
|
|
|
|
|
AaruConsole.WriteLine("Sending CHECK MEDIA CARD TYPE to the device:");
|
|
|
|
|
|
AaruConsole.WriteLine("Command took {0} ms.", duration);
|
|
|
|
|
|
AaruConsole.WriteLine("Sense is {0}.", sense);
|
|
|
|
|
|
AaruConsole.WriteLine("CHECK MEDIA CARD TYPE status registers:");
|
|
|
|
|
|
AaruConsole.Write("{0}", MainClass.DecodeAtaRegisters(errorRegisters));
|
|
|
|
|
|
AaruConsole.WriteLine();
|
|
|
|
|
|
AaruConsole.WriteLine("Choose what to do:");
|
|
|
|
|
|
AaruConsole.WriteLine("1.- Send command again.");
|
|
|
|
|
|
AaruConsole.WriteLine("2.- Change parameters.");
|
|
|
|
|
|
AaruConsole.WriteLine("0.- Return to Media Card Pass Through commands menu.");
|
|
|
|
|
|
AaruConsole.Write("Choose: ");
|
|
|
|
|
|
|
2022-03-07 07:36:44 +00:00
|
|
|
|
strDev = Console.ReadLine();
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
|
|
if(!int.TryParse(strDev, out item))
|
|
|
|
|
|
{
|
|
|
|
|
|
AaruConsole.WriteLine("Not a number. Press any key to continue...");
|
2022-03-07 07:36:44 +00:00
|
|
|
|
Console.ReadKey();
|
|
|
|
|
|
Console.Clear();
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
|
|
goto menu;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
switch(item)
|
|
|
|
|
|
{
|
|
|
|
|
|
case 0:
|
|
|
|
|
|
AaruConsole.WriteLine("Returning to Media Card Pass Through commands menu...");
|
|
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
case 1: goto start;
|
|
|
|
|
|
case 2: goto parameters;
|
|
|
|
|
|
default:
|
|
|
|
|
|
AaruConsole.WriteLine("Incorrect option. Press any key to continue...");
|
2022-03-07 07:36:44 +00:00
|
|
|
|
Console.ReadKey();
|
|
|
|
|
|
Console.Clear();
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
|
|
goto menu;
|
|
|
|
|
|
}
|
2017-09-07 20:30:23 +01:00
|
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
}
|