]> sigrok.org Git - libsigrok.git/commitdiff
sr: fx2lafw: Get/display FX2 REVID.
authorUwe Hermann <redacted>
Sun, 6 May 2012 17:54:46 +0000 (19:54 +0200)
committerUwe Hermann <redacted>
Sun, 6 May 2012 17:54:46 +0000 (19:54 +0200)
hardware/fx2lafw/command.c
hardware/fx2lafw/command.h
hardware/fx2lafw/fx2lafw.c

index acf5a7f3a241547834782740049c1ffc6808803f..bb47d2d183676d6539df9aef4e417e5f453dcf5f 100644 (file)
@@ -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)
 {
index deacbecd0d4a23edba5981a598ec77cae1f1c77c..0ab3e85e26ce5ba303fd2cb28aebde82172b2fe5 100644 (file)
@@ -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);
 
index 4fc5744da84f5e6090841aa2c3bf7f2c8e2f2705..11b43f087bfd1c1d8c043479b4c9175224e51e75 100644 (file)
@@ -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;
        }