]> sigrok.org Git - libsigrok.git/commitdiff
rigol-ds: On DS1000 with firmware < 0.2.4, use legacy protocol.
authorBert Vermeulen <redacted>
Tue, 21 Jan 2014 11:54:24 +0000 (12:54 +0100)
committerBert Vermeulen <redacted>
Tue, 21 Jan 2014 12:05:06 +0000 (13:05 +0100)
Apparently the ASCII header containing length was only added in version
0.2.4.

hardware/rigol-ds/api.c
hardware/rigol-ds/protocol.c
hardware/rigol-ds/protocol.h

index 52c72a4451d9e798cddab38d9d62bde48dc0bec4..087cc9a53120d19937e59f0c0104811e8a9bd44d 100644 (file)
@@ -250,9 +250,10 @@ static int probe_port(const char *resource, const char *serialcomm, GSList **dev
        struct sr_scpi_dev_inst *scpi;
        struct sr_scpi_hw_info *hw_info;
        struct sr_probe *probe;
+       long n[3];
        unsigned int i;
        const struct rigol_ds_model *model = NULL;
-       gchar *channel_name, *vendor;
+       gchar *channel_name, *vendor, **version;
 
        *devices = NULL;
 
@@ -295,7 +296,6 @@ static int probe_port(const char *resource, const char *serialcomm, GSList **dev
                return SR_ERR_NA;
        }
 
-       sr_scpi_hw_info_free(hw_info);
        sr_scpi_close(scpi);
 
        sdi->conn = scpi;
@@ -308,6 +308,34 @@ static int probe_port(const char *resource, const char *serialcomm, GSList **dev
 
        devc->limit_frames = 0;
        devc->model = model;
+       devc->protocol = model->protocol;
+
+       /* DS1000 models with firmware before 0.2.4 used the old
+        * legacy protocol. */
+       if (model->series == RIGOL_DS1000) {
+               version = g_strsplit(hw_info->firmware_version, ".", 0);
+               do {
+                       if (!version[0] || !version[1] || !version[2])
+                               break;
+                       if (version[0][0] == 0 || version[1][0] == 0 || version[2][0] == 0)
+                               break;
+                       for (i = 0; i < 3; i++) {
+                               if (sr_atol(version[i], &n[i]) != SR_OK)
+                                       break;
+                       }
+                       if (i != 3)
+                               break;
+                       if (n[0] != 0 || n[1] > 2)
+                               break;
+                       if (n[1] == 2 && n[2] > 3)
+                               break;
+                       sr_dbg("Found DS1000 firmware < 0.2.4, using old protocol.");
+                       devc->protocol = PROTOCOL_LEGACY;
+               } while(0);
+               g_strfreev(version);
+       }
+
+       sr_scpi_hw_info_free(hw_info);
 
        for (i = 0; i < model->analog_channels; i++) {
                if (!(channel_name = g_strdup_printf("CH%d", i + 1)))
index 4f4ff412b015d7240b37c08ccb5fb30ffe346b02..446534b9966d7bcf948cbc54e7c6a1e3ebc4c443 100644 (file)
@@ -460,7 +460,7 @@ SR_PRIV int rigol_ds_receive(int fd, int revents, void *cb_data)
                        if (sr_scpi_read_begin(scpi) != SR_OK)
                                return TRUE;
 
-                       if (devc->model->protocol == PROTOCOL_IEEE488_2) {
+                       if (devc->protocol == PROTOCOL_IEEE488_2) {
                                sr_dbg("New block header expected");
                                len = rigol_ds_read_header(scpi);
                                if (len == -1)
@@ -529,7 +529,7 @@ SR_PRIV int rigol_ds_receive(int fd, int revents, void *cb_data)
                                /* Discard the terminating linefeed */
                                sr_scpi_read_data(scpi, (char *)devc->buffer, 1);
                        }
-                       if (devc->model->protocol == PROTOCOL_IEEE488_2) {
+                       if (devc->protocol == PROTOCOL_IEEE488_2) {
                                /* Prepare for possible next block */
                                devc->num_block_bytes = 0;
                                if (devc->data_source != DATA_SOURCE_LIVE)
index 121b3ea3f77dcd649e15390299962c74dabfe7c7..9c4c7f80e25443236cf7a828f11d2156f4237e5b 100644 (file)
@@ -93,6 +93,7 @@ enum wait_events {
 struct dev_context {
        /* Device model */
        const struct rigol_ds_model *model;
+       enum rigol_protocol_flavor protocol;
 
        /* Device properties */
        const uint64_t (*timebases)[2];