From: Uwe Hermann Date: Sun, 6 May 2012 17:54:46 +0000 (+0200) Subject: sr: fx2lafw: Get/display FX2 REVID. X-Git-Tag: libsigrok-0.1.1~23 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=1e94408ae515157a9f27898b7b4c181e2aef980a;p=libsigrok.git sr: fx2lafw: Get/display FX2 REVID. --- diff --git a/hardware/fx2lafw/command.c b/hardware/fx2lafw/command.c index acf5a7f3..bb47d2d1 100644 --- a/hardware/fx2lafw/command.c +++ b/hardware/fx2lafw/command.c @@ -39,6 +39,23 @@ SR_PRIV int command_get_fw_version(libusb_device_handle *devhdl, return SR_OK; } +SR_PRIV int command_get_revid_version(libusb_device_handle *devhdl, + uint8_t *revid) +{ + int ret; + + ret = libusb_control_transfer(devhdl, LIBUSB_REQUEST_TYPE_VENDOR | + LIBUSB_ENDPOINT_IN, CMD_GET_REVID_VERSION, 0x0000, 0x0000, + revid, 1, 100); + + if (ret < 0) { + sr_err("fx2lafw: Unable to get REVID: %d.", ret); + return SR_ERR; + } + + return SR_OK; +} + SR_PRIV int command_start_acquisition(libusb_device_handle *devhdl, uint64_t samplerate) { diff --git a/hardware/fx2lafw/command.h b/hardware/fx2lafw/command.h index deacbecd..0ab3e85e 100644 --- a/hardware/fx2lafw/command.h +++ b/hardware/fx2lafw/command.h @@ -25,6 +25,7 @@ /* Protocol commands */ #define CMD_GET_FW_VERSION 0xb0 #define CMD_START 0xb1 +#define CMD_GET_REVID_VERSION 0xb2 #define CMD_START_FLAGS_CLK_SRC_POS 6 @@ -47,7 +48,8 @@ struct cmd_start_acquisition { SR_PRIV int command_get_fw_version(libusb_device_handle *devhdl, struct version_info *vi); - +SR_PRIV int command_get_revid_version(libusb_device_handle *devhdl, + uint8_t *revid); SR_PRIV int command_start_acquisition(libusb_device_handle *devhdl, uint64_t samplerate); diff --git a/hardware/fx2lafw/fx2lafw.c b/hardware/fx2lafw/fx2lafw.c index 4fc5744d..11b43f08 100644 --- a/hardware/fx2lafw/fx2lafw.c +++ b/hardware/fx2lafw/fx2lafw.c @@ -175,6 +175,7 @@ static int fx2lafw_dev_open(int dev_index) struct context *ctx; struct version_info vi; int ret, skip, i; + uint8_t revid; if (!(sdi = sr_dev_inst_get(dev_insts, dev_index))) return SR_ERR; @@ -239,19 +240,25 @@ static int fx2lafw_dev_open(int dev_index) break; } + ret = command_get_revid_version(ctx->usb->devhdl, &revid); + if (ret != SR_OK) { + sr_err("fx2lafw: Failed to retrieve REVID."); + break; + } + if (vi.major != FX2LAFW_VERSION_MAJOR || vi.minor != FX2LAFW_VERSION_MINOR) { - sr_err("fx2lafw: Expected firmware version %d.%02d " - "got %d.%02d.", FX2LAFW_VERSION_MAJOR, + sr_err("fx2lafw: Expected firmware version %d.%d " + "got %d.%d.", FX2LAFW_VERSION_MAJOR, FX2LAFW_VERSION_MINOR, vi.major, vi.minor); break; } sdi->status = SR_ST_ACTIVE; sr_info("fx2lafw: Opened device %d on %d.%d " - "interface %d, firmware version %d.%02d", + "interface %d, firmware %d.%d, REVID %d.", sdi->index, ctx->usb->bus, ctx->usb->address, - USB_INTERFACE, vi.major, vi.minor); + USB_INTERFACE, vi.major, vi.minor, revid); break; }