]> sigrok.org Git - libsigrok.git/blobdiff - hardware/asix-sigma/asix-sigma.c
probe names: Fix cosmetics, add docs, fix off-by-one.
[libsigrok.git] / hardware / asix-sigma / asix-sigma.c
index e7d6f7833103bd608a4a29344bbec7ec2ad9f4ea..723b2445f454a77cd7b1d4772d60b54a985996f8 100644 (file)
@@ -29,8 +29,8 @@
 #include <ftdi.h>
 #include <string.h>
 #include <zlib.h>
-#include <sigrok.h>
-#include <sigrok-internal.h>
+#include "sigrok.h"
+#include "sigrok-internal.h"
 #include "asix-sigma.h"
 
 #define USB_VENDOR                     0xa600
@@ -40,6 +40,7 @@
 #define USB_MODEL_NAME                 "SIGMA"
 #define USB_MODEL_VERSION              ""
 #define TRIGGER_TYPES                  "rf10"
+#define NUM_PROBES                     16
 
 static GSList *device_instances = NULL;
 
@@ -57,6 +58,26 @@ static uint64_t supported_samplerates[] = {
        0,
 };
 
+static const char *probe_names[NUM_PROBES + 1] = {
+       "0",
+       "1",
+       "2",
+       "3",
+       "4",
+       "5",
+       "6",
+       "7",
+       "8",
+       "9",
+       "10",
+       "11",
+       "12",
+       "13",
+       "14",
+       "15",
+       NULL,
+};
+
 static struct sr_samplerates samplerates = {
        SR_KHZ(200),
        SR_MHZ(200),
@@ -400,7 +421,7 @@ static int hw_init(const char *deviceinfo)
        struct sigma *sigma;
 
        /* Avoid compiler warnings. */
-       deviceinfo = deviceinfo;
+       (void)deviceinfo;
 
        if (!(sigma = g_try_malloc(sizeof(struct sigma)))) {
                sr_err("sigma: %s: sigma malloc failed", __func__);
@@ -724,7 +745,7 @@ static void *hw_get_device_info(int device_index, int device_info_id)
        void *info = NULL;
 
        if (!(sdi = sr_get_device_instance(device_instances, device_index))) {
-               fprintf(stderr, "It's NULL.\n");
+               sr_err("It's NULL.\n");
                return NULL;
        }
 
@@ -735,7 +756,10 @@ static void *hw_get_device_info(int device_index, int device_info_id)
                info = sdi;
                break;
        case SR_DI_NUM_PROBES:
-               info = GINT_TO_POINTER(16);
+               info = GINT_TO_POINTER(NUM_PROBES);
+               break;
+       case SR_DI_PROBE_NAMES:
+               info = probe_names;
                break;
        case SR_DI_SAMPLERATES:
                info = &samplerates;
@@ -997,8 +1021,9 @@ static int receive_data(int fd, int revents, void *session_data)
        uint64_t running_msec;
        struct timeval tv;
 
-       fd = fd;
-       revents = revents;
+       /* Avoid compiler warnings. */
+       (void)fd;
+       (void)revents;
 
        numchunks = (sigma->state.stoppos + 511) / 512;
 
@@ -1245,7 +1270,8 @@ static int hw_start_acquisition(int device_index, gpointer session_data)
        struct triggerinout triggerinout_conf;
        struct triggerlut lut;
 
-       session_data = session_data;
+       /* Avoid compiler warnings. */
+       (void)session_data;
 
        if (!(sdi = sr_get_device_instance(device_instances, device_index)))
                return SR_ERR;
@@ -1361,7 +1387,8 @@ static void hw_stop_acquisition(int device_index, gpointer session_data)
 
        sigma = sdi->priv;
 
-       session_data = session_data;
+       /* Avoid compiler warnings. */
+       (void)session_data;
 
        /* Stop acquisition. */
        sigma_set_register(WRITE_MODE, 0x11, sigma);