Browse Source

Merge branch 'bfl_devdump' into bitforce_queue_parallel

Luke Dashjr 12 years ago
parent
commit
18a09f0a0f
3 changed files with 20 additions and 0 deletions
  1. 15 0
      driver-bitforce.c
  2. 4 0
      miner.c
  3. 1 0
      miner.h

+ 15 - 0
driver-bitforce.c

@@ -64,12 +64,16 @@ struct device_drv bitforce_queue_api;
 
 static void BFgets(char *buf, size_t bufLen, int fd)
 {
+	char *obuf = buf;
 	do {
 		buf[0] = '\0';
 		--bufLen;
 	} while (likely(bufLen && read(fd, buf, 1) == 1 && (buf++)[0] != '\n'));
 
 	buf[0] = '\0';
+	
+	if (unlikely(opt_dev_protocol))
+		applog(LOG_DEBUG, "DEVPROTO: GETS (fd=%d): %s", fd, obuf);
 }
 
 static ssize_t BFwrite(int fd, const void *buf, ssize_t bufLen)
@@ -109,6 +113,9 @@ static ssize_t bitforce_send(int fd, int procid, const void *buf, ssize_t bufLen
 static
 void bitforce_cmd1(int fd, int procid, void *buf, size_t bufsz, const char *cmd)
 {
+	if (unlikely(opt_dev_protocol))
+		applog(LOG_DEBUG, "DEVPROTO: CMD1 (fd=%d xlink=%d): %s", fd, procid, cmd);
+	
 	bitforce_send(fd, procid, cmd, 3);
 	BFgets(buf, bufsz, fd);
 }
@@ -119,6 +126,14 @@ void bitforce_cmd2(int fd, int procid, void *buf, size_t bufsz, const char *cmd,
 	bitforce_cmd1(fd, procid, buf, bufsz, cmd);
 	if (strncasecmp(buf, "OK", 2))
 		return;
+	
+	if (unlikely(opt_dev_protocol))
+	{
+		char *hex = bin2hex(data, datasz);
+		applog(LOG_DEBUG, "DEVPROTO: CMD2 (fd=%d xlink=%d): %s", fd, procid, hex);
+		free(hex);
+	}
+	
 	bitforce_send(fd, procid, data, datasz);
 	BFgets(buf, bufsz, fd);
 }

+ 4 - 0
miner.c

@@ -95,6 +95,7 @@ struct strategies strategies[] = {
 static char packagename[256];
 
 bool opt_protocol;
+bool opt_dev_protocol;
 static bool opt_benchmark;
 static bool want_longpoll = true;
 static bool want_gbt = true;
@@ -1261,6 +1262,9 @@ static struct opt_table opt_config_table[] = {
 	OPT_WITHOUT_ARG("--debuglog",
 		     opt_set_bool, &opt_debug,
 		     "Enable debug logging"),
+	OPT_WITHOUT_ARG("--device-protocol-dump",
+			opt_set_bool, &opt_dev_protocol,
+			"Verbose dump of device protocol-level activities"),
 	OPT_WITH_ARG("--device|-d",
 		     set_devices, NULL, NULL,
 	             "Select device to use, one value, range and/or comma separated (e.g. 0-2,4) default: all"),

+ 1 - 0
miner.h

@@ -834,6 +834,7 @@ static inline void cg_wunlock(cglock_t *lock)
 struct pool;
 
 extern bool opt_protocol;
+extern bool opt_dev_protocol;
 extern char *opt_coinbase_sig;
 extern bool have_longpoll;
 extern int opt_skip_checks;