]> sigrok.org Git - libsigrok.git/commitdiff
hameg-hmo: Beautify trigger pattern.
authorGuido Trentalancia <redacted>
Tue, 20 Nov 2018 18:35:33 +0000 (19:35 +0100)
committerUwe Hermann <redacted>
Thu, 25 Jul 2019 22:55:40 +0000 (00:55 +0200)
Beautify the trigger pattern by removing the quotes from the SCPI response
using sr_scpi_unquote_string() and improve the string pattern handling.

src/hardware/hameg-hmo/api.c
src/hardware/hameg-hmo/protocol.c
src/hardware/hameg-hmo/protocol.h

index 27fbc6a65df2037a5f8b006e9ad5c48b8235f777..9ae139b9d3acc44d92c16144b03cb18108fd1c2f 100644 (file)
@@ -379,8 +379,9 @@ static int config_set(uint32_t key, GVariant *data,
                if (sr_scpi_send(sdi->conn, command) != SR_OK ||
                    sr_scpi_get_opc(sdi->conn) != SR_OK)
                        return SR_ERR;
-               g_free(state->trigger_pattern);
-               state->trigger_pattern = g_strdup(tmp_str);
+               strncpy(state->trigger_pattern,
+                       tmp_str,
+                       MAX_ANALOG_CHANNEL_COUNT + MAX_DIGITAL_CHANNEL_COUNT);
                ret = SR_OK;
                break;
        case SR_CONF_COUPLING:
index e6e73e4b8c7392bfb8b4fa364311f5d09196ef5d..2806352bf157308818890a2a3fe7cc18e8c0ed1a 100644 (file)
@@ -1129,8 +1129,12 @@ SR_PRIV int hmo_scope_state_get(struct sr_dev_inst *sdi)
 
        if (sr_scpi_get_string(sdi->conn,
                               (*config->scpi_dialect)[SCPI_CMD_GET_TRIGGER_PATTERN],
-                              &state->trigger_pattern) != SR_OK)
+                              &tmp_str) != SR_OK)
                return SR_ERR;
+       strncpy(state->trigger_pattern,
+               sr_scpi_unquote_string(tmp_str),
+               MAX_ANALOG_CHANNEL_COUNT + MAX_DIGITAL_CHANNEL_COUNT);
+       g_free(tmp_str);
 
        if (hmo_update_sample_rate(sdi) != SR_OK)
                return SR_ERR;
index d169311b2eec7d9cd5ca498dd0d3892c5856b670..30efc8626ab9fb94da75a63fd33200a82204668a 100644 (file)
@@ -104,7 +104,7 @@ struct scope_state {
 
        int trigger_source;
        int trigger_slope;
-       char *trigger_pattern;
+       char trigger_pattern[MAX_ANALOG_CHANNEL_COUNT + MAX_DIGITAL_CHANNEL_COUNT];
 
        uint64_t sample_rate;
 };