- added tests for Samsung .scm files

- fixed some rare file-format detection issues for Samsung (e.g. J-series with .scm format, HExxC, LTxxC)
This commit is contained in:
hbeham
2015-11-27 23:47:09 +01:00
parent b571e8897e
commit ff96a36cc7
11 changed files with 301 additions and 30 deletions

View File

@@ -32,6 +32,24 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />

View File

@@ -16,12 +16,13 @@ namespace ChanSort.Loader.Samsung
this.InitCommonData(slot, signalSource, mapping);
var floatFreq = mapping.GetFloat(_Frequency);
if (!float.IsNaN(floatFreq))
if (!float.IsNaN(floatFreq) && floatFreq > 100 && floatFreq < 2000) // some files seem to have a value way off scale
this.FreqInMhz = (decimal)floatFreq; // C,D,E series have the value in the data record
if (this.FreqInMhz == 0) // for B series take it from the Tuning table
this.FreqInMhz = freq;
if (this.FreqInMhz == 0) // fallback since Freq is part of the UID and requires a unique value
this.FreqInMhz = slot;
this.ChannelOrTransponder = "";
}

View File

@@ -11,6 +11,7 @@
Favorites = 4
[Series:C]
; _1001 format. favorites A-D are stored in a bitmask
SatDataBase.dat = 145
TransponderDataBase.dat = 45
PTC = 12
@@ -21,6 +22,7 @@
Favorites = 4
[Series:D]
; _1101 format. favorite A-E have individual number fields, but only allow 0 = not-a-fav, 1=is-a-fav
SatDataBase.dat = 145
TransponderDataBase.dat = 45
PTC = 12
@@ -33,6 +35,8 @@
SortedFavorites = 0
[Series:E]
; _1201 format with favorites A-E and individual numbering (-1 = not-a-fav, 0...x = fav program nr)
; used by E models
SatDataBase.dat = 145
TransponderDataBase.dat = 45
PTC = 12
@@ -46,6 +50,8 @@
SortedFavorites = 1
[Series:F]
; _1201 format with favorites A-E, but forced to use same numbers as main program number (-1 = not-a-fav, 0...x = main program nr)
; used by F, H, low-end J and HExxC models
SatDataBase.dat = 145
TransponderDataBase.dat = 45
PTC = 12
@@ -58,18 +64,6 @@
Favorites = 5
SortedFavorites = 2
[Series:H]
SatDataBase.dat = 145
TransponderDataBase.dat = 45
PTC = 12
map-AirA = 64
map-AirD = 320
map-CableD = 320
map-SateD = 168
map-AstraHDPlusD = 212
map-CyfraPlusD = 172
Favorites = 5
SortedFavorites = 2
[Analog:28]
; map-AirA and map-CableA for B series

View File

@@ -7,13 +7,13 @@ namespace ChanSort.Loader.Samsung
/// <summary>
/// D model uses values 0 and 1
/// </summary>
Flag = 0,
Boolean = 0,
/// <summary>
/// E model uses -1 for not-a-fav and 1-x for a fav program number
/// E model uses -1 for not-a-fav and 1..x for a fav program number
/// </summary>
IndividuallySorted = 1,
/// <summary>
/// some F models and H series uses -1 for not-a-fav, but expects 1-x to match the main program number
/// some F models and H series uses -1 for not-a-fav, but expects 1..x to match the main program number
/// </summary>
MainProgramnrIndex = 2
}

View File

@@ -2,7 +2,9 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
[assembly:InternalsVisibleTo("Test.Loader")]
[assembly: InternalsVisibleTo("Test.Loader")]
[assembly: InternalsVisibleTo("Test.Loader.Samsung")]
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information

View File

