]> sigrok.org Git - libsigrok.git/commitdiff
hameg-hmo: Handle floating point numbers while ignoring the locale.
authorpoljar (Damir Jelić) <redacted>
Thu, 16 Jan 2014 14:28:50 +0000 (15:28 +0100)
committerBert Vermeulen <redacted>
Thu, 16 Jan 2014 15:27:35 +0000 (16:27 +0100)
hardware/hameg-hmo/api.c
hardware/hameg-hmo/protocol.c

index bf3b868c0828610ce900f108607e1f01f664654f..0877d235719292efaf7561e97950b874c4fe1133 100644 (file)
@@ -474,7 +474,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;
@@ -528,9 +528,10 @@ static int config_set(int key, GVariant *data, const struct sr_dev_inst *sdi,
                                if (probe_group != &devc->analog_groups[j - 1])
                                        continue;
                                state->analog_channels[j - 1].vdiv = (float) p / q;
+                               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)
@@ -551,9 +552,10 @@ static int config_set(int key, GVariant *data, const struct sr_dev_inst *sdi,
                            q != (*model->timebases)[i][1])
                                continue;
                        state->timebase = (float) p / q;
+                       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;
index 9d5e17738a6d750d1d2ff1eeb9fb3f322b7689b7..2f7f5ab43999c1dc987b9c0972aba522477efdb6 100644 (file)
 static const char *hameg_scpi_dialect[] = {
        [SCPI_CMD_GET_DIG_DATA]             = ":POD%d:DATA?",
        [SCPI_CMD_GET_TIMEBASE]             = ":TIM:SCAL?",
-       [SCPI_CMD_SET_TIMEBASE]             = ":TIM:SCAL %E",
+       [SCPI_CMD_SET_TIMEBASE]             = ":TIM:SCAL %s",
        [SCPI_CMD_GET_COUPLING]             = ":CHAN%d:COUP?",
        [SCPI_CMD_SET_COUPLING]             = ":CHAN%d:COUP %s",
        [SCPI_CMD_GET_ANALOG_DATA]          = ":CHAN%d:DATA?",
        [SCPI_CMD_GET_VERTICAL_DIV]         = ":CHAN%d:SCAL?",
-       [SCPI_CMD_SET_VERTICAL_DIV]         = ":CHAN%d:SCAL %E",
+       [SCPI_CMD_SET_VERTICAL_DIV]         = ":CHAN%d:SCAL %s",
        [SCPI_CMD_GET_DIG_POD_STATE]        = ":POD%d:STAT?",
        [SCPI_CMD_SET_DIG_POD_STATE]        = ":POD%d:STAT %d",
        [SCPI_CMD_GET_TRIGGER_SLOPE]        = ":TRIG:A:EDGE:SLOP?",