Add temperature rate, front, rear and device temperature to spond API output
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 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
diff --git a/driver-spondoolies.c b/driver-spondoolies.c
index a7b24f0..a47386c 100644
--- a/driver-spondoolies.c
+++ b/driver-spondoolies.c
@@ -179,12 +179,15 @@ static void spondoolies_detect(__maybe_unused bool hotplug)
applog(LOG_DEBUG, "SPOND spondoolies_detect done");
}
-static struct api_data *spondoolies_api_stats(struct cgpu_info __maybe_unused *cgpu)
+static struct api_data *spondoolies_api_stats(struct cgpu_info *cgpu)
{
+ struct spond_adapter *a = cgpu->device_data;
struct api_data *root = NULL;
- applog(LOG_DEBUG, "SPOND spondoolies_api_stats");
- applog(LOG_DEBUG, "SPOND spondoolies_api_stats done");
+ root = api_add_int(root, "Temperature rate", &a->temp_rate, false);
+ root = api_add_int(root, "Temparature rear", &a->rear_temp, false);
+ root = api_add_int(root, "Temparature front", &a->front_temp, false);
+
return root;
}
@@ -323,13 +326,41 @@ return_unlock:
return ret;
}
+static void spond_poll_stats(struct cgpu_info *spond, struct spond_adapter *a)
+{
+ FILE *fp = fopen("/var/run/mg_rate_temp", "r");
+
+ if (!fp) {
+ applog(LOG_DEBUG, "SPOND unable to open mg_rate_temp");
+ a->temp_rate = a->rear_temp = a->front_temp = 0;
+ } else {
+ int ret = fscanf(fp, "%d %d %d", &a->temp_rate, &a->rear_temp, &a->front_temp);
+
+ if (ret != 3)
+ a->temp_rate = a->rear_temp = a->front_temp = 0;
+ fclose(fp);
+ }
+ applog(LOG_DEBUG, "SPOND poll_stats rate: %d rear: %d front: %d",
+ a->temp_rate, a->rear_temp, a->front_temp);
+ /* Use the rear temperature as the dev temperature for now */
+ spond->temp = a->rear_temp;
+}
+
// Return completed work to submit_nonce() and work_completed()
// struct timeval last_force_queue = {0};
static int64_t spond_scanhash(struct thr_info *thr)
{
struct cgpu_info *cgpu = thr->cgpu;
struct spond_adapter *a = cgpu->device_data;
- int64_t ghashes=0;
+ int64_t ghashes = 0;
+ time_t now_t;
+
+ now_t = time(NULL);
+ /* Poll stats only once per second */
+ if (now_t != a->last_stats) {
+ a->last_stats = now_t;
+ spond_poll_stats(cgpu, a);
+ }
if (a->parse_resp) {
int array_size, i;
diff --git a/driver-spondoolies.h b/driver-spondoolies.h
index 0fead0a..4766a79 100644
--- a/driver-spondoolies.h
+++ b/driver-spondoolies.h
@@ -60,6 +60,14 @@ struct spond_adapter {
minergate_req_packet* mp_next_req;
minergate_rsp_packet* mp_last_rsp;
spond_driver_work my_jobs[MAX_JOBS_IN_MINERGATE];
+
+ // Temperature statistics
+ int temp_rate;
+ int rear_temp;
+ int front_temp;
+
+ // Last second we polled stats
+ time_t last_stats;
};
// returns non-zero if needs to change ASICs.