]> sigrok.org Git - libsigrok.git/blobdiff - hardware/hameg-hmo/api.c
hameg-hmo: Change the way vdiv and timebase are saved.
[libsigrok.git] / hardware / hameg-hmo / api.c
index ee7c74430b2ceb9ce63a2650b93918daa2cebaf4..33800c7345867024b467d7fbe9a7e2453720af19 100644 (file)
@@ -217,7 +217,7 @@ static struct sr_dev_inst *hmo_probe_serial_device(const char *serial_device,
        scpi = NULL;
        hw_info = NULL;
 
-       if (!(scpi = scpi_serial_dev_inst_new(serial_device, serial_options)))
+       if (!(scpi = scpi_dev_inst_new(serial_device, serial_options)))
                goto fail;
 
        sr_info("Probing %s.", serial_device);
@@ -251,6 +251,10 @@ static struct sr_dev_inst *hmo_probe_serial_device(const char *serial_device,
        if (hmo_init_device(sdi) != SR_OK)
                goto fail;
 
+       sr_scpi_close(sdi->conn);
+
+       sdi->status = SR_ST_INACTIVE;
+
        return sdi;
 
 fail:
@@ -474,7 +478,7 @@ static int config_set(int key, GVariant *data, const struct sr_dev_inst *sdi,
 {
        int ret, pg_type;
        unsigned int i, j;
-       char command[MAX_COMMAND_SIZE];
+       char command[MAX_COMMAND_SIZE], float_str[30];
        struct dev_context *devc;
        struct scope_config *model;
        struct scope_state *state;
@@ -527,10 +531,11 @@ static int config_set(int key, GVariant *data, const struct sr_dev_inst *sdi,
                        for (j = 1; j <= model->analog_channels; ++j) {
                                if (probe_group != &devc->analog_groups[j - 1])
                                        continue;
-                               state->analog_channels[j - 1].vdiv = (float) p / q;
+                               state->analog_channels[j - 1].vdiv = i;
+                               g_ascii_formatd(float_str, sizeof(float_str), "%E", (float) p / q);
                                g_snprintf(command, sizeof(command),
                                           (*model->scpi_dialect)[SCPI_CMD_SET_VERTICAL_DIV],
-                                          j, state->analog_channels[j-1].vdiv);
+                                          j, float_str);
 
                                if (sr_scpi_send(sdi->conn, command) != SR_OK ||
                                    sr_scpi_get_opc(sdi->conn) != SR_OK)
@@ -550,10 +555,11 @@ static int config_set(int key, GVariant *data, const struct sr_dev_inst *sdi,
                        if (p != (*model->timebases)[i][0] ||
                            q != (*model->timebases)[i][1])
                                continue;
-                       state->timebase = (float) p / q;
+                       state->timebase = i;
+                       g_ascii_formatd(float_str, sizeof(float_str), "%E", (float) p / q);
                        g_snprintf(command, sizeof(command),
                                   (*model->scpi_dialect)[SCPI_CMD_SET_TIMEBASE],
-                                  state->timebase);
+                                  float_str);
 
                        ret = sr_scpi_send(sdi->conn, command);
                        break;
@@ -876,9 +882,14 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
 {
        struct dev_context *devc;
        struct sr_scpi_dev_inst *scpi;
+       struct sr_datafeed_packet packet;
 
        (void)cb_data;
 
+       packet.type = SR_DF_END;
+       packet.payload = NULL;
+       sr_session_send(sdi, &packet);
+
        if (sdi->status != SR_ST_ACTIVE)
                return SR_ERR_DEV_CLOSED;