Add temperature parsing to bxf driver
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
diff --git a/driver-bitfury.c b/driver-bitfury.c
index eec35dc..5adc5c5 100644
--- a/driver-bitfury.c
+++ b/driver-bitfury.c
@@ -232,6 +232,20 @@ static void bitfury_detect(bool __maybe_unused hotplug)
usb_detect(&bitfury_drv, bitfury_detect_one);
}
+static void parse_bxf_temp(struct cgpu_info *bitfury, struct bitfury_info *info, char *buf)
+{
+ unsigned int temp;
+
+ if (!sscanf(&buf[5], "%u", &temp)) {
+ applog(LOG_INFO, "%s %d: Failed to parse temperature",
+ bitfury->drv->name, bitfury->device_id);
+ return;
+ }
+ mutex_lock(&info->lock);
+ info->temperature = (double)temp / 10;
+ mutex_unlock(&info->lock);
+}
+
static void *bxf_get_results(void *userdata)
{
struct cgpu_info *bitfury = userdata;
@@ -253,6 +267,8 @@ static void *bxf_get_results(void *userdata)
break;
continue;
}
+ if (!strncmp(buf, "temp", 4))
+ parse_bxf_temp(bitfury, info, buf);
}
return NULL;
}
diff --git a/driver-bitfury.h b/driver-bitfury.h
index cb75341..808f4ab 100644
--- a/driver-bitfury.h
+++ b/driver-bitfury.h
@@ -30,6 +30,7 @@ struct bitfury_info {
/* BXF specific data */
pthread_mutex_t lock;
pthread_t read_thr;
+ double temperature;
};
#endif /* BITFURY_H */