]> sigrok.org Git - libsigrok.git/blobdiff - hardware/zeroplus-logic-cube/zeroplus.c
sr: Fix handling of virtual devices.
[libsigrok.git] / hardware / zeroplus-logic-cube / zeroplus.c
index c3a1f9224360865976f446e70e7d9ca9b5845a07..f51f918311d445f32c8036af9fb2178f3bf7d1e4 100644 (file)
@@ -74,39 +74,27 @@ static int hwcaps[] = {
        0,
 };
 
+/*
+ * ZEROPLUS LAP-C (16032) numbers the 16 probes A0-A7 and B0-B7.
+ * We currently ignore other untested/unsupported devices here.
+ */
 static const char *probe_names[] = {
-       "0",
-       "1",
-       "2",
-       "3",
-       "4",
-       "5",
-       "6",
-       "7",
-       "8",
-       "9",
-       "10",
-       "11",
-       "12",
-       "13",
-       "14",
-       "15",
-       "16",
-       "17",
-       "18",
-       "19",
-       "20",
-       "21",
-       "22",
-       "23",
-       "24",
-       "25",
-       "26",
-       "27",
-       "28",
-       "29",
-       "30",
-       "31",
+       "A0",
+       "A1",
+       "A2",
+       "A3",
+       "A4",
+       "A5",
+       "A6",
+       "A7",
+       "B0",
+       "B1",
+       "B2",
+       "B3",
+       "B4",
+       "B5",
+       "B6",
+       "B7",
        NULL,
 };
 
@@ -245,7 +233,7 @@ static struct sr_dev_inst *zp_open_dev(int dev_index)
        struct sr_dev_inst *sdi;
        libusb_device **devlist;
        struct libusb_device_descriptor des;
-       int err, i;
+       int i;
 
        if (!(sdi = sr_dev_inst_get(dev_insts, dev_index)))
                return NULL;
@@ -256,7 +244,7 @@ static struct sr_dev_inst *zp_open_dev(int dev_index)
                libusb_get_device_list(usb_context, &devlist);
                for (i = 0; devlist[i]; i++) {
                        /* TODO: Error handling. */
-                       err = opendev4(&sdi, devlist[i], &des);
+                       opendev4(&sdi, devlist[i], &des);
                }
        } else {
                /* Status must be SR_ST_ACTIVE, i.e. already in use... */
@@ -625,7 +613,7 @@ static int hw_dev_config_set(int dev_index, int hwcap, void *value)
        }
 }
 
-static int hw_dev_acquisition_start(int dev_index, gpointer session_data)
+static int hw_dev_acquisition_start(int dev_index, void *cb_data)
 {
        struct sr_dev_inst *sdi;
        struct sr_datafeed_packet packet;
@@ -667,7 +655,7 @@ static int hw_dev_acquisition_start(int dev_index, gpointer session_data)
        gettimeofday(&header.starttime, NULL);
        header.samplerate = ctx->cur_samplerate;
        header.num_logic_probes = ctx->num_channels;
-       sr_session_bus(session_data, &packet);
+       sr_session_send(cb_data, &packet);
 
        if (!(buf = g_try_malloc(PACKET_SIZE))) {
                sr_err("zp: %s: buf malloc failed", __func__);
@@ -688,27 +676,27 @@ static int hw_dev_acquisition_start(int dev_index, gpointer session_data)
                logic.length = PACKET_SIZE;
                logic.unitsize = 4;
                logic.data = buf;
-               sr_session_bus(session_data, &packet);
+               sr_session_send(cb_data, &packet);
                samples_read += res / 4;
        }
        analyzer_read_stop(ctx->usb->devhdl);
        g_free(buf);
 
        packet.type = SR_DF_END;
-       sr_session_bus(session_data, &packet);
+       sr_session_send(cb_data, &packet);
 
        return SR_OK;
 }
 
-/* This stops acquisition on ALL devices, ignoring dev_index. */
-static int hw_dev_acquisition_stop(int dev_index, gpointer session_dev_id)
+/* TODO: This stops acquisition on ALL devices, ignoring dev_index. */
+static int hw_dev_acquisition_stop(int dev_index, void *cb_data)
 {
        struct sr_datafeed_packet packet;
        struct sr_dev_inst *sdi;
        struct context *ctx;
 
        packet.type = SR_DF_END;
-       sr_session_bus(session_dev_id, &packet);
+       sr_session_send(cb_data, &packet);
 
        if (!(sdi = sr_dev_inst_get(dev_insts, dev_index))) {
                sr_err("zp: %s: sdi was NULL", __func__);
@@ -726,7 +714,7 @@ static int hw_dev_acquisition_stop(int dev_index, gpointer session_dev_id)
        return SR_OK;
 }
 
-SR_PRIV struct sr_dev_plugin zeroplus_logic_cube_plugin_info = {
+SR_PRIV struct sr_dev_driver zeroplus_logic_cube_driver_info = {
        .name = "zeroplus-logic-cube",
        .longname = "Zeroplus Logic Cube LAP-C series",
        .api_version = 1,