]> sigrok.org Git - libsigrok.git/commitdiff
korad-kaxxxxp: eliminate model check in OVP enabled quirk handling
authorGerhard Sittig <redacted>
Thu, 15 Sep 2022 20:12:28 +0000 (22:12 +0200)
committerGerhard Sittig <redacted>
Sat, 17 Sep 2022 09:24:39 +0000 (11:24 +0200)
Rephrase the check for the Velleman LABPS3005D quirk. Eliminate the
check for individual supported models in the main loop. The condition
gets detected at scan time already. Handling other affected models
becomes transparent.

src/hardware/korad-kaxxxxp/protocol.c

index f98bf962e37d23960993fcc893d54c7369051547..c52bd9011fcc189cbb8fb00cd0785f280b02b1df 100644 (file)
@@ -258,6 +258,7 @@ SR_PRIV int korad_kaxxxxp_get_value(struct sr_serial_dev_inst *serial,
        char reply[6];
        float *value;
        char status_byte;
+       gboolean needs_ovp_quirk;
        gboolean prev_status;
 
        g_mutex_lock(&devc->rw_mutex);
@@ -345,9 +346,8 @@ SR_PRIV int korad_kaxxxxp_get_value(struct sr_serial_dev_inst *serial,
                devc->output_enabled_changed = devc->output_enabled != prev_status;
 
                /* OVP enabled, special handling for Velleman LABPS3005 quirk. */
-               if ((devc->model->model_id == VELLEMAN_LABPS3005D && devc->output_enabled) ||
-                       devc->model->model_id != VELLEMAN_LABPS3005D) {
-
+               needs_ovp_quirk = devc->model->quirks & KORAD_QUIRK_LABPS_OVP_EN;
+               if (!needs_ovp_quirk || devc->output_enabled) {
                        prev_status = devc->ovp_enabled;
                        devc->ovp_enabled = status_byte & (1 << 7);
                        devc->ovp_enabled_changed = devc->ovp_enabled != prev_status;