]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/agilent-dmm/protocol.c
agilent-dmm: Add support for Vsense (Non-Contact Voltage).
[libsigrok.git] / src / hardware / agilent-dmm / protocol.c
index 7c31fe81fa324f3d63ae437d060dde06e2237cd6..1e178ae9e9ff39dd0d26b99f8464871d703ad408 100644 (file)
@@ -414,6 +414,7 @@ static int recv_fetc(const struct sr_dev_inst *sdi, GMatchInfo *match)
        struct sr_analog_encoding encoding;
        struct sr_analog_meaning meaning;
        struct sr_analog_spec spec;
+       struct sr_channel *prev_chan;
        float fvalue;
        const char *s;
        char *mstr;
@@ -473,8 +474,8 @@ static int recv_fetc(const struct sr_dev_inst *sdi, GMatchInfo *match)
 
        sr_sw_limits_update_samples_read(&devc->limits, 1);
 
-skip_value:;
-       struct sr_channel *prev_chan = devc->cur_channel;
+skip_value:
+       prev_chan = devc->cur_channel;
        devc->cur_channel = sr_next_enabled_channel(sdi, devc->cur_channel);
        if (devc->cur_channel->index > prev_chan->index)
                return JOB_AGAIN;
@@ -487,7 +488,7 @@ static int send_conf(const struct sr_dev_inst *sdi)
        struct dev_context *devc = sdi->priv;
 
        /* Do not try to send CONF? for internal temperature channel. */
-       if (devc->cur_conf->index == MAX(devc->profile->nb_channels - 1, 1))
+       if (devc->cur_conf->index >= MIN(devc->profile->nb_channels, 2))
                return SR_ERR_NA;
 
        if (devc->cur_conf->index > 0)
@@ -704,16 +705,16 @@ static int recv_conf_u124x_5x(const struct sr_dev_inst *sdi, GMatchInfo *match)
                devc->cur_digits[i] = 4;
                devc->cur_encoding[i] = 5;
        } else if (!strncmp(mstr, "T1", 2) || !strncmp(mstr, "T2", 2) ||
-                  !strncmp(mstr, "TEMP", 2)) {
+                  !strncmp(mstr, "TEMP", 4)) {
                devc->cur_mq[i] = SR_MQ_TEMPERATURE;
                m2 = g_match_info_fetch(match, 2);
-               if (!m2)
+               if (!m2 && devc->profile->nb_channels == 3)
                        /*
                         * TEMP without param is for secondary display (channel P2)
                         * and is identical to channel P3, so discard it.
                         */
                        devc->cur_mq[i] = -1;
-               else if (!strcmp(m2, "FAR"))
+               else if (m2 && !strcmp(m2, "FAR"))
                        devc->cur_unit[i] = SR_UNIT_FAHRENHEIT;
                else
                        devc->cur_unit[i] = SR_UNIT_CELSIUS;
@@ -741,6 +742,13 @@ static int recv_conf_u124x_5x(const struct sr_dev_inst *sdi, GMatchInfo *match)
                 * an error in this mode, so don't even call it.
                 */
                devc->mode_squarewave = 1;
+       } else if (!strcmp(mstr, "NCV")) {
+               devc->cur_mq[i] = SR_MQ_VOLTAGE;
+               devc->cur_unit[i] = SR_UNIT_VOLT;
+               devc->cur_mqflags[i] = SR_MQFLAG_AC;
+               devc->cur_exponent[i] = -3;
+               devc->cur_digits[i] = -1;
+               devc->cur_encoding[i] = 0;
        } else {
                sr_dbg("Unknown first argument '%s'.", mstr);
        }
@@ -748,7 +756,7 @@ static int recv_conf_u124x_5x(const struct sr_dev_inst *sdi, GMatchInfo *match)
 
        struct sr_channel *prev_conf = devc->cur_conf;
        devc->cur_conf = sr_next_enabled_channel(sdi, devc->cur_conf);
-       if (devc->cur_conf->index == MAX(devc->profile->nb_channels - 1, 1))
+       if (devc->cur_conf->index >= MIN(devc->profile->nb_channels, 2))
                devc->cur_conf = sr_next_enabled_channel(sdi, devc->cur_conf);
        if (devc->cur_conf->index > prev_conf->index)
                return JOB_AGAIN;
@@ -945,6 +953,7 @@ SR_PRIV const struct agdmm_recv agdmm_recvs_u128x[] = {
        { "^\"(CPER:[40]-20mA) ([-+][0-9\\.E\\-+]+),([-+][0-9]\\.[0-9]{8}E([-+][0-9]{2}))\"$", recv_conf_u124x_5x },
        { "^\"(PULS:PWID|PULS:PWID:[ACD]+) ([-+][0-9\\.E\\-+]+),([-+][0-9]\\.[0-9]{8}E([-+][0-9]{2}))\"$", recv_conf_u124x_5x },
        { "^\"(TEMP:[A-Z]+) ([A-Z]+)\"$", recv_conf_u124x_5x },
+       { "^\"(NCV) (HIGH|LOW)\"$", recv_conf_u124x_5x },
        { "^\"(DIOD|SQU|PULS:PDUT|TEMP)\"$", recv_conf_u124x_5x },
        { "^\"((\\d{2})(\\d{5})\\d{7})\"$", recv_log_u128x },
        { "^\\*E$", recv_err },