Browse Source

Merge branch 'httpsrv' into bfgminer

Luke Dashjr 12 years ago
parent
commit
0832a9d495
3 changed files with 29 additions and 6 deletions
  1. 4 0
      README
  2. 18 2
      README.ASIC
  3. 7 4
      driver-getwork.c

+ 4 - 0
README

@@ -81,6 +81,7 @@ BUILDING BFGMINER
 Everything you probably want, condensed:
 Everything you probably want, condensed:
 	build-essential autoconf automake libtool pkg-config libcurl4-gnutls-dev
 	build-essential autoconf automake libtool pkg-config libcurl4-gnutls-dev
 	libjansson-dev uthash-dev libncursesw5-dev libudev-dev libusb-1.0-0-dev
 	libjansson-dev uthash-dev libncursesw5-dev libudev-dev libusb-1.0-0-dev
+	libmicrohttpd-dev
 
 
 Dependencies:
 Dependencies:
 	autoconf             http://www.gnu.org/software/autoconf/
 	autoconf             http://www.gnu.org/software/autoconf/
@@ -104,6 +105,9 @@ Optional Dependencies:
 	Multiple ASIC/FPGA autodetection: any one of:
 	Multiple ASIC/FPGA autodetection: any one of:
 	  sysfs              (builtin to most Linux kernels, just mount on /sys)
 	  sysfs              (builtin to most Linux kernels, just mount on /sys)
 	  libudev-dev        http://www.freedesktop.org/software/systemd/libudev/
 	  libudev-dev        http://www.freedesktop.org/software/systemd/libudev/
+	
+	getwork server for Block Erupter Blades:
+	  libmicrohttpd-dev  http://www.gnu.org/software/libmicrohttpd/
 
 
 	X6500 and ZTEX FPGA boards:
 	X6500 and ZTEX FPGA boards:
 	  libusb-1.0-0-dev   http://www.libusb.org/
 	  libusb-1.0-0-dev   http://www.libusb.org/

+ 18 - 2
README.ASIC

@@ -1,9 +1,11 @@
 SUPPORTED DEVICES
 SUPPORTED DEVICES
 
 
-Currently supported ASIC devices include ASICMiner's Block Erupter USB miners,
-Avalon, and Butterfly Labs' SC range of devices.
+Currently supported ASIC devices include Avalon, Bitfountain's Block Erupter
+series (both USB and blades), and Butterfly Labs' SC range of devices.
+
 
 
 AVALON
 AVALON
+------
 
 
 Currently, Avalon boards are supported only by connecting them directly (or via
 Currently, Avalon boards are supported only by connecting them directly (or via
 a hub) to a regular PC running BFGMiner. It is also possible to install the
 a hub) to a regular PC running BFGMiner. It is also possible to install the
@@ -62,6 +64,20 @@ ambient temp / highest device temp  set fan % / lowest detected fan RPM.
 
 
 Use the API for more detailed information than this.
 Use the API for more detailed information than this.
 
 
+
+BLOCK ERUPTER BLADE
+-------------------
+
+Blades communicate over Ethernet using the old but simple getwork mining
+protocol. If you build BFGMiner with libmicrohttpd, you can have it work with
+one or more blades. First, start BFGMiner with the --http-port option. For
+example:
+    bfgminer --http-port 8330
+Then configure your blade to connect to your BFGMiner instance on the same port,
+with a unique username per blade. It will then show up as a SGW device and
+should work more or less like any other miner.
+
+
 ---
 ---
 
 
 This code is provided entirely free of charge by the programmer in his spare
 This code is provided entirely free of charge by the programmer in his spare

+ 7 - 4
driver-getwork.c

