Browse Source

bitforce: Debuglog device information during detection

Luke Dashjr 13 years ago
parent
commit
eaa48af7d2
1 changed files with 17 additions and 1 deletions
  1. 17 1
      driver-bitforce.c

+ 17 - 1
driver-bitforce.c

@@ -67,6 +67,7 @@ static bool bitforce_detect_one(const char *devpath)
 	int fdDev = serial_open(devpath, 0, 10, true);
 	int fdDev = serial_open(devpath, 0, 10, true);
 	struct cgpu_info *bitforce;
 	struct cgpu_info *bitforce;
 	char pdevbuf[0x100];
 	char pdevbuf[0x100];
+	size_t pdevbuf_len;
 	char *s;
 	char *s;
 
 
 	applog(LOG_DEBUG, "BFL: Attempting to open %s", devpath);
 	applog(LOG_DEBUG, "BFL: Attempting to open %s", devpath);
@@ -84,12 +85,27 @@ static bool bitforce_detect_one(const char *devpath)
 		return 0;
 		return 0;
 	}
 	}
 
 
-	BFclose(fdDev);
 	if (unlikely(!strstr(pdevbuf, "SHA256"))) {
 	if (unlikely(!strstr(pdevbuf, "SHA256"))) {
 		applog(LOG_DEBUG, "BFL: Didn't recognise BitForce on %s", devpath);
 		applog(LOG_DEBUG, "BFL: Didn't recognise BitForce on %s", devpath);
+		BFclose(fdDev);
 		return false;
 		return false;
 	}
 	}
 
 
+	applog(LOG_DEBUG, "Found BitForce device on %s", devpath);
+	BFwrite(fdDev, "ZCX", 3);
+	while (true)
+	{
+		BFgets(pdevbuf, sizeof(pdevbuf), fdDev);
+		if (!strncasecmp(pdevbuf, "OK", 2))
+			break;
+		pdevbuf_len = strlen(pdevbuf);
+		if (unlikely(!pdevbuf_len))
+			continue;
+		pdevbuf[pdevbuf_len-1] = '\0';  // trim newline
+		applog(LOG_DEBUG, "  %s", pdevbuf);
+	}
+	BFclose(fdDev);
+	
 	// We have a real BitForce!
 	// We have a real BitForce!
 	bitforce = calloc(1, sizeof(*bitforce));
 	bitforce = calloc(1, sizeof(*bitforce));
 	bitforce->api = &bitforce_api;
 	bitforce->api = &bitforce_api;