2017-09-07 20:30:23 +01:00
|
|
|
|
// /***************************************************************************
|
|
|
|
|
|
// The Disc Image Chef
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
//
|
|
|
|
|
|
// Filename : Device.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/>.
|
|
|
|
|
|
//
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2018-12-29 17:34:38 +00:00
|
|
|
|
// Copyright © 2011-2019 Natalia Portillo
|
2017-09-07 20:30:23 +01:00
|
|
|
|
// ****************************************************************************/
|
2017-12-19 03:50:57 +00:00
|
|
|
|
|
2020-02-27 00:33:26 +00:00
|
|
|
|
using Aaru.Console;
|
|
|
|
|
|
using Aaru.Devices;
|
2017-09-07 20:30:23 +01:00
|
|
|
|
|
2020-02-27 00:33:26 +00:00
|
|
|
|
namespace Aaru.Tests.Devices
|
2017-09-07 20:30:23 +01:00
|
|
|
|
{
|
2020-02-29 18:03:35 +00:00
|
|
|
|
internal static partial class MainClass
|
2017-09-07 20:30:23 +01:00
|
|
|
|
{
|
|
|
|
|
|
public static void Device(string devPath)
|
|
|
|
|
|
{
|
2020-02-29 18:03:35 +00:00
|
|
|
|
AaruConsole.WriteLine("Going to open {0}. Press any key to continue...", devPath);
|
2017-09-07 20:30:23 +01:00
|
|
|
|
System.Console.ReadKey();
|
|
|
|
|
|
|
2020-02-29 18:03:35 +00:00
|
|
|
|
var dev = new Device(devPath);
|
2017-09-07 20:30:23 +01:00
|
|
|
|
|
|
|
|
|
|
while(true)
|
|
|
|
|
|
{
|
2020-02-29 18:03:35 +00:00
|
|
|
|
AaruConsole.WriteLine("dev.PlatformID = {0}", dev.PlatformId);
|
|
|
|
|
|
AaruConsole.WriteLine("dev.FileHandle = {0}", dev.FileHandle);
|
|
|
|
|
|
AaruConsole.WriteLine("dev.Timeout = {0}", dev.Timeout);
|
|
|
|
|
|
AaruConsole.WriteLine("dev.Error = {0}", dev.Error);
|
|
|
|
|
|
AaruConsole.WriteLine("dev.LastError = {0}", dev.LastError);
|
|
|
|
|
|
AaruConsole.WriteLine("dev.Type = {0}", dev.Type);
|
|
|
|
|
|
AaruConsole.WriteLine("dev.Manufacturer = \"{0}\"", dev.Manufacturer);
|
|
|
|
|
|
AaruConsole.WriteLine("dev.Model = \"{0}\"", dev.Model);
|
|
|
|
|
|
AaruConsole.WriteLine("dev.Revision = \"{0}\"", dev.FirmwareRevision);
|
|
|
|
|
|
AaruConsole.WriteLine("dev.Serial = \"{0}\"", dev.Serial);
|
|
|
|
|
|
AaruConsole.WriteLine("dev.SCSIType = {0}", dev.ScsiType);
|
|
|
|
|
|
AaruConsole.WriteLine("dev.IsRemovable = {0}", dev.IsRemovable);
|
|
|
|
|
|
AaruConsole.WriteLine("dev.IsUSB = {0}", dev.IsUsb);
|
|
|
|
|
|
AaruConsole.WriteLine("dev.USBVendorID = 0x{0:X4}", dev.UsbVendorId);
|
|
|
|
|
|
AaruConsole.WriteLine("dev.USBProductID = 0x{0:X4}", dev.UsbProductId);
|
|
|
|
|
|
|
|
|
|
|
|
AaruConsole.WriteLine("dev.USBDescriptors.Length = {0}",
|
|
|
|
|
|
dev.UsbDescriptors?.Length.ToString() ?? "null");
|
|
|
|
|
|
|
|
|
|
|
|
AaruConsole.WriteLine("dev.USBManufacturerString = \"{0}\"", dev.UsbManufacturerString);
|
|
|
|
|
|
AaruConsole.WriteLine("dev.USBProductString = \"{0}\"", dev.UsbProductString);
|
|
|
|
|
|
AaruConsole.WriteLine("dev.USBSerialString = \"{0}\"", dev.UsbSerialString);
|
|
|
|
|
|
AaruConsole.WriteLine("dev.IsFireWire = {0}", dev.IsFireWire);
|
|
|
|
|
|
AaruConsole.WriteLine("dev.FireWireGUID = {0:X16}", dev.FireWireGuid);
|
|
|
|
|
|
AaruConsole.WriteLine("dev.FireWireModel = 0x{0:X8}", dev.FireWireModel);
|
|
|
|
|
|
AaruConsole.WriteLine("dev.FireWireModelName = \"{0}\"", dev.FireWireModelName);
|
|
|
|
|
|
AaruConsole.WriteLine("dev.FireWireVendor = 0x{0:X8}", dev.FireWireVendor);
|
|
|
|
|
|
AaruConsole.WriteLine("dev.FireWireVendorName = \"{0}\"", dev.FireWireVendorName);
|
|
|
|
|
|
AaruConsole.WriteLine("dev.IsCompactFlash = {0}", dev.IsCompactFlash);
|
|
|
|
|
|
AaruConsole.WriteLine("dev.IsPCMCIA = {0}", dev.IsPcmcia);
|
|
|
|
|
|
AaruConsole.WriteLine("dev.CIS.Length = {0}", dev.Cis?.Length.ToString() ?? "null");
|
|
|
|
|
|
|
|
|
|
|
|
AaruConsole.WriteLine("Press any key to continue...", devPath);
|
2017-09-07 20:30:23 +01:00
|
|
|
|
System.Console.ReadKey();
|
|
|
|
|
|
|
|
|
|
|
|
menu:
|
|
|
|
|
|
System.Console.Clear();
|
2020-02-29 18:03:35 +00:00
|
|
|
|
AaruConsole.WriteLine("Device: {0}", devPath);
|
|
|
|
|
|
AaruConsole.WriteLine("Options:");
|
|
|
|
|
|
AaruConsole.WriteLine("1.- Print USB descriptors.");
|
|
|
|
|
|
AaruConsole.WriteLine("2.- Print PCMCIA CIS.");
|
|
|
|
|
|
AaruConsole.WriteLine("3.- Send a command to the device.");
|
|
|
|
|
|
AaruConsole.WriteLine("0.- Return to device selection.");
|
|
|
|
|
|
AaruConsole.Write("Choose: ");
|
2017-09-07 20:30:23 +01:00
|
|
|
|
|
|
|
|
|
|
string strDev = System.Console.ReadLine();
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2017-09-07 20:30:23 +01:00
|
|
|
|
if(!int.TryParse(strDev, out int item))
|
|
|
|
|
|
{
|
2020-02-29 18:03:35 +00:00
|
|
|
|
AaruConsole.WriteLine("Not a number. Press any key to continue...");
|
2017-09-07 20:30:23 +01:00
|
|
|
|
System.Console.ReadKey();
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2017-09-07 20:30:23 +01:00
|
|
|
|
goto menu;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
switch(item)
|
|
|
|
|
|
{
|
|
|
|
|
|
case 0:
|
2020-02-29 18:03:35 +00:00
|
|
|
|
AaruConsole.WriteLine("Returning to device selection...");
|
|
|
|
|
|
|
2017-09-07 20:30:23 +01:00
|
|
|
|
return;
|
|
|
|
|
|
case 1:
|
|
|
|
|
|
System.Console.Clear();
|
2020-02-29 18:03:35 +00:00
|
|
|
|
AaruConsole.WriteLine("Device: {0}", devPath);
|
|
|
|
|
|
AaruConsole.WriteLine("USB descriptors:");
|
|
|
|
|
|
|
|
|
|
|
|
if(dev.UsbDescriptors != null)
|
|
|
|
|
|
PrintHex.PrintHexArray(dev.UsbDescriptors, 64);
|
|
|
|
|
|
|
|
|
|
|
|
AaruConsole.WriteLine("Press any key to continue...");
|
2017-09-07 20:30:23 +01:00
|
|
|
|
System.Console.ReadKey();
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2017-09-07 20:30:23 +01:00
|
|
|
|
goto menu;
|
|
|
|
|
|
case 2:
|
|
|
|
|
|
System.Console.Clear();
|
2020-02-29 18:03:35 +00:00
|
|
|
|
AaruConsole.WriteLine("Device: {0}", devPath);
|
|
|
|
|
|
AaruConsole.WriteLine("PCMCIA CIS:");
|
|
|
|
|
|
|
|
|
|
|
|
if(dev.Cis != null)
|
|
|
|
|
|
PrintHex.PrintHexArray(dev.Cis, 64);
|
|
|
|
|
|
|
|
|
|
|
|
AaruConsole.WriteLine("Press any key to continue...");
|
2017-09-07 20:30:23 +01:00
|
|
|
|
System.Console.ReadKey();
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2017-09-07 20:30:23 +01:00
|
|
|
|
goto menu;
|
|
|
|
|
|
case 3:
|
|
|
|
|
|
Command(devPath, dev);
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2017-09-07 20:30:23 +01:00
|
|
|
|
goto menu;
|
|
|
|
|
|
default:
|
2020-02-29 18:03:35 +00:00
|
|
|
|
AaruConsole.WriteLine("Incorrect option. Press any key to continue...");
|
2017-09-07 20:30:23 +01:00
|
|
|
|
System.Console.ReadKey();
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2017-09-07 20:30:23 +01:00
|
|
|
|
goto menu;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
}
|