]> sigrok.org Git - libsigrok.git/blobdiff - hardware/fx2lafw/fx2lafw.c
sr: Made hwcap const
[libsigrok.git] / hardware / fx2lafw / fx2lafw.c
index 63a4f9f9b87847eb0c4d64bf06deb51fd1d2c77b..ccaf7d0d97bf4157f5e6ca991b31bf64c63c498f 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * This file is part of the sigrok project.
  *
+ * Copyright (C) 2010-2012 Bert Vermeulen <bert@biot.com>
  * Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
  *
  * This program is free software: you can redistribute it and/or modify
@@ -69,7 +70,7 @@ static const struct fx2lafw_profile supported_fx2[] = {
        { 0, 0, 0, 0, 0, 0, 0 }
 };
 
-static int hwcaps[] = {
+static const int hwcaps[] = {
        SR_HWCAP_LOGIC_ANALYZER,
        SR_HWCAP_SAMPLERATE,
 
@@ -250,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;
                }
 
@@ -372,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++) {
 
@@ -579,7 +584,7 @@ static int hw_dev_status_get(int dev_index)
        return sdi->status;
 }
 
-static int *hw_hwcap_get_all(void)
+static const int *hw_hwcap_get_all(void)
 {
        return hwcaps;
 }
@@ -789,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;
@@ -843,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);