]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/hameg-hmo/api.c
rigol-ds: Add initial Agilent MSO7034A support.
[libsigrok.git] / src / hardware / hameg-hmo / api.c
index ea2afef621867ed774703497f7588e961ee6b48e..8638a790bc56806954dfe017d8b44d7571e44d71 100644 (file)
@@ -509,6 +509,7 @@ static int hmo_setup_channels(const struct sr_dev_inst *sdi)
        struct sr_channel *ch;
        struct dev_context *devc;
        struct sr_scpi_dev_inst *scpi;
+       int ret;
 
        devc = sdi->priv;
        scpi = sdi->conn;
@@ -528,8 +529,10 @@ static int hmo_setup_channels(const struct sr_dev_inst *sdi)
                                   (*model->scpi_dialect)[SCPI_CMD_SET_ANALOG_CHAN_STATE],
                                   ch->index + 1, ch->enabled);
 
-                       if (sr_scpi_send(scpi, command) != SR_OK)
+                       if (sr_scpi_send(scpi, command) != SR_OK) {
+                               g_free(pod_enabled);
                                return SR_ERR;
+                       }
                        state->analog_channels[ch->index].state = ch->enabled;
                        setup_changed = TRUE;
                        break;
@@ -547,8 +550,10 @@ static int hmo_setup_channels(const struct sr_dev_inst *sdi)
                                   (*model->scpi_dialect)[SCPI_CMD_SET_DIG_CHAN_STATE],
                                   ch->index, ch->enabled);
 
-                       if (sr_scpi_send(scpi, command) != SR_OK)
+                       if (sr_scpi_send(scpi, command) != SR_OK) {
+                               g_free(pod_enabled);
                                return SR_ERR;
+                       }
 
                        state->digital_channels[ch->index] = ch->enabled;
                        setup_changed = TRUE;
@@ -559,19 +564,23 @@ static int hmo_setup_channels(const struct sr_dev_inst *sdi)
                }
        }
 
+       ret = SR_OK;
        for (i = 0; i < model->digital_pods; i++) {
                if (state->digital_pods[i] == pod_enabled[i])
                        continue;
                g_snprintf(command, sizeof(command),
                           (*model->scpi_dialect)[SCPI_CMD_SET_DIG_POD_STATE],
                           i + 1, pod_enabled[i]);
-               if (sr_scpi_send(scpi, command) != SR_OK)
-                       return SR_ERR;
+               if (sr_scpi_send(scpi, command) != SR_OK) {
+                       ret = SR_ERR;
+                       break;
+               }
                state->digital_pods[i] = pod_enabled[i];
                setup_changed = TRUE;
        }
-
        g_free(pod_enabled);
+       if (ret != SR_OK)
+               return ret;
 
        if (setup_changed && hmo_update_sample_rate(sdi) != SR_OK)
                return SR_ERR;