Commit 977943b31884d989a7f6a73f8f652299f0012d8e

Con Kolivas 2013-11-14T12:08:48

Add temperature parsing to bxf driver

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 */