]> sigrok.org Git - libsigrok.git/blobdiff - hardware/fx2lafw/fx2lafw.c
sr: change all drivers to use SR_DF_META_LOGIC
[libsigrok.git] / hardware / fx2lafw / fx2lafw.c
index 3762bde6a0af83b947c660086aa1b71c7753cb5e..0f839b57ca6f228d2a550a93c013da6656514914 100644 (file)
@@ -251,11 +251,15 @@ static int fx2lafw_dev_open(int dev_index)
                        break;
                }
 
-               if (vi.major != FX2LAFW_VERSION_MAJOR ||
-                   vi.minor != FX2LAFW_VERSION_MINOR) {
-                       sr_err("fx2lafw: Expected firmware version %d.%d "
-                              "got %d.%d.", FX2LAFW_VERSION_MAJOR,
-                              FX2LAFW_VERSION_MINOR, vi.major, vi.minor);
+               /*
+                * Changes in major version mean incompatible/API changes, so
+                * bail out if we encounter an incompatible version.
+                * Different minor versions are OK, they should be compatible.
+                */
+               if (vi.major != FX2LAFW_REQUIRED_VERSION_MAJOR) {
+                       sr_err("fx2lafw: Expected firmware version %d.x, "
+                              "got %d.%d.", FX2LAFW_REQUIRED_VERSION_MAJOR,
+                              vi.major, vi.minor);
                        break;
                }
 
@@ -373,7 +377,7 @@ static int hw_init(const char *devinfo)
                return 0;
        }
 
-       /* Find all fx2lafw compatible devices and upload firware to them. */
+       /* Find all fx2lafw compatible devices and upload firmware to them. */
        libusb_get_device_list(usb_context, &devlist);
        for (i = 0; devlist[i]; i++) {
 
@@ -790,6 +794,7 @@ static int hw_dev_acquisition_start(int dev_index, void *cb_data)
        struct sr_dev_inst *sdi;
        struct sr_datafeed_packet *packet;
        struct sr_datafeed_header *header;
+       struct sr_datafeed_meta_logic meta;
        struct context *ctx;
        struct libusb_transfer *transfer;
        const struct libusb_pollfd **lupfd;
@@ -844,9 +849,15 @@ static int hw_dev_acquisition_start(int dev_index, void *cb_data)
        packet->payload = header;
        header->feed_version = 1;
        gettimeofday(&header->starttime, NULL);
-       header->samplerate = ctx->cur_samplerate;
-       header->num_logic_probes = ctx->profile->num_probes;
        sr_session_send(cb_data, packet);
+
+       /* Send metadata about the SR_DF_LOGIC packets to come. */
+       packet->type = SR_DF_META_LOGIC;
+       packet->payload = &meta;
+       meta.samplerate = ctx->cur_samplerate;
+       meta.num_probes = ctx->profile->num_probes;
+       sr_session_send(cb_data, packet);
+
        g_free(header);
        g_free(packet);