2010-01-29 20:05:32 +00:00
|
|
|
|
/*
|
|
|
|
|
|
2012-05-27 14:23:31 +00:00
|
|
|
|
This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
|
License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
|
file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
2010-01-29 20:05:32 +00:00
|
|
|
|
|
2012-05-27 14:23:31 +00:00
|
|
|
|
Copyright (C) 2009-2011 Michael Möller <mmoeller@openhardwaremonitor.org>
|
|
|
|
|
|
2010-01-29 20:05:32 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
2010-08-08 13:57:26 +00:00
|
|
|
|
namespace OpenHardwareMonitor.Hardware {
|
2010-12-08 19:23:13 +00:00
|
|
|
|
internal static class HexStringArray {
|
2010-01-29 20:05:32 +00:00
|
|
|
|
|
2010-12-08 19:23:13 +00:00
|
|
|
|
public static byte Read(string s, ushort address) {
|
|
|
|
|
string[] lines = s.Split(new[] { '\r', '\n' },
|
|
|
|
|
StringSplitOptions.RemoveEmptyEntries);
|
2010-01-29 20:05:32 +00:00
|
|
|
|
|
2010-12-08 19:23:13 +00:00
|
|
|
|
foreach (string line in lines) {
|
2011-05-01 13:37:15 +00:00
|
|
|
|
string[] array = line.Split(new[] { ' ', '\t' },
|
2010-12-08 19:23:13 +00:00
|
|
|
|
StringSplitOptions.RemoveEmptyEntries);
|
2011-04-16 14:49:47 +00:00
|
|
|
|
if (array.Length == 0)
|
|
|
|
|
continue;
|
2010-12-08 19:23:13 +00:00
|
|
|
|
if (Convert.ToInt32(array[0], 16) == (address & 0xFFF0))
|
|
|
|
|
return Convert.ToByte(array[(address & 0x0F) + 1], 16);
|
2010-01-29 20:05:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-12-08 19:23:13 +00:00
|
|
|
|
throw new ArgumentException();
|
2010-01-29 20:05:32 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|