avalon: display the FPGA controller version on API
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
diff --git a/driver-avalon.c b/driver-avalon.c
index 348a2ae..824005e 100644
--- a/driver-avalon.c
+++ b/driver-avalon.c
@@ -273,6 +273,7 @@ static int avalon_reset(struct cgpu_info *avalon, bool initial)
struct avalon_task at;
uint8_t *buf, *tmp;
struct timespec p;
+ struct avalon_info *info = avalon->device_data;
/* Send reset, then check for result */
avalon_init_task(&at, 1, 0,
@@ -329,9 +330,17 @@ static int avalon_reset(struct cgpu_info *avalon, bool initial)
" (%d: %02x %02x %02x %02x)", avalon->drv->name, avalon->device_id,
i, buf[0], buf[1], buf[2], buf[3]);
/* FIXME: return 1; */
- } else
- applog(LOG_WARNING, "%s%d: Reset succeeded",
- avalon->drv->name, avalon->device_id);
+ } else {
+ /* buf[44]: minor
+ * buf[45]: day
+ * buf[46]: year,month, d6: 201306
+ */
+ info->ctlr_ver = ((buf[46] >> 4) + 2000) * 1000000 +
+ (buf[46] & 0x0f) * 10000 +
+ buf[45] * 100 + buf[44];
+ applog(LOG_WARNING, "%s%d: Reset succeeded (Controller version: %d)",
+ avalon->drv->name, avalon->device_id, info->ctlr_ver);
+ }
return 0;
}
@@ -1522,6 +1531,7 @@ static struct api_data *avalon_api_stats(struct cgpu_info *cgpu)
info->version1, info->version2, info->version3);
root = api_add_string(root, "version", buf, true);
}
+ root = api_add_int(root, "Controller Version", &(info->ctlr_ver), false);
return root;
}
diff --git a/driver-avalon.h b/driver-avalon.h
index 3f7c696..54dc5e2 100644
--- a/driver-avalon.h
+++ b/driver-avalon.h
@@ -125,6 +125,7 @@ struct avalon_info {
int matching_work[AVALON_DEFAULT_MINER_NUM];
int frequency;
+ uint32_t ctlr_ver;
struct thr_info *thr;
pthread_t read_thr;