Skip to content

Commit fb2dc2a

Browse files
committed
fixed RPi2 detection
1 parent 2b1eba4 commit fb2dc2a

File tree

1 file changed

+27
-12
lines changed

1 file changed

+27
-12
lines changed

Raspberry.System/Board.cs

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,8 @@ public char Model
139139
case 0x10:
140140
return 'B';
141141

142-
case 0x1a01040:
142+
case 0x1040:
143+
case 0x1041:
143144
return '2';
144145

145146
default:
@@ -179,7 +180,8 @@ public int Revision
179180
case 0x10:
180181
return 3; // Model B+, rev3
181182

182-
case 0x1a01040:
183+
case 0x1040:
184+
case 0x1041:
183185
return 4;
184186

185187
default:
@@ -197,17 +199,30 @@ private static Board LoadBoard()
197199
try
198200
{
199201
const string filePath = "/proc/cpuinfo";
200-
var settings = File.ReadAllLines(filePath)
201-
.Where(l => !string.IsNullOrEmpty(l))
202-
.Select(l =>
202+
string[] cpuInfo = File.ReadAllLines(filePath);
203+
Dictionary<string, string> settings = new Dictionary<string, string>();
204+
string suffix = "";
205+
foreach(var l in cpuInfo)
206+
{
207+
var separator = l.IndexOf(':');
208+
string key = l;
209+
string val = null;
210+
if (!string.IsNullOrWhiteSpace(l) && separator > 0)
203211
{
204-
var separator = l.IndexOf(':');
205-
return separator >= 0
206-
? new KeyValuePair<string, string>(l.Substring(0, separator).Trim(), l.Substring(separator + 1).Trim())
207-
: new KeyValuePair<string, string>(l, null);
208-
})
209-
.ToDictionary(p => p.Key, p => p.Value);
210-
212+
key = l.Substring(0, separator).Trim();
213+
val = l.Substring(separator + 1).Trim();
214+
if (String.Compare(key, "processor", true) == 0)
215+
{
216+
suffix = "." + val;
217+
}
218+
Console.WriteLine(key + suffix + " = " + val);
219+
settings.Add(key + suffix, val);
220+
}
221+
else
222+
{
223+
suffix = "";
224+
}
225+
}
211226
return new Board(settings);
212227
}
213228
catch

0 commit comments

Comments
 (0)