]> sigrok.org Git - libsigrok.git/commitdiff
agilent-dmm: split DIOD recv_conf into model specific functions
authorAurelien Jacobs <redacted>
Wed, 22 Jun 2016 23:11:35 +0000 (01:11 +0200)
committerAurelien Jacobs <redacted>
Sun, 26 Jun 2016 18:32:56 +0000 (20:32 +0200)
This reduce overall number of lines and facilitate computation
of significant digits.

src/hardware/agilent-dmm/sched.c

index b48d474e54a36f45b54bc1e7206c32a6c7e42086..f2793fe79f49f94430c0eb0f79217035c66ede66 100644 (file)
@@ -372,6 +372,11 @@ static int recv_conf_u123x(const struct sr_dev_inst *sdi, GMatchInfo *match)
                }
                devc->cur_mqflags = 0;
                devc->cur_exponent = 0;
+       } else if (!strcmp(mstr, "DIOD")) {
+               devc->cur_mq = SR_MQ_VOLTAGE;
+               devc->cur_unit = SR_UNIT_VOLT;
+               devc->cur_mqflags = SR_MQFLAG_DIODE;
+               devc->cur_exponent = 0;
        } else if (!strcmp(mstr, "CAP")) {
                devc->cur_mq = SR_MQ_CAPACITANCE;
                devc->cur_unit = SR_UNIT_FARAD;
@@ -451,6 +456,11 @@ static int recv_conf_u124x_5x(const struct sr_dev_inst *sdi, GMatchInfo *match)
                devc->cur_unit = SR_UNIT_BOOLEAN;
                devc->cur_mqflags = 0;
                devc->cur_exponent = 0;
+       } else if (!strcmp(mstr, "DIOD")) {
+               devc->cur_mq = SR_MQ_VOLTAGE;
+               devc->cur_unit = SR_UNIT_VOLT;
+               devc->cur_mqflags = SR_MQFLAG_DIODE;
+               devc->cur_exponent = 0;
        } else if (!strncmp(mstr, "T1", 2) || !strncmp(mstr, "T2", 2)) {
                devc->cur_mq = SR_MQ_TEMPERATURE;
                m2 = g_match_info_fetch(match, 2);
@@ -480,26 +490,6 @@ static int recv_conf_u124x_5x(const struct sr_dev_inst *sdi, GMatchInfo *match)
        return SR_OK;
 }
 
-static int recv_conf(const struct sr_dev_inst *sdi, GMatchInfo *match)
-{
-       struct dev_context *devc;
-       char *mstr;
-
-       sr_spew("CONF? response '%s'.", g_match_info_get_string(match));
-       devc = sdi->priv;
-       mstr = g_match_info_fetch(match, 1);
-       if (!strcmp(mstr, "DIOD")) {
-               devc->cur_mq = SR_MQ_VOLTAGE;
-               devc->cur_unit = SR_UNIT_VOLT;
-               devc->cur_mqflags = SR_MQFLAG_DIODE;
-               devc->cur_exponent = 0;
-       } else
-               sr_dbg("Unknown single argument.");
-       g_free(mstr);
-
-       return SR_OK;
-}
-
 /* This comes in whenever the rotary switch is changed to a new position.
  * We could use it to determine the major measurement mode, but we already
  * have the output of CONF? for that, which is more detailed. However
@@ -527,7 +517,7 @@ SR_PRIV const struct agdmm_recv agdmm_recvs_u123x[] = {
        { "^([-+][0-9]\\.[0-9]{8}E[-+][0-9]{2})$", recv_fetc },
        { "^\"(V|MV|A|UA|FREQ),(\\d),(AC|DC)\"$", recv_conf_u123x },
        { "^\"(RES|CAP),(\\d)\"$", recv_conf_u123x},
-       { "^\"(DIOD)\"$", recv_conf },
+       { "^\"(DIOD)\"$", recv_conf_u123x },
        ALL_ZERO
 };
 
@@ -539,7 +529,7 @@ SR_PRIV const struct agdmm_recv agdmm_recvs_u124x[] = {
        { "^\"(VOLT:[ACD]+) ([-+][0-9\\.E\\-+]+),([-+][0-9\\.E\\-+]+)\"$", recv_conf_u124x_5x },
        { "^\"(CPER:[40]-20mA) ([-+][0-9\\.E\\-+]+),([-+][0-9\\.E\\-+]+)\"$", recv_conf_u124x_5x },
        { "^\"(T[0-9]:[A-Z]+) ([A-Z]+)\"$", recv_conf_u124x_5x },
-       { "^\"(DIOD)\"$", recv_conf },
+       { "^\"(DIOD)\"$", recv_conf_u124x_5x },
        ALL_ZERO
 };
 
@@ -551,6 +541,6 @@ SR_PRIV const struct agdmm_recv agdmm_recvs_u125x[] = {
        { "^\"(VOLT:[ACD]+) ([-+][0-9\\.E\\-+]+),([-+][0-9\\.E\\-+]+)\"$", recv_conf_u124x_5x },
        { "^\"(CPER:[40]-20mA) ([-+][0-9\\.E\\-+]+),([-+][0-9\\.E\\-+]+)\"$", recv_conf_u124x_5x },
        { "^\"(T[0-9]:[A-Z]+) ([A-Z]+)\"$", recv_conf_u124x_5x },
-       { "^\"(DIOD)\"$", recv_conf },
+       { "^\"(DIOD)\"$", recv_conf_u124x_5x },
        ALL_ZERO
 };