mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Show ata/atapi identify information in device info gui panel.
This commit is contained in:
@@ -30,7 +30,10 @@
|
||||
// Copyright © 2011-2018 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using DiscImageChef.Core.Devices.Info;
|
||||
using DiscImageChef.Decoders.ATA;
|
||||
using Eto.Forms;
|
||||
using Eto.Serialization.Xaml;
|
||||
|
||||
@@ -38,10 +41,14 @@ namespace DiscImageChef.Gui
|
||||
{
|
||||
public class pnlDeviceInfo : Panel
|
||||
{
|
||||
DeviceInfo devInfo;
|
||||
|
||||
public pnlDeviceInfo(DeviceInfo devInfo)
|
||||
{
|
||||
XamlReader.Load(this);
|
||||
|
||||
this.devInfo = devInfo;
|
||||
|
||||
txtType.Text = devInfo.Type.ToString();
|
||||
txtManufacturer.Text = devInfo.Manufacturer;
|
||||
txtModel.Text = devInfo.Model;
|
||||
@@ -50,26 +57,124 @@ namespace DiscImageChef.Gui
|
||||
txtScsiType.Text = devInfo.ScsiType.ToString();
|
||||
chkRemovable.Checked = devInfo.IsRemovable;
|
||||
chkUsb.Checked = devInfo.IsUsb;
|
||||
|
||||
if(devInfo.AtaIdentify != null || devInfo.AtapiIdentify != null)
|
||||
{
|
||||
tabAta.Visible = true;
|
||||
|
||||
if(devInfo.AtaIdentify != null)
|
||||
{
|
||||
stkAtaMcpt.Visible = false;
|
||||
chkAtaMcpt.Checked = devInfo.AtaMcptError.HasValue;
|
||||
lblAtaMcpt.Visible = devInfo.AtaMcptError.HasValue;
|
||||
lblAtaIdentify.Text = "ATA IDENTIFY DEVICE";
|
||||
|
||||
if(devInfo.AtaMcptError.HasValue)
|
||||
{
|
||||
switch(devInfo.AtaMcptError.Value.DeviceHead & 0x7)
|
||||
{
|
||||
case 0:
|
||||
lblAtaMcpt.Text = "Device reports incorrect media card type";
|
||||
break;
|
||||
case 1:
|
||||
lblAtaMcpt.Text = "Device contains a Secure Digital card";
|
||||
break;
|
||||
case 2:
|
||||
lblAtaMcpt.Text = "Device contains a MultiMediaCard ";
|
||||
break;
|
||||
case 3:
|
||||
lblAtaMcpt.Text = "Device contains a Secure Digital I/O card";
|
||||
break;
|
||||
case 4:
|
||||
lblAtaMcpt.Text = "Device contains a Smart Media card";
|
||||
break;
|
||||
default:
|
||||
lblAtaMcpt.Text =
|
||||
$"Device contains unknown media card type {devInfo.AtaMcptError.Value.DeviceHead & 0x07}";
|
||||
break;
|
||||
}
|
||||
|
||||
chkAtaMcptWriteProtection.Checked = (devInfo.AtaMcptError.Value.DeviceHead & 0x08) == 0x08;
|
||||
|
||||
ushort specificData = (ushort)(devInfo.AtaMcptError.Value.CylinderHigh * 0x100 +
|
||||
devInfo.AtaMcptError.Value.CylinderLow);
|
||||
if(specificData != 0)
|
||||
{
|
||||
lblAtaMcptSpecificData.Visible = true;
|
||||
lblAtaMcptSpecificData.Text = $"Card specific data: 0x{specificData:X4}";
|
||||
}
|
||||
}
|
||||
|
||||
tabAta.Text = "ATA";
|
||||
txtAtaIdentify.Text = Identify.Prettify(this.devInfo.AtaIdentify);
|
||||
}
|
||||
else if(devInfo.AtapiIdentify != null)
|
||||
{
|
||||
lblAtaIdentify.Text = "ATA PACKET IDENTIFY DEVICE";
|
||||
stkAtaMcpt.Visible = false;
|
||||
tabAta.Text = "ATAPI";
|
||||
txtAtaIdentify.Text = Identify.Prettify(this.devInfo.AtapiIdentify);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void OnBtnSaveAtaBinary(object sender, EventArgs e)
|
||||
{
|
||||
SaveFileDialog dlgSaveBinary = new SaveFileDialog();
|
||||
dlgSaveBinary.Filters.Add(new FileFilter {Extensions = new[] {"*.bin"}, Name = "Binary"});
|
||||
DialogResult result = dlgSaveBinary.ShowDialog(this);
|
||||
|
||||
if(result != DialogResult.Ok) return;
|
||||
|
||||
FileStream saveFs = new FileStream(dlgSaveBinary.FileName, FileMode.Create);
|
||||
if(devInfo.AtaIdentify != null) saveFs.Write(devInfo.AtaIdentify, 0, devInfo.AtaIdentify.Length);
|
||||
else if(devInfo.AtapiIdentify != null) saveFs.Write(devInfo.AtapiIdentify, 0, devInfo.AtapiIdentify.Length);
|
||||
|
||||
saveFs.Close();
|
||||
}
|
||||
|
||||
protected void OnBtnSaveAtaText(object sender, EventArgs e)
|
||||
{
|
||||
SaveFileDialog dlgSaveText = new SaveFileDialog();
|
||||
dlgSaveText.Filters.Add(new FileFilter {Extensions = new[] {"*.txt"}, Name = "Text"});
|
||||
DialogResult result = dlgSaveText.ShowDialog(this);
|
||||
|
||||
if(result != DialogResult.Ok) return;
|
||||
|
||||
FileStream saveFs = new FileStream(dlgSaveText.FileName, FileMode.Create);
|
||||
StreamWriter saveSw = new StreamWriter(saveFs);
|
||||
saveSw.Write(txtAtaIdentify.Text);
|
||||
saveFs.Close();
|
||||
}
|
||||
|
||||
#region XAML controls
|
||||
Label lblDeviceInfo;
|
||||
TabControl tabInfos;
|
||||
TabPage tabGeneral;
|
||||
Label lblType;
|
||||
TextBox txtType;
|
||||
Label lblManufacturer;
|
||||
TextBox txtManufacturer;
|
||||
Label lblModel;
|
||||
TextBox txtModel;
|
||||
Label lblRevision;
|
||||
TextBox txtRevision;
|
||||
Label lblSerial;
|
||||
TextBox txtSerial;
|
||||
Label lblScsiType;
|
||||
TextBox txtScsiType;
|
||||
CheckBox chkRemovable;
|
||||
CheckBox chkUsb;
|
||||
Label lblDeviceInfo;
|
||||
TabControl tabInfos;
|
||||
TabPage tabGeneral;
|
||||
Label lblType;
|
||||
TextBox txtType;
|
||||
Label lblManufacturer;
|
||||
TextBox txtManufacturer;
|
||||
Label lblModel;
|
||||
TextBox txtModel;
|
||||
Label lblRevision;
|
||||
TextBox txtRevision;
|
||||
Label lblSerial;
|
||||
TextBox txtSerial;
|
||||
Label lblScsiType;
|
||||
TextBox txtScsiType;
|
||||
CheckBox chkRemovable;
|
||||
CheckBox chkUsb;
|
||||
TabPage tabAta;
|
||||
Label lblAtaIdentify;
|
||||
TextArea txtAtaIdentify;
|
||||
Button btnSaveAtaBinary;
|
||||
Button btnSaveAtaText;
|
||||
StackLayout stkAtaMcpt;
|
||||
CheckBox chkAtaMcpt;
|
||||
Label lblAtaMcpt;
|
||||
CheckBox chkAtaMcptWriteProtection;
|
||||
Label lblAtaMcptSpecificData;
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user