]> sigrok.org Git - libsigrok.git/blobdiff - hardware/rigol-ds/protocol.c
rigol-ds: Update which channels are enabled after making changes.
[libsigrok.git] / hardware / rigol-ds / protocol.c
index 9952e2a41517b0865e0b458ea3a324002e25d80f..1d2302f60c4bb949a99b7d9e0ea6b27e855fc7db 100644 (file)
@@ -182,8 +182,7 @@ static int rigol_ds_trigger_wait(const struct sr_dev_inst *sdi)
         * If timebase < 50 msecs/DIV just sleep about one sweep time except
         * for really fast sweeps.
         */
-       if (devc->timebase < 0.0499)
-       {
+       if (devc->timebase < 0.0499) {
                if (devc->timebase > 0.99e-6) {
                        /*
                         * Timebase * num hor. divs * 85(%) * 1e6(usecs) / 100
@@ -370,13 +369,11 @@ static int rigol_ds_read_header(struct sr_scpi_dev_inst *scpi)
        /* Read the hashsign and length digit. */
        tmp = sr_scpi_read_data(scpi, start, 2);
        start[2] = '\0';
-       if (tmp != 2)
-       {
+       if (tmp != 2) {
                sr_err("Failed to read first two bytes of data block header.");
                return -1;
        }
-       if (start[0] != '#' || !isdigit(start[1]) || start[1] == '0')
-       {
+       if (start[0] != '#' || !isdigit(start[1]) || start[1] == '0') {
                sr_err("Received invalid data block header start '%s'.", start);
                return -1;
        }
@@ -385,13 +382,11 @@ static int rigol_ds_read_header(struct sr_scpi_dev_inst *scpi)
        /* Read the data length. */
        tmp = sr_scpi_read_data(scpi, length, len);
        length[len] = '\0';
-       if (tmp != len)
-       {
+       if (tmp != len) {
                sr_err("Failed to read %d bytes of data block length.", len);
                return -1;
        }
-       if (parse_int(length, &len) != SR_OK)
-       {
+       if (parse_int(length, &len) != SR_OK) {
                sr_err("Received invalid data block length '%s'.", length);
                return -1;
        }
@@ -425,22 +420,19 @@ SR_PRIV int rigol_ds_receive(int fd, int revents, void *cb_data)
 
        if (revents == G_IO_IN || revents == 0) {
                if (devc->model->protocol == PROTOCOL_IEEE488_2) {
-                       switch(devc->wait_event) {
+                       switch (devc->wait_event) {
                        case WAIT_NONE:
                                break;
-
                        case WAIT_TRIGGER:
                                if (rigol_ds_trigger_wait(sdi) != SR_OK)
                                        return TRUE;
                                if (rigol_ds_channel_start(sdi) != SR_OK)
                                        return TRUE;
                                break;
-
                        case WAIT_BLOCK:
                                if (rigol_ds_block_wait(sdi) != SR_OK)
                                        return TRUE;
                                break;
-
                        case WAIT_STOP:
                                if (rigol_ds_stop_wait(sdi) != SR_OK)
                                        return TRUE;
@@ -449,7 +441,6 @@ SR_PRIV int rigol_ds_receive(int fd, int revents, void *cb_data)
                                if (rigol_ds_channel_start(sdi) != SR_OK)
                                        return TRUE;
                                return TRUE;
-
                        default:
                                sr_err("BUG: Unknown event target encountered");
                        }
@@ -590,9 +581,6 @@ SR_PRIV int rigol_ds_receive(int fd, int revents, void *cb_data)
                                devc->channel_entry = devc->enabled_digital_probes;
                                rigol_ds_channel_start(sdi);
                        } else if (++devc->num_frames == devc->limit_frames) {
-                               /* End of last frame. */
-                               packet.type = SR_DF_END;
-                               sr_session_send(sdi, &packet);
                                sdi->driver->dev_acquisition_stop(sdi, cb_data);
                        } else {
                                /* Get the next frame, starting with the first analog channel. */
@@ -700,16 +688,20 @@ SR_PRIV int rigol_ds_get_dev_cfg(const struct sr_dev_inst *sdi)
 
        /* Digital channel state. */
        if (devc->model->has_digital) {
-               sr_dbg("Current digital channel state:");
+               if (get_cfg_string(sdi, ":LA:DISP?", &t_s) != SR_OK)
+                       return SR_ERR;
+               devc->la_enabled = !strcmp(t_s, "ON") ? TRUE : FALSE;
+               sr_dbg("Logic analyzer %s, current digital channel state:",
+                               devc->la_enabled ? "enabled" : "disabled");
                for (i = 0; i < 16; i++) {
-                       cmd = g_strdup_printf(":DIG%d:TURN?", i + 1);
+                       cmd = g_strdup_printf(":DIG%d:TURN?", i);
                        res = get_cfg_string(sdi, cmd, &t_s);
                        g_free(cmd);
                        if (res != SR_OK)
                                return SR_ERR;
                        devc->digital_channels[i] = !strcmp(t_s, "ON") ? TRUE : FALSE;
                        g_free(t_s);
-                       sr_dbg("D%d: %s", i + 1, devc->digital_channels[i] ? "on" : "off");
+                       sr_dbg("D%d: %s", i, devc->digital_channels[i] ? "on" : "off");
                }
        }