Skip to content

Commit fea206b

Browse files
committed
Merge branch 'genielabs-master'
2 parents b5070db + 3e4c7f6 commit fea206b

File tree

6 files changed

+62
-31
lines changed

6 files changed

+62
-31
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,5 @@ TestResults
1818
# OS generated files
1919
[Tt]humbs.db
2020
[Dd]esktop.ini
21+
22+
RaspberrySharp.System.userprefs

Raspberry.System/Board.cs

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using System.Collections.Generic;
55
using System.Globalization;
66
using System.IO;
7-
using System.Linq;
87

98
#endregion
109

@@ -19,9 +18,9 @@ public class Board
1918
#region Fields
2019

2120
private static readonly Lazy<Board> board = new Lazy<Board>(LoadBoard);
22-
private readonly Dictionary<string, string> settings;
2321

24-
private const string raspberryPiProcessor = "BCM2708";
22+
private readonly Dictionary<string, string> settings;
23+
private readonly HashSet<string> raspberryPiProcessors = new HashSet<string>(new[]{ "BCM2708", "BCM2709" }, StringComparer.InvariantCultureIgnoreCase);
2524

2625
#endregion
2726

@@ -52,7 +51,7 @@ public static Board Current
5251
/// </value>
5352
public bool IsRaspberryPi
5453
{
55-
get { return string.Equals(Processor, raspberryPiProcessor, StringComparison.InvariantCultureIgnoreCase); }
54+
get { return raspberryPiProcessors.Contains(Processor); }
5655
}
5756

