X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fhp-3478a%2Fprotocol.c;h=7842f2f4e25992ca81a9d72e2f6d63a783274256;hb=4704f64551dd917c2616b4162e7e816fb57113da;hp=da200e7ab3fff629b804f52b8ead03d8e1bb7e51;hpb=e5137b9343563b27c8ba791360aa408264482153;p=libsigrok.git diff --git a/src/hardware/hp-3478a/protocol.c b/src/hardware/hp-3478a/protocol.c index da200e7a..7842f2f4 100644 --- a/src/hardware/hp-3478a/protocol.c +++ b/src/hardware/hp-3478a/protocol.c @@ -110,6 +110,24 @@ SR_PRIV int hp_3478a_set_range(const struct sr_dev_inst *sdi, int range_exp) return hp_3478a_get_status_bytes(sdi); } +SR_PRIV int hp_3478a_set_digits(const struct sr_dev_inst *sdi, uint8_t digits) +{ + int ret; + struct sr_scpi_dev_inst *scpi = sdi->conn; + struct dev_context *devc = sdi->priv; + + /* No need to send command if we're not changing the range. */ + if (devc->spec_digits == digits) + return SR_OK; + + /* digits are based on devc->spec_digits, so we have to substract 1 */ + ret = sr_scpi_send(scpi, "N%i", digits-1); + if (ret != SR_OK) + return ret; + + return hp_3478a_get_status_bytes(sdi); +} + static int parse_range_vdc(struct dev_context *devc, uint8_t range_byte) { if ((range_byte & SB1_RANGE_BLOCK) == RANGE_VDC_30MV) { @@ -479,6 +497,10 @@ SR_PRIV int hp_3478a_receive_data(int fd, int revents, void *cb_data) if (sr_scpi_get_double(scpi, NULL, &devc->measurement) != SR_OK) return FALSE; + /* Check for overflow. */ + if (devc->measurement >= 9.998e+9) + devc->measurement = INFINITY; + /* * This is necessary to get the actual range for the encoding digits. * Must be called after reading the value, because it resets the