Store MMC GET CONFIGURATION response in device report.

This commit is contained in:
2018-12-25 16:15:33 +00:00
parent 177c140dd4
commit c670bc2bc9
11 changed files with 1668 additions and 7 deletions

View File

@@ -326,6 +326,8 @@
<e p="20181224172147_FixUsbIdsAndIndexes.cs" t="Include" />
<e p="20181225002740_AddCdOffsets.Designer.cs" t="Include" />
<e p="20181225002740_AddCdOffsets.cs" t="Include" />
<e p="20181225152947_StoreMmcGetConfigurationResponse.Designer.cs" t="Include" />
<e p="20181225152947_StoreMmcGetConfigurationResponse.cs" t="Include" />
<e p="DicContextModelSnapshot.cs" t="Include" />
</e>
<e p="Models" t="Include">
@@ -1827,6 +1829,9 @@
<e p="201812250223002_AddCdOffsets.Designer.cs" t="Include" />
<e p="201812250223002_AddCdOffsets.cs" t="Include" />
<e p="201812250223002_AddCdOffsets.resx" t="Include" />
<e p="201812251556377_StoreMmcGetConfigurationResponse.Designer.cs" t="Include" />
<e p="201812251556377_StoreMmcGetConfigurationResponse.cs" t="Include" />
<e p="201812251556377_StoreMmcGetConfigurationResponse.resx" t="Include" />
<e p="Configuration.cs" t="Include" />
</e>
<e p="Models" t="Include">

View File

@@ -1032,6 +1032,8 @@ namespace DiscImageChef.CommonTypes.Metadata
public bool SupportsWriteInhibitDCB { get; set; }
public bool SupportsWriteProtectPAC { get; set; }
public ushort? VolumeLevels { get; set; }
public byte[] BinaryData { get; set; }
[JsonIgnore]
public short? BlocksPerReadableUnitSql
{

View File

@@ -42,6 +42,26 @@ namespace DiscImageChef.Core.Devices.Report
{
public partial class DeviceReport
{
static byte[] ClearMmcFeatures(byte[] response)
{
uint offset = 8;
while(offset + 4 < response.Length)
{
ushort code = (ushort)((response[offset + 0] << 8) + response[offset + 1]);
if(code != 0x0108) continue;
byte[] data = new byte[response[offset + 3] + 4];
if(data.Length + offset > response.Length) data = new byte[response.Length - offset];
Array.Copy(data, 4, response, offset + 4, data.Length - 4);
offset += (uint)data.Length;
}
return response;
}
public MmcFeatures ReportMmcFeatures()
{
DicConsole.WriteLine("Querying MMC GET CONFIGURATION...");
@@ -52,7 +72,7 @@ namespace DiscImageChef.Core.Devices.Report
Features.SeparatedFeatures ftr = Features.Separate(buffer);
if(ftr.Descriptors == null || ftr.Descriptors.Length <= 0) return null;
MmcFeatures report = new MmcFeatures();
MmcFeatures report = new MmcFeatures {BinaryData = ClearMmcFeatures(buffer)};
foreach(Features.FeatureDescriptor desc in ftr.Descriptors)
switch(desc.Code)
{

View File

@@ -86,6 +86,8 @@
<Compile Include="Migrations\20181224172147_FixUsbIdsAndIndexes.Designer.cs" />
<Compile Include="Migrations\20181225002740_AddCdOffsets.cs" />
<Compile Include="Migrations\20181225002740_AddCdOffsets.Designer.cs" />
<Compile Include="Migrations\20181225152947_StoreMmcGetConfigurationResponse.cs" />
<Compile Include="Migrations\20181225152947_StoreMmcGetConfigurationResponse.Designer.cs" />
<Compile Include="Migrations\DicContextModelSnapshot.cs" />
<Compile Include="Models\CdOffset.cs" />
<Compile Include="Models\Command.cs" />

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,30 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace DiscImageChef.Database.Migrations
{
// TODO: Find how to permanently create indexes
public partial class StoreMmcGetConfigurationResponse : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex("IX_UsbVendors_ModifiedWhen", "UsbVendors");
migrationBuilder.DropIndex("IX_UsbProducts_ModifiedWhen", "UsbProducts");
migrationBuilder.DropIndex("IX_UsbProducts_ProductId", "UsbProducts");
migrationBuilder.AddColumn<byte[]>("BinaryData", "MmcFeatures", nullable: true);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn("BinaryData", "MmcFeatures");
migrationBuilder.CreateIndex("IX_UsbVendors_ModifiedWhen", "UsbVendors", "ModifiedWhen");
migrationBuilder.CreateIndex("IX_UsbProducts_ModifiedWhen", "UsbProducts", "ModifiedWhen");
migrationBuilder.CreateIndex("IX_UsbProducts_ProductId", "UsbProducts", "ProductId");
}
}
}

View File

@@ -132,6 +132,8 @@ namespace DiscImageChef.Database.Migrations
b.Property<byte?>("AGIDs");
b.Property<byte[]>("BinaryData");
b.Property<byte?>("BindingNonceBlocks");
b.Property<ushort?>("BlocksPerReadableUnit");
@@ -1163,10 +1165,6 @@ namespace DiscImageChef.Database.Migrations
b.HasIndex("VendorId");
b.HasIndex("ProductId");
b.HasIndex("ModifiedWhen");
b.ToTable("UsbProducts");
});
@@ -1182,8 +1180,6 @@ namespace DiscImageChef.Database.Migrations
b.HasKey("Id");
b.HasIndex("ModifiedWhen");
b.ToTable("UsbVendors");
});

