]> sigrok.org Git - libsigrok.git/blobdiff - hardware/link-mso19/link-mso19.c
Move the probe naming to the creator of the device, and let each driver name its...
[libsigrok.git] / hardware / link-mso19 / link-mso19.c
index efafb0a314a876ca8cf02ce7b2dcb39363c9722a..30bda395fc848a28b585aa9b376c608096b6952d 100644 (file)
 #include <inttypes.h>
 #include <glib.h>
 #include <libudev.h>
-#include <sigrok.h>
 #include <arpa/inet.h>
-#include <sigrok-internal.h>
+#include "sigrok.h"
+#include "sigrok-internal.h"
 #include "config.h"
 #include "link-mso19.h"
 
 #define USB_VENDOR "3195"
 #define USB_PRODUCT "f190"
 
+#define NUM_PROBES 8
+
 static int capabilities[] = {
        SR_HWCAP_LOGIC_ANALYZER,
 //     SR_HWCAP_OSCILLOSCOPE,
@@ -46,6 +48,18 @@ static int capabilities[] = {
        0,
 };
 
+static const char *probe_names[NUM_PROBES + 1] = {
+       "0",
+       "1",
+       "2",
+       "3",
+       "4",
+       "5",
+       "6",
+       "7",
+       NULL,
+};
+
 static uint64_t supported_samplerates[] = {
        SR_HZ(100),
        SR_HZ(200),
@@ -539,18 +553,23 @@ static int hw_opendev(int device_index)
        return SR_OK;
 }
 
-static void hw_closedev(int device_index)
+static int hw_closedev(int device_index)
 {
        struct sr_device_instance *sdi;
 
-       if (!(sdi = sr_get_device_instance(device_instances, device_index)))
-               return;
+       if (!(sdi = sr_get_device_instance(device_instances, device_index))) {
+               sr_err("mso19: %s: sdi was NULL", __func__);
+               return SR_ERR; /* TODO: SR_ERR_ARG? */
+       }
 
+       /* TODO */
        if (sdi->serial->fd != -1) {
                serial_close(sdi->serial->fd);
                sdi->serial->fd = -1;
                sdi->status = SR_ST_INACTIVE;
        }
+
+       return SR_OK;
 }
 
 static void *hw_get_device_info(int device_index, int device_info_id)
@@ -568,7 +587,10 @@ static void *hw_get_device_info(int device_index, int device_info_id)
                info = sdi;
                break;
        case SR_DI_NUM_PROBES: /* FIXME: How to report analog probe? */
-               info = GINT_TO_POINTER(8);
+               info = GINT_TO_POINTER(NUM_PROBES);
+               break;
+       case SR_DI_PROBE_NAMES: 
+               info = probe_names;
                break;
        case SR_DI_SAMPLERATES:
                info = &samplerates;
@@ -779,8 +801,8 @@ struct sr_device_plugin link_mso19_plugin_info = {
        .api_version = 1,
        .init = hw_init,
        .cleanup = hw_cleanup,
-       .open = hw_opendev,
-       .close = hw_closedev,
+       .opendev = hw_opendev,
+       .closedev = hw_closedev,
        .get_device_info = hw_get_device_info,
        .get_status = hw_get_status,
        .get_capabilities = hw_get_capabilities,