From: Guido Trentalancia Date: Tue, 20 Nov 2018 18:35:33 +0000 (+0100) Subject: hameg-hmo: Beautify trigger pattern. X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=396af5ad7d607085ba597b2318769127df58799e;p=libsigrok.git hameg-hmo: Beautify trigger pattern. Beautify the trigger pattern by removing the quotes from the SCPI response using sr_scpi_unquote_string() and improve the string pattern handling. --- diff --git a/src/hardware/hameg-hmo/api.c b/src/hardware/hameg-hmo/api.c index 27fbc6a6..9ae139b9 100644 --- a/src/hardware/hameg-hmo/api.c +++ b/src/hardware/hameg-hmo/api.c @@ -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: diff --git a/src/hardware/hameg-hmo/protocol.c b/src/hardware/hameg-hmo/protocol.c index e6e73e4b..2806352b 100644 --- a/src/hardware/hameg-hmo/protocol.c +++ b/src/hardware/hameg-hmo/protocol.c @@ -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; diff --git a/src/hardware/hameg-hmo/protocol.h b/src/hardware/hameg-hmo/protocol.h index d169311b..30efc862 100644 --- a/src/hardware/hameg-hmo/protocol.h +++ b/src/hardware/hameg-hmo/protocol.h @@ -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; };