View File

@@ -229,6 +229,10 @@
<Compile Include="Migrations\201812250223002_AddCdOffsets.Designer.cs">
<DependentUpon>201812250223002_AddCdOffsets.cs</DependentUpon>
</Compile>
<Compile Include="Migrations\201812251556377_StoreMmcGetConfigurationResponse.cs" />
<Compile Include="Migrations\201812251556377_StoreMmcGetConfigurationResponse.Designer.cs">
<DependentUpon>201812251556377_StoreMmcGetConfigurationResponse.cs</DependentUpon>
</Compile>
<Compile Include="Migrations\Configuration.cs" />
<Compile Include="Models\CdOffset.cs" />
<Compile Include="Models\Command.cs" />
@@ -339,6 +343,9 @@
<EmbeddedResource Include="Migrations\201812250223002_AddCdOffsets.resx">
<DependentUpon>201812250223002_AddCdOffsets.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Migrations\201812251556377_StoreMmcGetConfigurationResponse.resx">
<DependentUpon>201812251556377_StoreMmcGetConfigurationResponse.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>

View File

@@ -0,0 +1,29 @@
// <auto-generated />
namespace DiscImageChef.Server.Migrations
{
using System.CodeDom.Compiler;
using System.Data.Entity.Migrations;
using System.Data.Entity.Migrations.Infrastructure;
using System.Resources;
[GeneratedCode("EntityFramework.Migrations", "6.2.0-61023")]
public sealed partial class StoreMmcGetConfigurationResponse : IMigrationMetadata
{
private readonly ResourceManager Resources = new ResourceManager(typeof(StoreMmcGetConfigurationResponse));
string IMigrationMetadata.Id
{
get { return "201812251556377_StoreMmcGetConfigurationResponse"; }
}
string IMigrationMetadata.Source
{
get { return null; }
}
string IMigrationMetadata.Target
{
get { return Resources.GetString("Target"); }
}
}
}

View File

@@ -0,0 +1,17 @@
using System.Data.Entity.Migrations;
namespace DiscImageChef.Server.Migrations
{
public partial class StoreMmcGetConfigurationResponse : DbMigration
{
public override void Up()
{
AddColumn("dbo.MmcFeatures", "BinaryData", c => c.Binary());
}
public override void Down()
{
DropColumn("dbo.MmcFeatures", "BinaryData");
}
}
}

File diff suppressed because one or more lines are too long