]> sigrok.org Git - libsigrok.git/commitdiff
siglent-sds: Added trigger position to device config code
authormarchelh <redacted>
Sun, 25 Feb 2018 08:28:39 +0000 (09:28 +0100)
committerUwe Hermann <redacted>
Sat, 3 Mar 2018 16:46:15 +0000 (17:46 +0100)
src/hardware/siglent-sds/protocol.c

index 80e1bb82fec6bfb2d9af4bc4b9e207a0a09a9446..64d26ce378e1be47a85535b99623e239071a329a 100644 (file)
@@ -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);