]> sigrok.org Git - libsigrok.git/commitdiff
hameg-hmo: fix "invalid argument" exception when setting trigger edges
authorStefan Brüns <redacted>
Sun, 10 Apr 2016 20:52:30 +0000 (22:52 +0200)
committerUwe Hermann <redacted>
Sun, 17 Apr 2016 12:50:42 +0000 (14:50 +0200)
The hameg-hmo driver uses the values from the trigger_slopes array.

src/hardware/hameg-hmo/api.c

index b2705d084cec4d9b34c6ed1dcb216d5f20f2f9e9..370b6314059fb5dd0a0375f4dfe8a1e000103440 100644 (file)
@@ -437,17 +437,17 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
                break;
        case SR_CONF_TRIGGER_SLOPE:
                tmp = g_variant_get_string(data, NULL);
                break;
        case SR_CONF_TRIGGER_SLOPE:
                tmp = g_variant_get_string(data, NULL);
+               for (i = 0; (*model->trigger_slopes)[i]; i++) {
+                       if (g_strcmp0(tmp, (*model->trigger_slopes)[i]) != 0)
+                               continue;
+                       state->trigger_slope = i;
+                       g_snprintf(command, sizeof(command),
+                                  (*model->scpi_dialect)[SCPI_CMD_SET_TRIGGER_SLOPE],
+                                  (*model->trigger_slopes)[i]);
 
 
-               if (!tmp || !(tmp[0] == 'f' || tmp[0] == 'r'))
-                       return SR_ERR_ARG;
-
-               state->trigger_slope = (tmp[0] == 'r') ? 0 : 1;
-
-               g_snprintf(command, sizeof(command),
-                          (*model->scpi_dialect)[SCPI_CMD_SET_TRIGGER_SLOPE],
-                          (state->trigger_slope == 0) ? "POS" : "NEG");
-
-               ret = sr_scpi_send(sdi->conn, command);
+                       ret = sr_scpi_send(sdi->conn, command);
+                       break;
+               }
                break;
        case SR_CONF_COUPLING:
                if (cg_type == CG_NONE) {
                break;
        case SR_CONF_COUPLING:
                if (cg_type == CG_NONE) {