During the initial configuration phase of the hameg-hmo driver
only send an OPC command if an SCPI command has been previously
sent to the device so that bogus SCPI timeouts are avoided.

Signed-off-by: Guido Trentalancia <gu...@trentalancia.com>
---
 src/hardware/hameg-hmo/api.c |   23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

diff -pru libsigrok-git-orig/src/hardware/hameg-hmo/api.c 
libsigrok-git-hameg-hmo-perform-opc-only-after-scpi-commands/src/hardware/hameg-hmo/api.c
--- libsigrok-git-orig/src/hardware/hameg-hmo/api.c     2018-11-15 
17:16:49.625199054 +0100
+++ 
libsigrok-git-hameg-hmo-perform-opc-only-after-scpi-commands/src/hardware/hameg-hmo/api.c
   2018-11-17 22:14:28.849535439 +0100
@@ -288,7 +288,10 @@ static int config_set(uint32_t key, GVar
                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, GVar
                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, GVar
                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, GVar
                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, GVar
                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);
 


_______________________________________________
sigrok-devel mailing list
sigrok-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sigrok-devel

Reply via email to