From: Gerhard Sittig Date: Fri, 21 Aug 2020 09:34:54 +0000 (+0200) Subject: scpi-dmm: factor out some OL detection limits X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=395c1850b797384cd7e1a2e194c001461c8460f7;p=libsigrok.git scpi-dmm: factor out some OL detection limits Prepare the "plus/minus infinity" checks for OL conditions to use model dependent limits. This commit does not change behaviour. --- diff --git a/src/hardware/scpi-dmm/protocol.c b/src/hardware/scpi-dmm/protocol.c index d8d07957..f9aea2a4 100644 --- a/src/hardware/scpi-dmm/protocol.c +++ b/src/hardware/scpi-dmm/protocol.c @@ -170,6 +170,7 @@ SR_PRIV int scpi_dmm_get_meas_agilent(const struct sr_dev_inst *sdi, size_t ch) int sig_digits, val_exp; int digits; enum sr_unit unit; + double limit; scpi = sdi->conn; devc = sdi->priv; @@ -282,9 +283,10 @@ SR_PRIV int scpi_dmm_get_meas_agilent(const struct sr_dev_inst *sdi, size_t ch) } if (!response) return SR_ERR; - if (info->d_value > +9e37) { + limit = 9e37; + if (info->d_value > +limit) { info->d_value = +INFINITY; - } else if (info->d_value < -9e37) { + } else if (info->d_value < -limit) { info->d_value = -INFINITY; } else { p = response; @@ -456,9 +458,10 @@ SR_PRIV int scpi_dmm_get_meas_gwinstek(const struct sr_dev_inst *sdi, size_t ch) } if (!response) return SR_ERR; - if (info->d_value > +9e37) { + limit = 9e37; + if (info->d_value > +limit) { info->d_value = +INFINITY; - } else if (info->d_value < -9e37) { + } else if (info->d_value < -limit) { info->d_value = -INFINITY; } else { p = response; @@ -494,10 +497,9 @@ SR_PRIV int scpi_dmm_get_meas_gwinstek(const struct sr_dev_inst *sdi, size_t ch) case 7: case 16: /* In resitance modes 0L reads as 1.20000E8 or 1.99999E8. */ + limit = 1.2e8; if (strcmp(devc->model->model, "GDM8255A") == 0) limit = 1.99999e8; - else - limit = 1.2e8; if (info->d_value >= limit) info->d_value = +INFINITY; break;