5857
/// <summary>
@@ -76,7 +75,9 @@ public int Firmware
7675
{
7776
string revision;
7877
int firmware;
79-
if (settings.TryGetValue("Revision", out revision) && !string.IsNullOrEmpty(revision) && int.TryParse(revision, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out firmware))
78+
if (settings.TryGetValue("Revision", out revision)
79+
&& !string.IsNullOrEmpty(revision)
80+
&& int.TryParse(revision, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out firmware))
8081
return firmware;
8182

8283
return 0;
@@ -90,7 +91,8 @@ public string SerialNumber
9091
{
9192
get {
9293
string serial;
93-
if (settings.TryGetValue("Serial", out serial) && !string.IsNullOrEmpty(serial))
94+
if (settings.TryGetValue("Serial", out serial)
95+
&& !string.IsNullOrEmpty(serial))
9496
return serial;
9597

9698
return null;
@@ -139,6 +141,10 @@ public char Model
139141
case 0x10:
140142
return 'B';
141143

144+
case 0x1040:
145+
case 0x1041:
146+
return '2';
147+
142148
default:
143149
return (char)0;
144150
}
@@ -175,6 +181,10 @@ public int Revision
175181

176182
case 0x10:
177183
return 3; // Model B+, rev3
184+
185+
case 0x1040:
186+
case 0x1041:
187+
return 4;
178188

179189
default:
180190
return 0; // Unknown
@@ -191,16 +201,27 @@ private static Board LoadBoard()
191201
try
192202
{
193203
const string filePath = "/proc/cpuinfo";
194-
var settings = File.ReadAllLines(filePath)
195-
.Where(l => !string.IsNullOrEmpty(l))
196-
.Select(l =>
204+
205+
var cpuInfo = File.ReadAllLines(filePath);
206+
var settings = new Dictionary<string, string>();
207+
var suffix = string.Empty;
208+
209+
foreach(var l in cpuInfo)
210+
{
211+
var separator = l.IndexOf(':');
212+
213+
if (!string.IsNullOrWhiteSpace(l) && separator > 0)
197214
{
198-
var separator = l.IndexOf(':');
199-
return separator >= 0
200-
? new KeyValuePair<string, string>(l.Substring(0, separator).Trim(), l.Substring(separator + 1).Trim())
201-
: new KeyValuePair<string, string>(l, null);
202-
})
203-
.ToDictionary(p => p.Key, p => p.Value);
215+
var key = l.Substring(0, separator).Trim();
216+
var val = l.Substring(separator + 1).Trim();
217+
if (string.Equals(key, "processor", StringComparison.InvariantCultureIgnoreCase))
218+
suffix = "." + val;
219+
220+
settings.Add(key + suffix, val);
221+
}
222+
else
223+
suffix = "";
224+
}
204225

205226
return new Board(settings);
206227
}

Raspberry.System/Timers/ITimer.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
namespace Raspberry.Timers
88
{
9+
/// <summary>
10+
/// Provides an interface for a timer.
11+
/// </summary>
912
public interface ITimer
1013
{
1114
#region Properties

Raspberry.System/Timers/StandardTimer.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
namespace Raspberry.Timers
88
{
9+
/// <summary>
10+
/// Represents a timer.
11+
/// </summary>
912
public class StandardTimer : ITimer
1013
{
1114
#region Fields

RaspberrySharp.System.sln

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 2012
3+
# Visual Studio 2013
4+
VisualStudioVersion = 12.0.31101.0
5+
MinimumVisualStudioVersion = 10.0.40219.1
46
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{DE3AA526-5A9D-465A-B9B0-7A07AE6824B5}"
57
ProjectSection(SolutionItems) = preProject
68
Icon.png = Icon.png
@@ -41,16 +43,16 @@ Global
4143
{2C0C9AAF-4EDD-4C79-961B-E7BC4FC4EB0C}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
4244
{2C0C9AAF-4EDD-4C79-961B-E7BC4FC4EB0C}.Release|Mixed Platforms.Build.0 = Release|Any CPU
4345
{2C0C9AAF-4EDD-4C79-961B-E7BC4FC4EB0C}.Release|x86.ActiveCfg = Release|Any CPU
44-
{51780F8A-E5F5-4DC8-84B4-B282800A3396}.Debug|Any CPU.ActiveCfg = Debug|x86
45-
{51780F8A-E5F5-4DC8-84B4-B282800A3396}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
46-
{51780F8A-E5F5-4DC8-84B4-B282800A3396}.Debug|Mixed Platforms.Build.0 = Debug|x86
47-
{51780F8A-E5F5-4DC8-84B4-B282800A3396}.Debug|x86.ActiveCfg = Debug|x86
48-
{51780F8A-E5F5-4DC8-84B4-B282800A3396}.Debug|x86.Build.0 = Debug|x86
49-
{51780F8A-E5F5-4DC8-84B4-B282800A3396}.Release|Any CPU.ActiveCfg = Release|x86
50-
{51780F8A-E5F5-4DC8-84B4-B282800A3396}.Release|Mixed Platforms.ActiveCfg = Release|x86
51-
{51780F8A-E5F5-4DC8-84B4-B282800A3396}.Release|Mixed Platforms.Build.0 = Release|x86
52-
{51780F8A-E5F5-4DC8-84B4-B282800A3396}.Release|x86.ActiveCfg = Release|x86
53-
{51780F8A-E5F5-4DC8-84B4-B282800A3396}.Release|x86.Build.0 = Release|x86
46+
{51780F8A-E5F5-4DC8-84B4-B282800A3396}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
47+
{51780F8A-E5F5-4DC8-84B4-B282800A3396}.Debug|Any CPU.Build.0 = Debug|Any CPU
48+
{51780F8A-E5F5-4DC8-84B4-B282800A3396}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
49+
{51780F8A-E5F5-4DC8-84B4-B282800A3396}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
50+
{51780F8A-E5F5-4DC8-84B4-B282800A3396}.Debug|x86.ActiveCfg = Debug|Any CPU
51+
{51780F8A-E5F5-4DC8-84B4-B282800A3396}.Release|Any CPU.ActiveCfg = Release|Any CPU
52+
{51780F8A-E5F5-4DC8-84B4-B282800A3396}.Release|Any CPU.Build.0 = Release|Any CPU
53+
{51780F8A-E5F5-4DC8-84B4-B282800A3396}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
54+
{51780F8A-E5F5-4DC8-84B4-B282800A3396}.Release|Mixed Platforms.Build.0 = Release|Any CPU
55+
{51780F8A-E5F5-4DC8-84B4-B282800A3396}.Release|x86.ActiveCfg = Release|Any CPU
5456
EndGlobalSection
5557
GlobalSection(SolutionProperties) = preSolution
5658
HideSolutionNode = FALSE

Test.Board/Test.Board.csproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<PropertyGroup>
44
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5-
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
5+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
66
<ProductVersion>8.0.30703</ProductVersion>
77
<SchemaVersion>2.0</SchemaVersion>
88
<ProjectGuid>{51780F8A-E5F5-4DC8-84B4-B282800A3396}</ProjectGuid>
@@ -14,8 +14,8 @@
1414
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
1515
<FileAlignment>512</FileAlignment>
1616
</PropertyGroup>
17-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
18-
<PlatformTarget>x86</PlatformTarget>
17+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
18+
<PlatformTarget>AnyCPU</PlatformTarget>
1919
<DebugSymbols>true</DebugSymbols>
2020
<DebugType>full</DebugType>
2121
<Optimize>false</Optimize>
@@ -24,8 +24,8 @@
2424
<ErrorReport>prompt</ErrorReport>
2525
<WarningLevel>4</WarningLevel>
2626
</PropertyGroup>
27-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
28-
<PlatformTarget>x86</PlatformTarget>
27+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
28+
<PlatformTarget>AnyCPU</PlatformTarget>
2929
<DebugType>pdbonly</DebugType>
3030
<Optimize>true</Optimize>
3131
<OutputPath>bin\Release\</OutputPath>

0 commit comments

Comments
 (0)