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.
This commit is contained in:
Guido Trentalancia 2018-11-20 19:35:33 +01:00 committed by Uwe Hermann
parent a058de0410
commit 396af5ad7d
3 changed files with 9 additions and 4 deletions

View 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:

View 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;

View 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;
};