@@ -97,6 +97,7 @@ int getwork_error(struct MHD_Connection *conn, int16_t errcode, const char *errm
 	char * const reply = malloc(replysz);
 	char * const reply = malloc(replysz);
 	replysz = snprintf(reply, replysz, "{\"result\":null,\"error\":{\"code\":%d,\"message\":\"%s\"},\"id\":%s}", errcode, errmsg, idstr ?: "0");
 	replysz = snprintf(reply, replysz, "{\"result\":null,\"error\":{\"code\":%d,\"message\":\"%s\"},\"id\":%s}", errcode, errmsg, idstr ?: "0");
 	struct MHD_Response * const resp = MHD_create_response_from_buffer(replysz, reply, MHD_RESPMEM_MUST_FREE);
 	struct MHD_Response * const resp = MHD_create_response_from_buffer(replysz, reply, MHD_RESPMEM_MUST_FREE);
+	MHD_add_response_header(resp, MHD_HTTP_HEADER_CONTENT_TYPE, "application/json");
 	const int ret = MHD_queue_response(conn, 500, resp);
 	const int ret = MHD_queue_response(conn, 500, resp);
 	MHD_destroy_response(resp);
 	MHD_destroy_response(resp);
 	return ret;
 	return ret;
@@ -232,6 +233,7 @@ int handle_getwork(struct MHD_Connection *conn, bytes_t *upbuf)
 		sprintf(reply, "{\"error\":null,\"result\":%s,\"id\":%s}",
 		sprintf(reply, "{\"error\":null,\"result\":%s,\"id\":%s}",
 		        rejreason ? "false" : "true", idstr);
 		        rejreason ? "false" : "true", idstr);
 		resp = MHD_create_response_from_buffer(replysz, reply, MHD_RESPMEM_MUST_FREE);
 		resp = MHD_create_response_from_buffer(replysz, reply, MHD_RESPMEM_MUST_FREE);
+		MHD_add_response_header(resp, MHD_HTTP_HEADER_CONTENT_TYPE, "application/json");
 		if (rejreason)
 		if (rejreason)
 			MHD_add_response_header(resp, "X-Reject-Reason", rejreason);
 			MHD_add_response_header(resp, "X-Reject-Reason", rejreason);
 		ret = MHD_queue_response(conn, 200, resp);
 		ret = MHD_queue_response(conn, 200, resp);
@@ -246,7 +248,7 @@ int handle_getwork(struct MHD_Connection *conn, bytes_t *upbuf)
 	}
 	}
 	
 	
 	{
 	{
-		const size_t replysz = 451 + idstr_sz;
+		const size_t replysz = 590 + idstr_sz;
 		
 		
 		work = get_work(thr);
 		work = get_work(thr);
 		reply = malloc(replysz);
 		reply = malloc(replysz);
@@ -254,14 +256,15 @@ int handle_getwork(struct MHD_Connection *conn, bytes_t *upbuf)
 		bin2hex(&reply[108], work->data, 128);
 		bin2hex(&reply[108], work->data, 128);
 		memcpy(&reply[364], "\",\"midstate\":\"", 14);
 		memcpy(&reply[364], "\",\"midstate\":\"", 14);
 		bin2hex(&reply[378], work->midstate, 32);
 		bin2hex(&reply[378], work->midstate, 32);
-		memcpy(&reply[442], "\"},\"id\":", 8);
-		memcpy(&reply[450], idstr ?: "0", idstr_sz);
-		memcpy(&reply[450 + idstr_sz], "}", 1);
+		memcpy(&reply[442], "\",\"hash1\":\"00000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000010000\"},\"id\":", 147);
+		memcpy(&reply[589], idstr ?: "0", idstr_sz);
+		memcpy(&reply[589 + idstr_sz], "}", 1);
 		
 		
 		timer_set_now(&work->tv_work_start);
 		timer_set_now(&work->tv_work_start);
 		HASH_ADD_KEYPTR(hh, client->work, work->data, 76, work);
 		HASH_ADD_KEYPTR(hh, client->work, work->data, 76, work);
 		
 		
 		resp = MHD_create_response_from_buffer(replysz, reply, MHD_RESPMEM_MUST_FREE);
 		resp = MHD_create_response_from_buffer(replysz, reply, MHD_RESPMEM_MUST_FREE);
+		MHD_add_response_header(resp, MHD_HTTP_HEADER_CONTENT_TYPE, "application/json");
 		ret = MHD_queue_response(conn, 200, resp);
 		ret = MHD_queue_response(conn, 200, resp);
 		MHD_destroy_response(resp);
 		MHD_destroy_response(resp);
 	}
 	}