This patch fixes the logic calculating the trigger position as well as the
(hopefully) last remaining locale issue.
---
 hardware/hameg-hmo/api.c      | 10 ++++++++--
 hardware/hameg-hmo/protocol.c | 11 ++++++++---
 2 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/hardware/hameg-hmo/api.c b/hardware/hameg-hmo/api.c
index b82d2a3..eeccf7c 100644
--- a/hardware/hameg-hmo/api.c
+++ b/hardware/hameg-hmo/api.c
@@ -400,10 +400,16 @@ static int config_set(int key, GVariant *data, const 
struct sr_dev_inst *sdi,
                if (tmp_d < 0.0 || tmp_d > 1.0)
                        return SR_ERR;
 
-               state->horiz_triggerpos = -(tmp_d - 0.5) * state->timebase * 
model->num_xdivs;
+               state->horiz_triggerpos = tmp_d;
+               tmp_d = -(tmp_d - 0.5) *
+                       ((double) (*model->timebases)[state->timebase][0] /
+                       (*model->timebases)[state->timebase][1])
+                        * model->num_xdivs;
+
+               g_ascii_formatd(float_str, sizeof(float_str), "%E", tmp_d);
                g_snprintf(command, sizeof(command),
                           
(*model->scpi_dialect)[SCPI_CMD_SET_HORIZ_TRIGGERPOS],
-                          state->horiz_triggerpos);
+                          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 ff9cf29..60443b8 100644
--- a/hardware/hameg-hmo/protocol.c
+++ b/hardware/hameg-hmo/protocol.c
@@ -40,7 +40,7 @@ static const char *hameg_scpi_dialect[] = {
        [SCPI_CMD_SET_DIG_CHAN_STATE]       = ":LOG%d:STAT %d",
        [SCPI_CMD_GET_VERTICAL_OFFSET]      = ":CHAN%d:POS?",
        [SCPI_CMD_GET_HORIZ_TRIGGERPOS]     = ":TIM:POS?",
-       [SCPI_CMD_SET_HORIZ_TRIGGERPOS]     = ":TIM:POS %E",
+       [SCPI_CMD_SET_HORIZ_TRIGGERPOS]     = ":TIM:POS %s",
        [SCPI_CMD_GET_ANALOG_CHAN_STATE]    = ":CHAN%d:STAT?",
        [SCPI_CMD_SET_ANALOG_CHAN_STATE]    = ":CHAN%d:STAT %d",
 };
@@ -291,7 +291,7 @@ static void scope_state_dump(struct scope_config *config,
        sr_info("Current samplerate: %s", tmp);
        g_free(tmp);
 
-       sr_info("Current trigger: %s (source), %s (slope) %2.2e (offset)",
+       sr_info("Current trigger: %s (source), %s (slope) %.2f (offset)",
                (*config->trigger_sources)[state->trigger_source],
                (*config->trigger_slopes)[state->trigger_slope],
                state->horiz_triggerpos);
@@ -507,8 +507,13 @@ SR_PRIV int hmo_scope_state_get(struct sr_dev_inst *sdi)
 
        if (sr_scpi_get_float(sdi->conn,
                        (*config->scpi_dialect)[SCPI_CMD_GET_HORIZ_TRIGGERPOS],
-                       &state->horiz_triggerpos) != SR_OK)
+                       &tmp_float) != SR_OK)
                return SR_ERR;
+       state->horiz_triggerpos = tmp_float /
+               (((double) (*config->timebases)[state->timebase][0] /
+                 (*config->timebases)[state->timebase][1]) * 
config->num_xdivs);
+       state->horiz_triggerpos -= 0.5;
+       state->horiz_triggerpos *= -1;
 
        if (scope_state_get_array_option(sdi->conn,
                        (*config->scpi_dialect)[SCPI_CMD_GET_TRIGGER_SOURCE],
-- 
1.9.1


------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
sigrok-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sigrok-devel

Reply via email to