Browse Source

modminer: Show bitstream upload progress in statline, and only report to log every 10%

Luke Dashjr 13 years ago
parent
commit
5e3809c9a8
1 changed files with 33 additions and 21 deletions
  1. 33 21
      driver-modminer.c

+ 33 - 21
driver-modminer.c

@@ -22,6 +22,24 @@
 
 struct device_api modminer_api;
 
+struct modminer_fpga_state {
+	bool work_running;
+	struct work running_work;
+	struct timeval tv_workstart;
+	uint32_t hashes;
+
+	char next_work_cmd[46];
+
+	unsigned char clock;
+	int no_nonce_counter;
+	int good_share_counter;
+	time_t last_cutoff_reduced;
+
+	unsigned char temp;
+
+	unsigned char pdone;
+};
+
 static inline bool
 _bailout(int fd, struct cgpu_info*modminer, int prio, const char *fmt, ...)
 {
@@ -139,6 +157,7 @@ select(fd+1, &fds, NULL, NULL, NULL);  \
 static bool
 modminer_fpga_upload_bitstream(struct cgpu_info*modminer)
 {
+	struct modminer_fpga_state *state = modminer->thr[0]->cgpu_data;
 fd_set fds;
 	char buf[0x100];
 	unsigned char *ubuf = (unsigned char*)buf;
@@ -199,18 +218,18 @@ fd_set fds;
 		bailout2(LOG_ERR, "%s %u: Error programming %s (cmd)", modminer->api->name, modminer->device_id, modminer->device_path);
 	status_read("cmd reply");
 	ssize_t buflen;
-	time_t nextstatus = time(NULL) + opt_log_interval, now;
+	char nextstatus = 10;
 	while (len) {
 		buflen = len < 32 ? len : 32;
 		if (fread(buf, buflen, 1, f) != 1)
 			bailout2(LOG_ERR, "%s %u: File underrun programming %s (%d bytes left)", modminer->api->name, modminer->device_id, modminer->device_path, len);
 		if (write(fd, buf, buflen) != buflen)
 			bailout2(LOG_ERR, "%s %u: Error programming %s (data)", modminer->api->name, modminer->device_id,  modminer->device_path);
-		time(&now);
-		if (now >= nextstatus)
+		state->pdone = 100 - ((len * 100) / flen);
+		if (state->pdone >= nextstatus)
 		{
-			nextstatus = now + opt_log_interval;
-			applog(LOG_WARNING, "%s %u: Programming %s... %d%% complete...", modminer->api->name, modminer->device_id, modminer->device_path, 100 - ((len * 100) / flen));
+			nextstatus += 10;
+			applog(LOG_WARNING, "%s %u: Programming %s... %d%% complete...", modminer->api->name, modminer->device_id, modminer->device_path, state->pdone);
 		}
 		status_read("status");
 		len -= buflen;
@@ -240,22 +259,6 @@ modminer_device_prepare(struct cgpu_info *modminer)
 
 #undef bailout
 
-struct modminer_fpga_state {
-	bool work_running;
-	struct work running_work;
-	struct timeval tv_workstart;
-	uint32_t hashes;
-
-	char next_work_cmd[46];
-
-	unsigned char clock;
-	int no_nonce_counter;
-	int good_share_counter;
-	time_t last_cutoff_reduced;
-
-	unsigned char temp;
-};
-
 static bool
 modminer_fpga_prepare(struct thr_info *thr)
 {
@@ -336,6 +339,7 @@ modminer_fpga_init(struct thr_info *thr)
 	}
 	else
 		applog(LOG_DEBUG, "%s %u.%u: FPGA is already programmed :)", modminer->api->name, modminer->device_id, fpgaid);
+	state->pdone = 101;
 
 	state->clock = 212;  // Will be reduced to 210 by modminer_reduce_clock
 	modminer_reduce_clock(thr, false);
@@ -353,6 +357,14 @@ get_modminer_statline_before(char *buf, struct cgpu_info *modminer)
 	bool havetemp = false;
 	int i;
 
+	char pdone = ((struct modminer_fpga_state*)(modminer->thr[0]->cgpu_data))->pdone;
+	if (pdone != 101) {
+		sprintf(&info[1], "%3d%%", pdone);
+		info[5] = ' ';
+		strcat(buf, info);
+		return;
+	}
+
 	if (tc > 4)
 		tc = 4;