]> sigrok.org Git - libsigrok.git/blobdiff - hardware/link-mso19/link-mso19.c
link-mso19: Updated to the current structs (fixed compilation).
[libsigrok.git] / hardware / link-mso19 / link-mso19.c
index 63b910318615002dfc653225232898ce5e50e464..fdcc0a48da48837a3dac14cde01a73164c014e29 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),
@@ -573,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;
@@ -634,6 +651,7 @@ static int receive_data(int fd, int revents, void *user_data)
        struct sr_device_instance *sdi = user_data;
        struct mso *mso = sdi->priv;
        struct sr_datafeed_packet packet;
+       struct sr_datafeed_logic logic;
        uint8_t in[1024], logic_out[1024];
        double analog_out[1024];
        size_t i, s;
@@ -674,17 +692,20 @@ static int receive_data(int fd, int revents, void *user_data)
        }
 
        packet.type = SR_DF_LOGIC;
-       packet.length = 1024;
-       packet.unitsize = 1;
-       packet.payload = logic_out;
+        packet.payload = &logic;
+       logic.length = 1024;
+       logic.unitsize = 1;
+       logic.data = logic_out;
        sr_session_bus(mso->session_id, &packet);
 
 
+        // Dont bother fixing this yet, keep it "old style"
+        /*
        packet.type = SR_DF_ANALOG;
        packet.length = 1024;
        packet.unitsize = sizeof(double);
        packet.payload = analog_out;
-       sr_session_bus(mso->session_id, &packet);
+       sr_session_bus(mso->session_id, &packet); */
 
        packet.type = SR_DF_END;
        sr_session_bus(mso->session_id, &packet);
@@ -754,14 +775,12 @@ static int hw_start_acquisition(int device_index, gpointer session_device_id)
        sr_source_add(sdi->serial->fd, G_IO_IN, -1, receive_data, sdi);
 
        packet.type = SR_DF_HEADER;
-       packet.length = sizeof(struct sr_datafeed_header);
        packet.payload = (unsigned char *) &header;
        header.feed_version = 1;
        gettimeofday(&header.starttime, NULL);
        header.samplerate = mso->cur_rate;
        header.num_analog_probes = 1;
        header.num_logic_probes = 8;
-       header.protocol_id = SR_PROTO_RAW;
        sr_session_bus(session_device_id, &packet);
 
        return ret;