Commit 0d9f3389a1aa72d35ddfea49f04d062988e542af

Kano 2013-09-24T13:17:19

klondike - debug dump structured replies

diff --git a/driver-klondike.c b/driver-klondike.c
index b3ffe37..44a62b2 100644
--- a/driver-klondike.c
+++ b/driver-klondike.c
@@ -82,7 +82,7 @@ typedef struct _workresult {
 	uint32_t nonce;
 } WORKRESULT;
 
-typedef struct kondike_cfg {
+typedef struct klondike_cfg {
 	uint16_t hashclock;
 	uint8_t temptarget;
 	uint8_t tempcritical;
@@ -339,12 +339,18 @@ static void klondike_check_nonce(struct cgpu_info *klncgpu, WORKRESULT *result)
 	//inc_hw_errors(klncgpu->thr[0]);
 }
 
+// Change this to LOG_WARNING if you wish to always see the replies
+#define READ_DEBUG LOG_DEBUG
+
 // thread to keep looking for replies
 static void *klondike_get_replies(void *userdata)
 {
 	struct cgpu_info *klncgpu = (struct cgpu_info *)userdata;
 	struct klondike_info *klninfo = (struct klondike_info *)(klncgpu->device_data);
 	struct klondike_status *ks;
+	struct _workresult *wr;
+	struct klondike_cfg *kc;
+	struct klondike_id *ki;
 	char *replybuf;
 	int err, recd;
 
@@ -361,7 +367,7 @@ static void *klondike_get_replies(void *userdata)
 		if (!err && recd == REPLY_SIZE) {
 			if (opt_log_level <= LOG_DEBUG) {
 				char *hexdata = bin2hex((unsigned char *)(replybuf+1), recd);
-				applog(LOG_DEBUG, "%s (%s) reply [%s:%s]", klncgpu->drv->dname, klncgpu->device_path, replybuf+1, hexdata);
+				applog(READ_DEBUG, "%s (%s) reply [%s:%s]", klncgpu->drv->dname, klncgpu->device_path, replybuf+1, hexdata);
 				free(hexdata);
 			}
 			if (++klninfo->nextreply == MAX_REPLY_COUNT)
@@ -370,7 +376,16 @@ static void *klondike_get_replies(void *userdata)
 			replybuf[0] = replybuf[1];
 			switch (replybuf[0]) {
 				case '=':
+					wr = (struct _workresult *)(replybuf+1);
 					klondike_check_nonce(klncgpu, (WORKRESULT *)replybuf);
+					applog(READ_DEBUG,
+						"%s (%s) reply: work [%c] device=%d workid=%d"
+						" nonce=0x%08x",
+						klncgpu->drv->dname, klncgpu->device_path,
+						*(replybuf+1),
+						(int)(wr->device),
+						(int)(wr->workid),
+						(unsigned int)(wr->nonce));
 					break;
 				case 'S':
 				case 'W':
@@ -381,6 +396,45 @@ static void *klondike_get_replies(void *userdata)
 					klninfo->errorcount += ks->errorcount;
 					klninfo->noisecount += ks->noise;
 					wr_unlock(&(klninfo->stat_lock));
+					applog(READ_DEBUG,
+						"%s (%s) reply: status [%c] chips=%d slaves=%d"
+						" workcq=%d workid=%d temp=%d fan=%d errors=%d"
+						" hashes=%d max=%d noise=%d",
+						klncgpu->drv->dname, klncgpu->device_path,
+						*(replybuf+1),
+						(int)(ks->chipcount),
+						(int)(ks->slavecount),
+						(int)(ks->workqc),
+						(int)(ks->workid),
+						(int)(ks->temp),
+						(int)(ks->fanspeed),
+						(int)(ks->errorcount),
+						(int)(ks->hashcount),
+						(int)(ks->maxcount),
+						(int)(ks->noise));
+					break;
+				case 'C':
+					kc = (struct klondike_cfg *)(replybuf+2);
+					applog(READ_DEBUG,
+						"%s (%s) reply: config [%c] clock=%d temptarget=%d"
+						" tempcrit=%d fan=%d",
+						klncgpu->drv->dname, klncgpu->device_path,
+						*(replybuf+1),
+						(int)(kc->hashclock),
+						(int)(kc->temptarget),
+						(int)(kc->tempcritical),
+						(int)(kc->fantarget));
+					break;
+				case 'I':
+					ki = (struct klondike_id *)(replybuf+2);
+					applog(READ_DEBUG,
+						"%s (%s) reply: info [%c] version=0x%02x prod=%.7s"
+						" serial=0x%08x",
+						klncgpu->drv->dname, klncgpu->device_path,
+						*(replybuf+1),
+						(int)(ki->version),
+						ki->product,
+						(unsigned int)(ki->serial));
 					break;
 				default:
 					break;