@@ -80,9 +80,9 @@ namespace ChanSort.Loader.Samsung
foreach (int off in offsets)
{
int favValue = BitConverter.ToInt32(this.rawData, baseOffset + off);
if (sortedFavorites == FavoritesIndexMode.Flag && favValue != 0)
if (sortedFavorites == FavoritesIndexMode.Boolean && favValue != 0)
fav |= mask;
else if (sortedFavorites != FavoritesIndexMode.Flag && favValue != -1)
else if (sortedFavorites != FavoritesIndexMode.Boolean && favValue != -1)
fav |= mask;
if (sortedFavorites == FavoritesIndexMode.IndividuallySorted)
this.FavIndex[favIndex] = favValue;
@@ -173,7 +173,7 @@ namespace ChanSort.Loader.Samsung
foreach (int off in offsets)
{
int favValue;
if (this.sortedFavorites == FavoritesIndexMode.Flag) // D series
if (this.sortedFavorites == FavoritesIndexMode.Boolean) // D series
favValue = (fav & mask) != 0 ? 1 : 0; // D series
else if (this.sortedFavorites == FavoritesIndexMode.IndividuallySorted) // E series (and some F models with early firmware)
favValue = (fav & mask) != 0 ? this.FavIndex[favIndex] : -1;

View File

@@ -9,7 +9,7 @@ using ICSharpCode.SharpZipLib.Zip;
namespace ChanSort.Loader.Samsung
{
class ScmSerializer : SerializerBase
internal class ScmSerializer : SerializerBase
{
private readonly Dictionary<string, ModelConstants> modelConstants = new Dictionary<string, ModelConstants>();
private readonly MappingPool<DataMapping> analogMappings = new MappingPool<DataMapping>("Analog");
@@ -140,7 +140,7 @@ namespace ChanSort.Loader.Samsung
#endregion
#region DetectModelConstants()
private void DetectModelConstants(ZipFile zip)
internal void DetectModelConstants(ZipFile zip)
{
if (DetectModelFromFileName()) return;
if (DetectModelFromCloneInfoFile(zip)) return;
@@ -165,9 +165,9 @@ namespace ChanSort.Loader.Samsung
case "1101": series = "D"; break;
case "1201":
var letter = match.Groups[2].Value;
series = match.Groups[1].Value.StartsWith("LT") ? "F" : // LTxxCxxx is actually an F-series model
StringComparer.OrdinalIgnoreCase.Compare(letter, "E") < 0 ? "E" : // at least E sereis
letter; // E, F, H
// F, H and low-end J series use same file format
series = letter == "E" ? "E" : "F";
break;
default:
return false;
@@ -192,8 +192,12 @@ namespace ChanSort.Loader.Samsung
if (cloneInfo.Length >= 9)
{
char series = (char) cloneInfo[8];
if (series == 'B') // 2013 B-series uses E/F-series format
if (series == 'B') // LTxxBxxx uses E/F format. the old B-series has no CloneInfo file, so we can tell the difference
series = 'F';
else if (series == 'C') // there are models with a C that are actually F: LTxxCxxx, HExxCxxx, ... so we can't decide here
return false;
else if (series >= 'F') // F, H, low-end J
series = 'F';
if (this.modelConstants.TryGetValue("Series:" + series, out this.c))
return true;
}
@@ -212,7 +216,7 @@ namespace ChanSort.Loader.Samsung
DetectModelFromAstraHdPlusD(zip)
};
// note: E, F and B(2013) series use an identical format, so we only care about E here
// E, F, B(2013), H, low-end J series use an identical format, so we only care about one here
string validCandidates = "BCDE";
foreach (var candidateList in candidates)
{
@@ -230,7 +234,10 @@ namespace ChanSort.Loader.Samsung
if (validCandidates.Length == 0)
return false;
this.modelConstants.TryGetValue("Series:" + validCandidates[0], out this.c);
var series = validCandidates[0];
if (series == 'E') // E allows favorites to be individually sorted, while F-J require them to match the main program nr
series = 'F'; // since we can't tell the difference from the format, we use the safe F/H/J logic, which also works for E
this.modelConstants.TryGetValue("Series:" + series, out this.c);
return true;
}

View File

@@ -43,6 +43,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ChanSort.Loader.SamsungJ",
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ChanSort.Loader.Hisense", "ChanSort.Loader.Hisense\ChanSort.Loader.Hisense.csproj", "{D093E7EE-D3AD-4E7B-AF82-C6918CA017FB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test.Loader.Samsung", "Test.Loader.Samsung\Test.Loader.Samsung.csproj", "{1ED68A9B-6698-4609-B9E6-8E08B6055F2E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -181,14 +183,26 @@ Global
{D093E7EE-D3AD-4E7B-AF82-C6918CA017FB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D093E7EE-D3AD-4E7B-AF82-C6918CA017FB}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{D093E7EE-D3AD-4E7B-AF82-C6918CA017FB}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{D093E7EE-D3AD-4E7B-AF82-C6918CA017FB}.Debug|x86.ActiveCfg = Debug|Any CPU
{D093E7EE-D3AD-4E7B-AF82-C6918CA017FB}.Debug|x86.Build.0 = Debug|Any CPU
{D093E7EE-D3AD-4E7B-AF82-C6918CA017FB}.Debug|x86.ActiveCfg = Debug|x86
{D093E7EE-D3AD-4E7B-AF82-C6918CA017FB}.Debug|x86.Build.0 = Debug|x86
{D093E7EE-D3AD-4E7B-AF82-C6918CA017FB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D093E7EE-D3AD-4E7B-AF82-C6918CA017FB}.Release|Any CPU.Build.0 = Release|Any CPU
{D093E7EE-D3AD-4E7B-AF82-C6918CA017FB}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{D093E7EE-D3AD-4E7B-AF82-C6918CA017FB}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{D093E7EE-D3AD-4E7B-AF82-C6918CA017FB}.Release|x86.ActiveCfg = Release|Any CPU
{D093E7EE-D3AD-4E7B-AF82-C6918CA017FB}.Release|x86.Build.0 = Release|Any CPU
{1ED68A9B-6698-4609-B9E6-8E08B6055F2E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1ED68A9B-6698-4609-B9E6-8E08B6055F2E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1ED68A9B-6698-4609-B9E6-8E08B6055F2E}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{1ED68A9B-6698-4609-B9E6-8E08B6055F2E}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{1ED68A9B-6698-4609-B9E6-8E08B6055F2E}.Debug|x86.ActiveCfg = Debug|x86
{1ED68A9B-6698-4609-B9E6-8E08B6055F2E}.Debug|x86.Build.0 = Debug|x86
{1ED68A9B-6698-4609-B9E6-8E08B6055F2E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1ED68A9B-6698-4609-B9E6-8E08B6055F2E}.Release|Any CPU.Build.0 = Release|Any CPU
{1ED68A9B-6698-4609-B9E6-8E08B6055F2E}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{1ED68A9B-6698-4609-B9E6-8E08B6055F2E}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{1ED68A9B-6698-4609-B9E6-8E08B6055F2E}.Release|x86.ActiveCfg = Release|Any CPU
{1ED68A9B-6698-4609-B9E6-8E08B6055F2E}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@@ -0,0 +1,85 @@
using System;
using System.IO;
using System.Text;
using ChanSort.Loader.Samsung;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Test.Loader.Samsung
{
[TestClass]
public class FileFormatDetectionTest
{
private readonly StringBuilder errors = new StringBuilder();
private const string RootPath = @"d:\sources\ChanSort\TestFiles_Samsung\";
#region LoadAllFilesAndLogDetecedFileFormat()
[TestMethod]
public void LoadAllFilesAndLogDetecedFileFormat()
{
RecurseInto(RootPath);
Assert.AreEqual("", errors.ToString());
}
private void RecurseInto(string dir)
{
foreach (var path in Directory.GetFiles(dir, "*.scm"))
{
if (path.Contains("_null"))
continue;
try
{
var s = new ScmSerializer(path);
s.Load();
var series = s.Series;
System.Diagnostics.Debug.WriteLine($"{path.Substring(RootPath.Length)}: {series}");
}
catch (Exception ex)
{
errors.AppendLine($"{path.Substring(RootPath.Length)} : {ex.Message}");
}
}
foreach (var path in Directory.GetDirectories(dir))
RecurseInto(path);
}
#endregion
[TestMethod]
public void LoadFileWithExcessiveHighFrequency_1()
{
// this seems to be a corrupt file caused by a buffer-overflow from analog channel names into the frequency data bytes
var s = new ScmSerializer(RootPath + @"ThomasSaur_DH\channel_list_UE55H6470_1201-Suchlauf-2015-04-26.scm");
s.Load();
}
[TestMethod]
public void LoadFileWithExcessiveHighFrequency_2()
{
// this seems to be a corrupt file caused by a buffer-overflow from analog channel names into the frequency data bytes
var s = new ScmSerializer(RootPath + @"ThomasSaur_DH\channel_list_UE55H6470_1201.scm");
s.Load();
}
[TestMethod]
public void LoadRenamedFile_HE40Cxxx_1201()
{
// This file uses the 1201 format (E,F,H,J), but has a "C" in its model name
var s = new ScmSerializer(RootPath + @"__C=F\Kinig\Reier Monika.scm");
s.Load();
Assert.AreEqual("F", s.Series);
}
[TestMethod]
public void LoadRenamedFile_LT24B_1201()
{
// This file uses the 1201 format (E,F,H,J), but has a "B" in its model name
var s = new ScmSerializer(RootPath + @"__B=F\DieterHerzberg_B\renamed.scm");
s.Load();
Assert.AreEqual("F", s.Series);
}
}
}

View File

@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Test.Loader.Samsung")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Test.Loader.Samsung")]
[assembly: AssemblyCopyright("Copyright © 2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("1ed68a9b-6698-4609-b9e6-8e08b6055f2e")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,114 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{1ED68A9B-6698-4609-B9E6-8E08B6055F2E}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Test.Loader.Samsung</RootNamespace>
<AssemblyName>Test.Loader.Samsung</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
<IsCodedUITest>False</IsCodedUITest>
<TestProjectType>UnitTest</TestProjectType>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="ICSharpCode.SharpZipLib">
<HintPath>..\DLL\ICSharpCode.SharpZipLib.dll</HintPath>
</Reference>
<Reference Include="System" />
</ItemGroup>
<Choose>
<When Condition="('$(VisualStudioVersion)' == '10.0' or '$(VisualStudioVersion)' == '') and '$(TargetFrameworkVersion)' == 'v3.5'">
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
</ItemGroup>
</When>
<Otherwise>
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework" />
</ItemGroup>
</Otherwise>
</Choose>
<ItemGroup>
<Compile Include="FileFormatDetectionTest.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ChanSort.Api\ChanSort.Api.csproj">
<Project>{dccffa08-472b-4d17-bb90-8f513fc01392}</Project>
<Name>ChanSort.Api</Name>
</ProjectReference>
<ProjectReference Include="..\ChanSort.Loader.Samsung\ChanSort.Loader.Samsung.csproj">
<Project>{a1c9a98d-368a-44e8-9b7f-7eaca46c9ec5}</Project>
<Name>ChanSort.Loader.Samsung</Name>
</ProjectReference>
</ItemGroup>
<Choose>
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.CodedUITestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Extension, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestTools.UITesting, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
</ItemGroup>
</When>
</Choose>
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>