From: poljar (Damir Jelić) Date: Thu, 16 Jan 2014 14:28:50 +0000 (+0100) Subject: hameg-hmo: Handle floating point numbers while ignoring the locale. X-Git-Tag: libsigrok-0.3.0~272 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=965b463d9825c2a72a3a1cfcc10e1a23ccc768aa;p=libsigrok.git hameg-hmo: Handle floating point numbers while ignoring the locale. --- diff --git a/hardware/hameg-hmo/api.c b/hardware/hameg-hmo/api.c index bf3b868c..0877d235 100644 --- a/hardware/hameg-hmo/api.c +++ b/hardware/hameg-hmo/api.c @@ -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; diff --git a/hardware/hameg-hmo/protocol.c b/hardware/hameg-hmo/protocol.c index 9d5e1773..2f7f5ab4 100644 --- a/hardware/hameg-hmo/protocol.c +++ b/hardware/hameg-hmo/protocol.c @@ -22,12 +22,12 @@ 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?",