mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Move SecureDigital / MultiMediaCard device reporting to non-static class and its UI to CLI.
This commit is contained in:
@@ -39,26 +39,14 @@ namespace DiscImageChef.Core.Devices.Report
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Implements creating a device report for a SecureDigital or MultiMediaCard flash card
|
/// Implements creating a device report for a SecureDigital or MultiMediaCard flash card
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static class SecureDigital
|
public partial class DeviceReport
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a device report for a SecureDigital or MultiMediaCard flash card
|
/// Creates a device report for a SecureDigital or MultiMediaCard flash card
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="dev">Device</param>
|
public MmcSd MmcSdReport()
|
||||||
/// <param name="report">Device report</param>
|
|
||||||
public static void Report(Device dev, ref DeviceReportV2 report)
|
|
||||||
{
|
{
|
||||||
if(report == null) return;
|
MmcSd report = new MmcSd();
|
||||||
|
|
||||||
switch(dev.Type)
|
|
||||||
{
|
|
||||||
case DeviceType.MMC:
|
|
||||||
report.MultiMediaCard = new MmcSd();
|
|
||||||
break;
|
|
||||||
case DeviceType.SecureDigital:
|
|
||||||
report.SecureDigital = new MmcSd();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
DicConsole.WriteLine("Trying to get CID...");
|
DicConsole.WriteLine("Trying to get CID...");
|
||||||
bool sense = dev.ReadCid(out byte[] cid, out _, dev.Timeout, out _);
|
bool sense = dev.ReadCid(out byte[] cid, out _, dev.Timeout, out _);
|
||||||
@@ -71,24 +59,24 @@ namespace DiscImageChef.Core.Devices.Report
|
|||||||
{
|
{
|
||||||
case DeviceType.SecureDigital:
|
case DeviceType.SecureDigital:
|
||||||
// Clear serial number and manufacturing date
|
// Clear serial number and manufacturing date
|
||||||
cid[9] = 0;
|
cid[9] = 0;
|
||||||
cid[10] = 0;
|
cid[10] = 0;
|
||||||
cid[11] = 0;
|
cid[11] = 0;
|
||||||
cid[12] = 0;
|
cid[12] = 0;
|
||||||
cid[13] = 0;
|
cid[13] = 0;
|
||||||
cid[14] = 0;
|
cid[14] = 0;
|
||||||
report.SecureDigital.CID = cid;
|
|
||||||
break;
|
break;
|
||||||
case DeviceType.MMC:
|
case DeviceType.MMC:
|
||||||
// Clear serial number and manufacturing date
|
// Clear serial number and manufacturing date
|
||||||
cid[10] = 0;
|
cid[10] = 0;
|
||||||
cid[11] = 0;
|
cid[11] = 0;
|
||||||
cid[12] = 0;
|
cid[12] = 0;
|
||||||
cid[13] = 0;
|
cid[13] = 0;
|
||||||
cid[14] = 0;
|
cid[14] = 0;
|
||||||
report.MultiMediaCard.CID = cid;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
report.CID = cid;
|
||||||
}
|
}
|
||||||
else DicConsole.WriteLine("Could not read CID...");
|
else DicConsole.WriteLine("Could not read CID...");
|
||||||
|
|
||||||
@@ -98,40 +86,45 @@ namespace DiscImageChef.Core.Devices.Report
|
|||||||
if(!sense)
|
if(!sense)
|
||||||
{
|
{
|
||||||
DicConsole.WriteLine("CSD obtained correctly...");
|
DicConsole.WriteLine("CSD obtained correctly...");
|
||||||
|
report.CSD = csd;
|
||||||
switch(dev.Type)
|
|
||||||
{
|
|
||||||
case DeviceType.MMC:
|
|
||||||
report.MultiMediaCard.CSD = csd;
|
|
||||||
break;
|
|
||||||
case DeviceType.SecureDigital:
|
|
||||||
report.SecureDigital.CSD = csd;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else DicConsole.WriteLine("Could not read CSD...");
|
else DicConsole.WriteLine("Could not read CSD...");
|
||||||
|
|
||||||
|
sense = true;
|
||||||
|
byte[] ocr = null;
|
||||||
|
DicConsole.WriteLine("Trying to get OCR...");
|
||||||
|
switch(dev.Type)
|
||||||
|
{
|
||||||
|
case DeviceType.MMC:
|
||||||
|
{
|
||||||
|
sense = dev.ReadOcr(out ocr, out _, dev.Timeout, out _);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DeviceType.SecureDigital:
|
||||||
|
{
|
||||||
|
sense = dev.ReadSdocr(out ocr, out _, dev.Timeout, out _);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!sense)
|
||||||
|
{
|
||||||
|
DicConsole.WriteLine("OCR obtained correctly...");
|
||||||
|
report.OCR = ocr;
|
||||||
|
}
|
||||||
|
else DicConsole.WriteLine("Could not read OCR...");
|
||||||
|
|
||||||
switch(dev.Type)
|
switch(dev.Type)
|
||||||
{
|
{
|
||||||
case DeviceType.MMC:
|
case DeviceType.MMC:
|
||||||
{
|
{
|
||||||
DicConsole.WriteLine("Trying to get OCR...");
|
|
||||||
sense = dev.ReadOcr(out byte[] ocr, out _, dev.Timeout, out _);
|
|
||||||
|
|
||||||
if(!sense)
|
|
||||||
{
|
|
||||||
DicConsole.WriteLine("OCR obtained correctly...");
|
|
||||||
report.MultiMediaCard.OCR = ocr;
|
|
||||||
}
|
|
||||||
else DicConsole.WriteLine("Could not read OCR...");
|
|
||||||
|
|
||||||
DicConsole.WriteLine("Trying to get Extended CSD...");
|
DicConsole.WriteLine("Trying to get Extended CSD...");
|
||||||
sense = dev.ReadExtendedCsd(out byte[] ecsd, out _, dev.Timeout, out _);
|
sense = dev.ReadExtendedCsd(out byte[] ecsd, out _, dev.Timeout, out _);
|
||||||
|
|
||||||
if(!sense)
|
if(!sense)
|
||||||
{
|
{
|
||||||
DicConsole.WriteLine("Extended CSD obtained correctly...");
|
DicConsole.WriteLine("Extended CSD obtained correctly...");
|
||||||
report.MultiMediaCard.ExtendedCSD = ecsd;
|
report.ExtendedCSD = ecsd;
|
||||||
}
|
}
|
||||||
else DicConsole.WriteLine("Could not read Extended CSD...");
|
else DicConsole.WriteLine("Could not read Extended CSD...");
|
||||||
|
|
||||||
@@ -139,29 +132,21 @@ namespace DiscImageChef.Core.Devices.Report
|
|||||||
}
|
}
|
||||||
case DeviceType.SecureDigital:
|
case DeviceType.SecureDigital:
|
||||||
{
|
{
|
||||||
DicConsole.WriteLine("Trying to get OCR...");
|
|
||||||
sense = dev.ReadSdocr(out byte[] ocr, out _, dev.Timeout, out _);
|
|
||||||
|
|
||||||
if(!sense)
|
|
||||||
{
|
|
||||||
DicConsole.WriteLine("OCR obtained correctly...");
|
|
||||||
report.SecureDigital.OCR = ocr;
|
|
||||||
}
|
|
||||||
else DicConsole.WriteLine("Could not read OCR...");
|
|
||||||
|
|
||||||
DicConsole.WriteLine("Trying to get SCR...");
|
DicConsole.WriteLine("Trying to get SCR...");
|
||||||
sense = dev.ReadScr(out byte[] scr, out _, dev.Timeout, out _);
|
sense = dev.ReadScr(out byte[] scr, out _, dev.Timeout, out _);
|
||||||
|
|
||||||
if(!sense)
|
if(!sense)
|
||||||
{
|
{
|
||||||
DicConsole.WriteLine("SCR obtained correctly...");
|
DicConsole.WriteLine("SCR obtained correctly...");
|
||||||
report.SecureDigital.SCR = scr;
|
report.SCR = scr;
|
||||||
}
|
}
|
||||||
else DicConsole.WriteLine("Could not read SCR...");
|
else DicConsole.WriteLine("Could not read SCR...");
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return report;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -34,7 +34,6 @@ using System;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using DiscImageChef.CommonTypes.Metadata;
|
using DiscImageChef.CommonTypes.Metadata;
|
||||||
using DiscImageChef.Console;
|
using DiscImageChef.Console;
|
||||||
using DiscImageChef.Core.Devices.Report;
|
|
||||||
using DiscImageChef.Core.Devices.Report.SCSI;
|
using DiscImageChef.Core.Devices.Report.SCSI;
|
||||||
using DiscImageChef.Devices;
|
using DiscImageChef.Devices;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
@@ -141,11 +140,14 @@ namespace DiscImageChef.Commands
|
|||||||
Ata.Report(dev, ref report, options.Debug, ref removable);
|
Ata.Report(dev, ref report, options.Debug, ref removable);
|
||||||
break;
|
break;
|
||||||
case DeviceType.MMC:
|
case DeviceType.MMC:
|
||||||
|
report.MultiMediaCard = reporter.MmcSdReport();
|
||||||
|
break;
|
||||||
case DeviceType.SecureDigital:
|
case DeviceType.SecureDigital:
|
||||||
SecureDigital.Report(dev, ref report);
|
report.SecureDigital = reporter.MmcSdReport();
|
||||||
break;
|
break;
|
||||||
case DeviceType.NVMe:
|
case DeviceType.NVMe:
|
||||||
throw new NotImplementedException("NVMe devices not yet supported.");
|
throw new NotImplementedException("NVMe devices not yet supported.");
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case DeviceType.ATAPI:
|
case DeviceType.ATAPI:
|
||||||
case DeviceType.SCSI:
|
case DeviceType.SCSI:
|
||||||
|
|||||||
Reference in New Issue
Block a user