Skip to content

Commit 0e1774b

Browse files
committed
Fix for 0c memory junction sensor.
1 parent c0212e6 commit 0e1774b

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

NvThermalSensors.cs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using FanControl.Plugins;
2-
using System.Collections.Generic;
1+
using System.Collections.Generic;
32

43
namespace FanControl.NvThermalSensors
54
{
@@ -10,14 +9,16 @@ internal NvThermalSensors(int gpuIndex, NvApi.NvPhysicalGpuHandle handle)
109
Sensors = new List<NvThermalSensor>();
1110

1211
var mask = FindThermalSensorMask(handle);
12+
1313
if (mask == 0)
1414
return;
1515

1616
var gpuName = GetGpuName(handle, gpuIndex);
17+
var sensorcount = GetSensorCount(mask);
1718

1819
if (GetSensorValue(handle, mask, 1) != null)
1920
Sensors.Add(new NvThermalSensor(gpuIndex, $"{gpuName} - Hot Spot", () => GetSensorValue(handle, mask, 1)));
20-
if (GetSensorValue(handle, mask, 9) != null)
21+
if (GetSensorValue(handle, mask, sensorcount - 1) != null)
2122
Sensors.Add(new NvThermalSensor(gpuIndex, $"{gpuName} - Memory Junction", () => GetSensorValue(handle, mask, 9)));
2223
}
2324

@@ -38,6 +39,19 @@ private uint FindThermalSensorMask(NvApi.NvPhysicalGpuHandle handle)
3839
return --mask;
3940
}
4041

42+
private int GetSensorCount(uint mask)
43+
{
44+
var sensorCount = 0;
45+
46+
while (mask > 0)
47+
{
48+
mask &= (mask - 1);
49+
sensorCount++;
50+
}
51+
52+
return sensorCount;
53+
}
54+
4155
private NvApi.NvThermalSensors GetThermalSensors(NvApi.NvPhysicalGpuHandle handle, uint mask, out NvApi.NvStatus status)
4256
{
4357
var thermalSensors = new NvApi.NvThermalSensors()

0 commit comments

Comments
 (0)