# HG changeset patch # User moel.mich # Date 1326640043 0 # Node ID c34cbcc7df66040b712585537c449d807a64c403 # Parent 19b1e150e7afedbb1f768a4db7602afc20388bd9 Fixed Issue 213. diff -r 19b1e150e7af -r c34cbcc7df66 Hardware/ATI/ADL.cs --- a/Hardware/ATI/ADL.cs Sun Jan 15 14:05:52 2012 +0000 +++ b/Hardware/ATI/ADL.cs Sun Jan 15 15:07:23 2012 +0000 @@ -16,7 +16,7 @@ The Initial Developer of the Original Code is Michael Möller . - Portions created by the Initial Developer are Copyright (C) 2009-2010 + Portions created by the Initial Developer are Copyright (C) 2009-2012 the Initial Developer. All Rights Reserved. Contributor(s): @@ -37,6 +37,7 @@ using System; using System.Runtime.InteropServices; +using System.Text.RegularExpressions; namespace OpenHardwareMonitor.Hardware.ATI { @@ -124,8 +125,7 @@ public const int ADL_DL_FANCTRL_SUPPORTS_RPM_WRITE = 8; public const int ADL_DL_FANCTRL_FLAG_USER_DEFINED_SPEED = 1; - public const int ATI_VENDOR_ID1 = 1002; - public const int ATI_VENDOR_ID2 = 0x1002; + public const int ATI_VENDOR_ID = 0x1002; private delegate int ADL_Main_Control_CreateDelegate( ADL_Main_Memory_AllocDelegate callback, int enumConnectedAdapters); @@ -261,6 +261,23 @@ Marshal.PtrToStructure((IntPtr)((long)ptr + i * elementSize), typeof(ADLAdapterInfo)); Marshal.FreeHGlobal(ptr); + + // the ADLAdapterInfo.VendorID field reported by ADL is wrong on + // Windows systems (parse error), so we fix this here + for (int i = 0; i < info.Length; i++) { + // try Windows UDID format + Match m = Regex.Match(info[i].UDID, "PCI_VEN_([A-Fa-f0-9]{1,4})&.*"); + if (m.Success && m.Groups.Count == 2) { + info[i].VendorID = Convert.ToInt32(m.Groups[1].Value, 16); + continue; + } + // if above failed, try Unix UDID format + m = Regex.Match(info[i].UDID, "[0-9]+:[0-9]+:([0-9]+):[0-9]+:[0-9]+"); + if (m.Success && m.Groups.Count == 2) { + info[i].VendorID = Convert.ToInt32(m.Groups[1].Value, 10); + } + } + return result; } diff -r 19b1e150e7af -r c34cbcc7df66 Hardware/ATI/ATIGroup.cs --- a/Hardware/ATI/ATIGroup.cs Sun Jan 15 14:05:52 2012 +0000 +++ b/Hardware/ATI/ATIGroup.cs Sun Jan 15 15:07:23 2012 +0000 @@ -16,7 +16,7 @@ The Initial Developer of the Original Code is Michael Möller . - Portions created by the Initial Developer are Copyright (C) 2009-2010 + Portions created by the Initial Developer are Copyright (C) 2009-2012 the Initial Developer. All Rights Reserved. Contributor(s): @@ -87,8 +87,8 @@ report.Append("Present: "); report.AppendLine(adapterInfo[i].Present.ToString( CultureInfo.InvariantCulture)); - report.Append("VendorID: "); - report.AppendLine(adapterInfo[i].VendorID.ToString( + report.Append("VendorID: 0x"); + report.AppendLine(adapterInfo[i].VendorID.ToString("X", CultureInfo.InvariantCulture)); report.Append("BusNumber: "); report.AppendLine(adapterInfo[i].BusNumber.ToString( @@ -104,8 +104,8 @@ CultureInfo.InvariantCulture)); if (!string.IsNullOrEmpty(adapterInfo[i].UDID) && - (adapterInfo[i].VendorID == ADL.ATI_VENDOR_ID1 || - adapterInfo[i].VendorID == ADL.ATI_VENDOR_ID2)) { + adapterInfo[i].VendorID == ADL.ATI_VENDOR_ID) + { bool found = false; foreach (ATIGPU gpu in hardware) if (gpu.BusNumber == adapterInfo[i].BusNumber &&