]> sigrok.org Git - libsigrok.git/commitdiff
hameg-hmo: Avoid bogus SCPI timeouts.
authorGuido Trentalancia <redacted>
Sat, 17 Nov 2018 21:20:29 +0000 (22:20 +0100)
committerUwe Hermann <redacted>
Thu, 25 Jul 2019 22:11:07 +0000 (00:11 +0200)
During the initial configuration phase of the hameg-hmo driver
only send an OPC command if a SCPI command has been previously
sent to the device so that bogus SCPI timeouts are avoided.

src/hardware/hameg-hmo/api.c

index 617c78d96838c0434ff0ce479912aec9790be0c0..71d3a986797b81a97ad6e490930c27c590de2d61 100644 (file)
@@ -288,7 +288,10 @@ static int config_set(uint32_t key, GVariant *data,
                g_snprintf(command, sizeof(command),
                           (*model->scpi_dialect)[SCPI_CMD_SET_TRIGGER_SOURCE],
                           (*model->trigger_sources)[idx]);
-               ret = sr_scpi_send(sdi->conn, command);
+               if (sr_scpi_send(sdi->conn, command) != SR_OK ||
+                   sr_scpi_get_opc(sdi->conn) != SR_OK)
+                       return SR_ERR;
+               ret = SR_OK;
                break;
        case SR_CONF_VDIV:
                if (!cg)
@@ -317,7 +320,10 @@ static int config_set(uint32_t key, GVariant *data,
                g_snprintf(command, sizeof(command),
                           (*model->scpi_dialect)[SCPI_CMD_SET_TIMEBASE],
                           float_str);
-               ret = sr_scpi_send(sdi->conn, command);
+               if (sr_scpi_send(sdi->conn, command) != SR_OK ||
+                   sr_scpi_get_opc(sdi->conn) != SR_OK)
+                       return SR_ERR;
+               ret = SR_OK;
                update_sample_rate = TRUE;
                break;
        case SR_CONF_HORIZ_TRIGGERPOS:
@@ -333,7 +339,10 @@ static int config_set(uint32_t key, GVariant *data,
                g_snprintf(command, sizeof(command),
                           (*model->scpi_dialect)[SCPI_CMD_SET_HORIZ_TRIGGERPOS],
                           float_str);
-               ret = sr_scpi_send(sdi->conn, command);
+               if (sr_scpi_send(sdi->conn, command) != SR_OK ||
+                   sr_scpi_get_opc(sdi->conn) != SR_OK)
+                       return SR_ERR;
+               ret = SR_OK;
                break;
        case SR_CONF_TRIGGER_SLOPE:
                if ((idx = std_str_idx(data, *model->trigger_slopes, model->num_trigger_slopes)) < 0)
@@ -342,7 +351,10 @@ static int config_set(uint32_t key, GVariant *data,
                g_snprintf(command, sizeof(command),
                           (*model->scpi_dialect)[SCPI_CMD_SET_TRIGGER_SLOPE],
                           (*model->trigger_slopes)[idx]);
-               ret = sr_scpi_send(sdi->conn, command);
+               if (sr_scpi_send(sdi->conn, command) != SR_OK ||
+                   sr_scpi_get_opc(sdi->conn) != SR_OK)
+                       return SR_ERR;
+               ret = SR_OK;
                break;
        case SR_CONF_TRIGGER_PATTERN:
                tmp_str = (char *)g_variant_get_string(data, 0);
@@ -428,9 +440,6 @@ static int config_set(uint32_t key, GVariant *data,
                break;
        }
 
-       if (ret == SR_OK)
-               ret = sr_scpi_get_opc(sdi->conn);
-
        if (ret == SR_OK && update_sample_rate)
                ret = hmo_update_sample_rate(sdi);