Browse Source

Merge branch 'hashbuster_micro' into bfgminer

Luke Dashjr 12 years ago
parent
commit
070b1c6b6d
1 changed files with 23 additions and 14 deletions
  1. 23 14
      driver-hashbuster2.c

+ 23 - 14
driver-hashbuster2.c

@@ -13,6 +13,7 @@
 
 
 #include <stdbool.h>
 #include <stdbool.h>
 #include <stdint.h>
 #include <stdint.h>
+#include <string.h>
 
 
 #include "deviceapi.h"
 #include "deviceapi.h"
 #include "driver-bitfury.h"
 #include "driver-bitfury.h"
@@ -143,7 +144,7 @@ bool hashbuster2_lowl_probe(const struct lowlevel_device_info * const info)
 	int j;
 	int j;
 	struct cgpu_info dummy_cgpu;
 	struct cgpu_info dummy_cgpu;
 	const char * const product = info->product;
 	const char * const product = info->product;
-	const char * const serial = info->serial;
+	char *serial = info->serial;
 	libusb_device_handle *h;
 	libusb_device_handle *h;
 	
 	
 	if (info->lowl != &lowl_usb)
 	if (info->lowl != &lowl_usb)
@@ -165,22 +166,30 @@ bool hashbuster2_lowl_probe(const struct lowlevel_device_info * const info)
 	
 	
 	unsigned char OUTPacket[64];
 	unsigned char OUTPacket[64];
 	unsigned char INPacket[64];
 	unsigned char INPacket[64];
-	signed int result;
 	OUTPacket[0] = 0xFE;
 	OUTPacket[0] = 0xFE;
-	libusb_bulk_transfer(h, 0x01, OUTPacket, 64, &result, 0);
-	libusb_bulk_transfer(h, 0x81,  INPacket, 64, &result, 0);
+	hashbuster2_io(h, INPacket, OUTPacket);
 	if (INPacket[1] == 0x18)
 	if (INPacket[1] == 0x18)
 	{
 	{
-		do
-		{
-			// Turn on miner PSU
-			OUTPacket[0] = 0x10;
-			OUTPacket[1] = 0x00;
-			OUTPacket[2] = 0x01;
-			libusb_bulk_transfer(h, 0x01, OUTPacket, 64, &result, 0);
-			libusb_bulk_transfer(h, 0x81,  INPacket, 64, &result, 0);
-		} while (INPacket[0] == 0xFF);
+		// Turn on miner PSU
+		OUTPacket[0] = 0x10;
+		OUTPacket[1] = 0x00;
+		OUTPacket[2] = 0x01;
+		hashbuster2_io(h, INPacket, OUTPacket);
+	}
+	
+	OUTPacket[0] = '\x20';
+	hashbuster2_io(h, INPacket, OUTPacket);
+	if (!memcmp(INPacket, "\x20\0", 2))
+	{
+		// 64-bit LE serial number
+		uint64_t sernum = 0;
+		for (j = 2; j < 10; ++j)
+			sernum = (sernum << 8) | INPacket[j];
+		serial = malloc((8 * 2) + 1);
+		sprintf(serial, "%08"PRIx64, sernum);
 	}
 	}
+	else
+		serial = maybe_strdup(info->serial);
 	
 	
 	int chip_n;
 	int chip_n;
 	
 	
@@ -218,7 +227,7 @@ bool hashbuster2_lowl_probe(const struct lowlevel_device_info * const info)
 			.threads = 1,
 			.threads = 1,
 			.dev_manufacturer = maybe_strdup(info->manufacturer),
 			.dev_manufacturer = maybe_strdup(info->manufacturer),
 			.dev_product = maybe_strdup(product),
 			.dev_product = maybe_strdup(product),
-			.dev_serial = maybe_strdup(serial),
+			.dev_serial = serial,
 			.deven = DEV_ENABLED,
 			.deven = DEV_ENABLED,
 		};
 		};
 	}
 	}