From: marchelh Date: Sun, 25 Feb 2018 08:28:39 +0000 (+0100) Subject: siglent-sds: Added trigger position to device config code X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=fdf0744fa4b40adab32e8f10d84df784284c67cc;p=libsigrok.git siglent-sds: Added trigger position to device config code --- diff --git a/src/hardware/siglent-sds/protocol.c b/src/hardware/siglent-sds/protocol.c index 80e1bb82..64d26ce3 100644 --- a/src/hardware/siglent-sds/protocol.c +++ b/src/hardware/siglent-sds/protocol.c @@ -487,6 +487,8 @@ SR_PRIV int siglent_sds_get_dev_cfg(const struct sr_dev_inst *sdi) unsigned int i; int res, num_tokens; gchar **tokens; + int len; + float trigger_pos; devc = sdi->priv; @@ -590,9 +592,27 @@ SR_PRIV int siglent_sds_get_dev_cfg(const struct sr_dev_inst *sdi) sr_dbg("Current trigger source: %s.", devc->trigger_source); /* TODO: Horizontal trigger position. */ - - devc->horiz_triggerpos = 0; - sr_dbg("Current horizontal trigger position: %g.", devc->horiz_triggerpos); + response = ""; + trigger_pos = 0; + if (sr_scpi_get_string(sdi->conn, g_strdup_printf("%s:TRDL?", devc->trigger_source), &response) != SR_OK) + return SR_ERR; + len = strlen(response); + if (!g_ascii_strcasecmp(response + (len - 2), "us")) { + trigger_pos = atof(response) / SR_GHZ(1); + sr_dbg("Current trigger position us %s.", response); + } else if (!g_ascii_strcasecmp(response + (len - 2), "ns")) { + trigger_pos = atof(response) / SR_MHZ(1); + sr_dbg("Current trigger position ms %s.", response); + } else if (!g_ascii_strcasecmp(response + (len - 2), "ms")) { + trigger_pos = atof(response) / SR_KHZ(1); + sr_dbg("Current trigger position ns %s.", response); + } else if (!g_ascii_strcasecmp(response + (len - 2), "s")) { + trigger_pos = atof(response); + sr_dbg("Current trigger position s %s.", response); + }; + devc->horiz_triggerpos = trigger_pos; + + sr_dbg("Current horizontal trigger position %.10f", devc->horiz_triggerpos); /* Trigger slope. */ cmd = g_strdup_printf("%s:TRSL?", devc->trigger_source);