From 54ac35553fa7d1509f3082b2553e8e1f4ab11ace Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Tue, 24 Sep 2013 22:28:56 +1000 Subject: [PATCH] Add commands for getting BF1 bitfury info --- driver-bitfury.c | 26 ++++++++++++++++++-------- usbutils.h | 6 +++++- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/driver-bitfury.c b/driver-bitfury.c index 6ec794a9..66f35ff5 100644 --- a/driver-bitfury.c +++ b/driver-bitfury.c @@ -26,27 +26,37 @@ static void bitfury_close(struct cgpu_info *bitfury) usb_transfer(bitfury, 0x21, 0x22, 0, 0, C_BFO_CLOSE); } -static void bitfury_initialise(struct cgpu_info *bitfury) -{ - bitfury_open(bitfury); -} - static bool bitfury_detect_one(struct libusb_device *dev, struct usb_find_devices *found) { struct cgpu_info *bitfury; + char buf[512]; + int amount; bitfury = usb_alloc_cgpu(&bitfury_drv, 1); if (!usb_init(bitfury, dev, found)) { bitfury = usb_free_cgpu(bitfury); - return false; + goto out; } - applog(LOG_WARNING, "%s%d: Found at %s", bitfury->drv->name, + applog(LOG_INFO, "%s%d: Found at %s", bitfury->drv->name, bitfury->device_id, bitfury->device_path); - bitfury_initialise(bitfury); + usb_buffer_enable(bitfury); + bitfury_open(bitfury); + usb_write(bitfury, "I", 1, &amount, C_BFO_REQINFO); + usb_read(bitfury, buf, 14, &amount, C_BFO_GETINFO); + if (amount != 14) { + applog(LOG_WARNING, "%s%d: Getinfo received %d", + bitfury->drv->name, bitfury->device_id, amount); + goto out_close; + } + applog(LOG_INFO, "%s%d: Getinfo returned %s", bitfury->drv->name, + bitfury->device_id, buf); + //return true; +out_close: bitfury_close(bitfury); +out: return false; } diff --git a/usbutils.h b/usbutils.h index 29501e2b..3119e4a3 100644 --- a/usbutils.h +++ b/usbutils.h @@ -323,7 +323,11 @@ struct cg_usb_info { USB_ADD_COMMAND(C_BB_SET_VOLTAGE, "SetCoreVoltage") \ USB_ADD_COMMAND(C_BB_GET_VOLTAGE, "GetCoreVoltage") \ USB_ADD_COMMAND(C_BFO_OPEN, "BF1Open") \ - USB_ADD_COMMAND(C_BFO_CLOSE, "BF1Close") + USB_ADD_COMMAND(C_BFO_CLOSE, "BF1Close") \ + USB_ADD_COMMAND(C_BFO_REQINFO, "BF1RequestInfo") \ + USB_ADD_COMMAND(C_BFO_GETINFO, "BF1GetInfo") \ + USB_ADD_COMMAND(C_BFO_REQRESET, "BF1RequestReset") \ + USB_ADD_COMMAND(C_BFO_GETRESET, "BF1GetReset") /* Create usb_cmds enum from USB_PARSE_COMMANDS macro */ #define USB_ADD_COMMAND(X, Y) X,