Skip to content

Commit b5070db

Browse files
committed
Added support for Model B+
Also fixed potential issues with overclocked boards
1 parent e29c9b8 commit b5070db

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

Raspberry.System/Board.cs

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,21 @@ public string SerialNumber
9797
}
9898
}
9999

100+
/// <summary>
101+
/// Gets a value indicating whether Raspberry Pi board is overclocked.
102+
/// </summary>
103+
/// <value>
104+
/// <c>true</c> if Raspberry Pi is overclocked; otherwise, <c>false</c>.
105+
/// </value>
106+
public bool IsOverclocked
107+
{
108+
get
109+
{
110+
var firmware = Firmware;
111+
return (firmware & 0xFFFF0000) != 0;
112+
}
113+
}
114+
100115
/// <summary>
101116
/// Gets the model.
102117
/// </summary>
@@ -106,7 +121,7 @@ public char Model
106121
get
107122
{
108123
var firmware = Firmware;
109-
switch(firmware)
124+
switch(firmware & 0xFFFF)
110125
{
111126
case 0x7:
112127
case 0x8:
@@ -121,6 +136,7 @@ public char Model
121136
case 0xd:
122137
case 0xe:
123138
case 0xf:
139+
case 0x10:
124140
return 'B';
125141

126142
default:
@@ -138,7 +154,7 @@ public int Revision
138154
get
139155
{
140156
var firmware = Firmware;
141-
switch (firmware)
157+
switch (firmware & 0xFFFF)
142158
{
143159
case 0x7:
144160
case 0x8:
@@ -157,6 +173,9 @@ public int Revision
157173
case 0xf:
158174
return 2; // Model B, rev2
159175

176+
case 0x10:
177+
return 3; // Model B+, rev3
178+
160179
default:
161180
return 0; // Unknown
162181
}
@@ -177,10 +196,9 @@ private static Board LoadBoard()
177196
.Select(l =>
178197
{
179198
var separator = l.IndexOf(':');
180-
if (separator < 0)
181-
return new KeyValuePair<string, string>(l, null);
182-
else
183-
return new KeyValuePair<string, string>(l.Substring(0, separator).Trim(), l.Substring(separator + 1).Trim());
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);
184202
})
185203
.ToDictionary(p => p.Key, p => p.Value);
186204

0 commit comments

Comments
 (0)