Store the cointerra maximum temperature in the cgpu struct as an exponentially changing value based on the maximum temperature.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
diff --git a/driver-cointerra.c b/driver-cointerra.c
index 27993d8..9d49760 100644
--- a/driver-cointerra.c
+++ b/driver-cointerra.c
@@ -435,8 +435,12 @@ static void u16array_from_msg(uint16_t *u16, int entries, int var, char *buf)
u16[i] = hu16_from_msg(buf, var + j);
}
-static void cta_parse_statread(struct cointerra_info *info, char *buf)
+static void cta_parse_statread(struct cgpu_info *cointerra, struct cointerra_info *info,
+ char *buf)
{
+ float max_temp = 0;
+ int i;
+
mutex_lock(&info->lock);
u16array_from_msg(info->coretemp, CTA_CORES, CTA_STAT_CORETEMPS, buf);
info->ambtemp_low = hu16_from_msg(buf, CTA_STAT_AMBTEMP_LOW);
@@ -450,6 +454,15 @@ static void cta_parse_statread(struct cointerra_info *info, char *buf)
info->inactive = hu16_from_msg(buf, CTA_STAT_INACTIVE);
info->active = hu16_from_msg(buf, CTA_STAT_ACTIVE);
mutex_unlock(&info->lock);
+
+ for (i = 0; i < CTA_CORES; i++) {
+ if (info->coretemp[i] > max_temp)
+ max_temp = info->coretemp[i];
+ }
+ max_temp /= 100.0;
+ /* Store the max temperature in the cgpu struct as an exponentially
+ * changing value. */
+ cointerra->temp = cointerra->temp * 0.63 + max_temp * 0.37;
}
static void u8array_from_msg(uint8_t *u8, int entries, int var, char *buf)
@@ -561,7 +574,7 @@ static void cta_parse_msg(struct thr_info *thr, struct cgpu_info *cointerra,
case CTA_RECV_STATREAD:
applog(LOG_DEBUG, "%s %d: Status readings message received",
cointerra->drv->name, cointerra->device_id);
- cta_parse_statread(info, buf);
+ cta_parse_statread(cointerra, info, buf);
break;
case CTA_RECV_STATSET:
applog(LOG_DEBUG, "%s %d: Status settings message received",
@@ -1074,21 +1087,18 @@ static struct api_data *cta_api_stats(struct cgpu_info *cgpu)
static void cta_statline_before(char *buf, size_t bufsiz, struct cgpu_info *cointerra)
{
struct cointerra_info *info = cointerra->device_data;
- double max_temp = 0, max_volt = 0;
+ double max_volt = 0;
int freq = 0, i;
for (i = 0; i < CTA_CORES; i++) {
- if (info->coretemp[i] > max_temp)
- max_temp = info->coretemp[i];
if (info->corevolts[i] > max_volt)
max_volt = info->corevolts[i];
if (info->corefreqs[i] > freq)
freq = info->corefreqs[i];
}
- max_temp /= 100;
max_volt /= 100;
- tailsprintf(buf, bufsiz, "%3d %3.1fC %2.1fV | ", freq, max_temp, max_volt);
+ tailsprintf(buf, bufsiz, "%3d %3.1fC %2.1fV | ", freq, cointerra->temp, max_volt);
}
struct device_drv cointerra_drv = {