Skip to content

Commit

Permalink
Improvements in device information (#110)
Browse files Browse the repository at this point in the history
  • Loading branch information
josesimoes authored Jan 4, 2018
1 parent d61dbf4 commit 25f4fe7
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 32 deletions.
10 changes: 6 additions & 4 deletions source/USB Test App WPF/Serial Test App WPF.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@
<Reference Include="Microsoft.Practices.ServiceLocation, Version=1.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\CommonServiceLocator.1.3\lib\portable-net4+sl5+netcore45+wpa81+wp8\Microsoft.Practices.ServiceLocation.dll</HintPath>
</Reference>
<Reference Include="nanoFramework.Tools.Debugger, Version=0.5.0.0, Culture=neutral, PublicKeyToken=e520bb6b53f04733, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\nanoFramework.Tools.Debugger.Net.0.5.0-alpha108\lib\net46\nanoFramework.Tools.Debugger.dll</HintPath>
</Reference>
<Reference Include="PropertyChanged, Version=2.2.4.0, Culture=neutral, PublicKeyToken=ee3ee20bcf148ddd, processorArchitecture=MSIL">
<HintPath>..\packages\PropertyChanged.Fody.2.2.4.0\lib\net452\PropertyChanged.dll</HintPath>
</Reference>
Expand Down Expand Up @@ -141,6 +137,12 @@
<ItemGroup>
<Analyzer Include="..\packages\UwpDesktop.10.0.14393.3\analyzers\dotnet\UwpDesktopAnalyzer.dll" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\nanoFramework.Tools.DebugLibrary.Net\nanoFramework.Tools.DebugLibrary.Net.csproj">
<Project>{101D57AD-D22F-4905-A992-DE15E723F164}</Project>
<Name>nanoFramework.Tools.DebugLibrary.Net</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\Fody.2.3.11\build\net452\Fody.targets" Condition="Exists('..\packages\Fody.2.3.11\build\net452\Fody.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nanoFramework.Tools.DebugLibrary.Net ../nanoFramework.Tools.DebugLibrary.Net/nanoFramework.Tools.DebugLibrary.Net.csproj ../packages/nanoFramework.Tools.Debugger.Net.0.5.0-alpha108/lib/net46/nanoFramework.Tools.Debugger.dll
21 changes: 16 additions & 5 deletions source/nanoFramework.Tools.DebugLibrary.Shared/CLRCapabilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,28 @@ public enum Capability : ulong
public struct SoftwareVersionProperties
{
public readonly string BuildDate;
public readonly string CompilerInfo;
public readonly Version CompilerVersion;

public SoftwareVersionProperties(byte[] buildDate, uint compVersion)
public SoftwareVersionProperties(byte[] buildDate, byte[] compilerInfo, uint compVersion)
{
// parse build date from byte[]
char[] chars = new char[buildDate.Length];
int i = 0;
for (i = 0; i < chars.Length && buildDate[i] != 0; i++)
{
chars[i] = (char)buildDate[i];
}
BuildDate = new string(chars, 0, i);
BuildDate = (new string(chars, 0, i)).TrimEnd('\0');

// parse compiler info from byte[]
chars = new char[compilerInfo.Length];
i = 0;
for (i = 0; i < chars.Length && compilerInfo[i] != 0; i++)
{
chars[i] = (char)compilerInfo[i];
}
CompilerInfo = new string(chars, 0, i);

// this is the compiler version in coded format: MAJOR x 10000 + MINOR x 100 + PATCH
// example: v6.3.1 shows as 6 x 10000 + 3 x 100 + 1 = 60301
Expand Down Expand Up @@ -78,8 +89,8 @@ public HalSystemInfoProperties(
halVersion = hv; halVendorInfo = hvi;
oemCode = oc; modelCode = mc; skuCode = sc;

moduleSerialNumber = BytesToHexString(mSerNumBytes);
systemSerialNumber = BytesToHexString(sSerNumBytes);
moduleSerialNumber = BytesToHexString(mSerNumBytes).TrimEnd('\0');
systemSerialNumber = BytesToHexString(sSerNumBytes).TrimEnd('\0');
}

private static string BytesToHexString(byte[] bytes)
Expand Down Expand Up @@ -117,7 +128,7 @@ public struct TargetInfoProperties
public TargetInfoProperties(Version v, string i)
{
targetVersion = v;
targetVendorInfo = i;
targetVendorInfo = i.TrimEnd('\0');
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ public IAssemblyInfo[] Assemblies

public string ImageBuildDate => Dbg.Capabilities.SoftwareVersion.BuildDate;

public string ImageCompilerInfo => Dbg.Capabilities.SoftwareVersion.CompilerInfo;

public Version ImageCompilerVersion => Dbg.Capabilities.SoftwareVersion.CompilerVersion;

public override string ToString()
Expand All @@ -203,13 +205,13 @@ public override string ToString()
{
StringBuilder output = new StringBuilder();

output.AppendLine(String.Format("HAL build info: {0}, {1}", HalBuildVersion?.ToString(), HalBuildInfo?.TrimEnd('\0')));
output.AppendLine(String.Format($"Image build @ {ImageBuildDate.TrimEnd('\0')} GNU ARM GCC v{ ImageCompilerVersion.ToString() }"));
output.AppendLine(String.Format("HAL build info: {0}, {1}", HalBuildVersion?.ToString(), HalBuildInfo));
output.AppendLine(String.Format($"Image build @ { ImageBuildDate } { ImageCompilerInfo } v{ ImageCompilerVersion.ToString() }"));
output.AppendLine(String.Format("OEM Product codes (vendor, model, SKU): {0}, {1}, {2}", OEM.ToString(), Model.ToString(), SKU.ToString()));
output.AppendLine("Serial Numbers (module, system):");
output.AppendLine(" " + ModuleSerialNumber?.TrimEnd('\0'));
output.AppendLine(" " + SystemSerialNumber?.TrimEnd('\0'));
output.AppendLine(String.Format("Solution Build Info: {0}, {1}", SolutionBuildVersion?.ToString(), SolutionBuildInfo?.TrimEnd('\0')));
output.AppendLine(" " + ModuleSerialNumber);
output.AppendLine(" " + SystemSerialNumber);
output.AppendLine(String.Format("Solution Build Info: {0}, {1}", SolutionBuildVersion?.ToString(), SolutionBuildInfo));

output.AppendLine("AppDomains:");
foreach (IAppDomainInfo adi in AppDomains)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -706,10 +706,12 @@ public class LCD
public uint m_height;
public uint m_bpp;
}

public class SoftwareVersion
{
public byte[] m_buildDate = new byte[22];
public uint m_compilerVersion;
public byte[] BuildDate = new byte[22];
public byte[] CompilerInfo = new byte[16];
public uint CompilerVersion;
}

public class OEM_MODEL_SKU
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3134,7 +3134,7 @@ private CLRCapabilities.SoftwareVersionProperties DiscoverSoftwareVersionPropert
{
new Converter().Deserialize(ver, cmdReply.m_data);

verCaps = new CLRCapabilities.SoftwareVersionProperties(ver.m_buildDate, ver.m_compilerVersion);
verCaps = new CLRCapabilities.SoftwareVersionProperties(ver.BuildDate, ver.CompilerInfo, ver.CompilerVersion);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,26 @@ namespace nanoFramework.Tools.Debugger.WireProtocol
{
public class ReleaseInfo : IConverter
{
public VersionStruct m_version;
public byte[] m_info;
// these constants reflect the size of the struct NFReleaseInfo in native code @ nanoHAL_ReleaseInfo.h
private const int c_sizeOfVersion = 8;
private const int c_sizeOfInfo = 128;

private VersionStruct _version;
private byte[] _info;

public ReleaseInfo()
{
m_info = new byte[64 - 8];
_version = new VersionStruct();
_info = new byte[c_sizeOfInfo - c_sizeOfVersion];
}

public void PrepareForDeserialize(int size, byte[] data, Converter converter)
{
m_info = new byte[64 - 8];
_info = new byte[c_sizeOfInfo - c_sizeOfVersion];
}

public Version Version
{
get { return m_version.Version; }
}
public Version Version => _version.Version;

public string Info
{
get
{
return Encoding.UTF8.GetString(m_info, 0, m_info.Length);
}
}
public string Info => Encoding.UTF8.GetString(_info, 0, _info.Length).TrimEnd('\0');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ For .NET look for the respective Nuget package.</PackageReleaseNotes>
<PlatformTarget>x86</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<PlatformTarget>x86</PlatformTarget>
Expand All @@ -73,6 +74,7 @@ For .NET look for the respective Nuget package.</PackageReleaseNotes>
<PlatformTarget>x86</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM'">
<PlatformTarget>ARM</PlatformTarget>
Expand Down

0 comments on commit 25f4fe7

Please sign in to comment.