2017-09-07 20:30:23 +01:00
|
|
|
|
// /***************************************************************************
|
|
|
|
|
|
// The Disc Image Chef
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
//
|
|
|
|
|
|
// Filename : Certance.cs
|
2017-12-19 03:50:57 +00:00
|
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
2017-09-07 20:30:23 +01:00
|
|
|
|
//
|
2017-12-19 03:50:57 +00:00
|
|
|
|
// Component : DiscImageChef 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/>.
|
|
|
|
|
|
//
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2017-12-19 03:50:57 +00:00
|
|
|
|
// Copyright © 2011-2018 Natalia Portillo
|
2017-09-07 20:30:23 +01:00
|
|
|
|
// ****************************************************************************/
|
2017-12-19 03:50:57 +00:00
|
|
|
|
|
2017-09-07 20:30:23 +01:00
|
|
|
|
using DiscImageChef.Console;
|
|
|
|
|
|
using DiscImageChef.Devices;
|
|
|
|
|
|
|
|
|
|
|
|
namespace DiscImageChef.Tests.Devices.SCSI
|
|
|
|
|
|
{
|
|
|
|
|
|
public static class Certance
|
|
|
|
|
|
{
|
|
|
|
|
|
public static void Menu(string devPath, Device dev)
|
|
|
|
|
|
{
|
|
|
|
|
|
while(true)
|
|
|
|
|
|
{
|
|
|
|
|
|
System.Console.Clear();
|
|
|
|
|
|
DicConsole.WriteLine("Device: {0}", devPath);
|
|
|
|
|
|
DicConsole.WriteLine("Send a Certance vendor command to the device:");
|
2017-09-08 20:38:19 +01:00
|
|
|
|
DicConsole.WriteLine("1.- Send PARK command.");
|
|
|
|
|
|
DicConsole.WriteLine("2.- Send UNPARK command.");
|
2017-09-07 20:30:23 +01:00
|
|
|
|
DicConsole.WriteLine("0.- Return to SCSI 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 SCSI commands menu...");
|
|
|
|
|
|
return;
|
2017-09-08 20:38:19 +01:00
|
|
|
|
case 1:
|
|
|
|
|
|
Park(devPath, dev);
|
|
|
|
|
|
continue;
|
|
|
|
|
|
case 2:
|
|
|
|
|
|
Unpark(devPath, dev);
|
|
|
|
|
|
continue;
|
2017-09-07 20:30:23 +01:00
|
|
|
|
default:
|
|
|
|
|
|
DicConsole.WriteLine("Incorrect option. Press any key to continue...");
|
|
|
|
|
|
System.Console.ReadKey();
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-09-08 20:38:19 +01:00
|
|
|
|
|
|
|
|
|
|
static void Park(string devPath, Device dev)
|
|
|
|
|
|
{
|
2017-12-19 20:33:03 +00:00
|
|
|
|
start:
|
2017-09-08 20:38:19 +01:00
|
|
|
|
System.Console.Clear();
|
|
|
|
|
|
bool sense = dev.CertancePark(out byte[] senseBuffer, dev.Timeout, out double duration);
|
|
|
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
|
menu:
|
2017-09-08 20:38:19 +01:00
|
|
|
|
DicConsole.WriteLine("Device: {0}", devPath);
|
|
|
|
|
|
DicConsole.WriteLine("Sending PARK to the device:");
|
|
|
|
|
|
DicConsole.WriteLine("Command took {0} ms.", duration);
|
|
|
|
|
|
DicConsole.WriteLine("Sense is {0}.", sense);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
DicConsole.WriteLine("Sense buffer is {0} bytes.",
|
|
|
|
|
|
senseBuffer == null ? "null" : senseBuffer.Length.ToString());
|
2017-09-08 20:38:19 +01:00
|
|
|
|
DicConsole.WriteLine("Sense buffer is null or empty? {0}", ArrayHelpers.ArrayIsNullOrEmpty(senseBuffer));
|
|
|
|
|
|
DicConsole.WriteLine("PARK 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("0.- Return to Certance vendor 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();
|
|
|
|
|
|
System.Console.Clear();
|
|
|
|
|
|
goto menu;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
switch(item)
|
|
|
|
|
|
{
|
|
|
|
|
|
case 0:
|
|
|
|
|
|
DicConsole.WriteLine("Returning to Certance vendor commands menu...");
|
|
|
|
|
|
return;
|
|
|
|
|
|
case 1:
|
|
|
|
|
|
System.Console.Clear();
|
|
|
|
|
|
DicConsole.WriteLine("Device: {0}", devPath);
|
|
|
|
|
|
DicConsole.WriteLine("PARK sense:");
|
2017-12-19 20:33:03 +00:00
|
|
|
|
if(senseBuffer != null) PrintHex.PrintHexArray(senseBuffer, 64);
|
2017-09-08 20:38:19 +01:00
|
|
|
|
DicConsole.WriteLine("Press any key to continue...");
|
|
|
|
|
|
System.Console.ReadKey();
|
|
|
|
|
|
System.Console.Clear();
|
|
|
|
|
|
DicConsole.WriteLine("Device: {0}", devPath);
|
|
|
|
|
|
goto menu;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
case 2: goto start;
|
2017-09-08 20:38:19 +01:00
|
|
|
|
default:
|
|
|
|
|
|
DicConsole.WriteLine("Incorrect option. Press any key to continue...");
|
|
|
|
|
|
System.Console.ReadKey();
|
|
|
|
|
|
System.Console.Clear();
|
|
|
|
|
|
goto menu;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void Unpark(string devPath, Device dev)
|
|
|
|
|
|
{
|
2017-12-19 20:33:03 +00:00
|
|
|
|
start:
|
2017-09-08 20:38:19 +01:00
|
|
|
|
System.Console.Clear();
|
|
|
|
|
|
bool sense = dev.CertanceUnpark(out byte[] senseBuffer, dev.Timeout, out double duration);
|
|
|
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
|
menu:
|
2017-09-08 20:38:19 +01:00
|
|
|
|
DicConsole.WriteLine("Device: {0}", devPath);
|
|
|
|
|
|
DicConsole.WriteLine("Sending UNPARK to the device:");
|
|
|
|
|
|
DicConsole.WriteLine("Command took {0} ms.", duration);
|
|
|
|
|
|
DicConsole.WriteLine("Sense is {0}.", sense);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
DicConsole.WriteLine("Sense buffer is {0} bytes.",
|
|
|
|
|
|
senseBuffer == null ? "null" : senseBuffer.Length.ToString());
|
2017-09-08 20:38:19 +01:00
|
|
|
|
DicConsole.WriteLine("Sense buffer is null or empty? {0}", ArrayHelpers.ArrayIsNullOrEmpty(senseBuffer));
|
|
|
|
|
|
DicConsole.WriteLine("UNPARK 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("0.- Return to Certance vendor 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();
|
|
|
|
|
|
System.Console.Clear();
|
|
|
|
|
|
goto menu;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
switch(item)
|
|
|
|
|
|
{
|
|
|
|
|
|
case 0:
|
|
|
|
|
|
DicConsole.WriteLine("Returning to Certance vendor commands menu...");
|
|
|
|
|
|
return;
|
|
|
|
|
|
case 1:
|
|
|
|
|
|
System.Console.Clear();
|
|
|
|
|
|
DicConsole.WriteLine("Device: {0}", devPath);
|
|
|
|
|
|
DicConsole.WriteLine("UNPARK sense:");
|
2017-12-19 20:33:03 +00:00
|
|
|
|
if(senseBuffer != null) PrintHex.PrintHexArray(senseBuffer, 64);
|
2017-09-08 20:38:19 +01:00
|
|
|
|
DicConsole.WriteLine("Press any key to continue...");
|
|
|
|
|
|
System.Console.ReadKey();
|
|
|
|
|
|
System.Console.Clear();
|
|
|
|
|
|
DicConsole.WriteLine("Device: {0}", devPath);
|
|
|
|
|
|
goto menu;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
case 2: goto start;
|
2017-09-08 20:38:19 +01:00
|
|
|
|
default:
|
|
|
|
|
|
DicConsole.WriteLine("Incorrect option. Press any key to continue...");
|
|
|
|
|
|
System.Console.ReadKey();
|
|
|
|
|
|
System.Console.Clear();
|
|
|
|
|
|
goto menu;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-09-07 20:30:23 +01:00
|
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
}
|