X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fhardware%2Fgmc-mh-1x-2x%2Fprotocol.c;h=53efdf4255f7500d60c4f07ef36ac6e537f4dff3;hb=396cdca0c3edbf619a9f03379486bbedc56cfdac;hp=20bf81fca6dc69ccd90603fd4c177b0f13201caa;hpb=d9251a2c9f1ca4380c27240ccca90c9f9ed46d3f;p=libsigrok.git
diff --git a/src/hardware/gmc-mh-1x-2x/protocol.c b/src/hardware/gmc-mh-1x-2x/protocol.c
index 20bf81fc..53efdf42 100644
--- a/src/hardware/gmc-mh-1x-2x/protocol.c
+++ b/src/hardware/gmc-mh-1x-2x/protocol.c
@@ -17,20 +17,11 @@
* along with this program. If not, see .
*/
-/**
- * @file
- *
- * Gossen Metrawatt Metrahit 1x/2x drivers
- *
- * @internal
- */
-
#include
#include
#include
#include "protocol.h"
-/* Internal Headers */
static guchar calc_chksum_14(guchar *dta);
static int chk_msg14(struct sr_dev_inst *sdi);
@@ -95,10 +86,7 @@ static void decode_ctmv_16(uint8_t ctmv, struct dev_context *devc)
case 0x0d: /* 1101 µF (15S/16S only) */
devc->mq = SR_MQ_CAPACITANCE;
devc->unit = SR_UNIT_FARAD;
- if (ctmv == 0x0c)
- devc->scale1000 = -3;
- else
- devc->scale1000 = -2;
+ devc->scale1000 = (ctmv == 0x0c) ? -3 : -2;
break;
case 0x0e: /* mA, µA */
devc->scale1000 = -1; /* Fall through. */
@@ -124,12 +112,8 @@ static void decode_rs_16(uint8_t rs, struct dev_context *devc)
if (rs & 0x04) /* Sign */
devc->scale = -devc->scale;
- if (devc->mq == SR_MQ_CURRENT) {
- if (rs & 0x08) /* Current is AC */
- devc->mqflags |= SR_MQFLAG_AC;
- else
- devc->mqflags |= SR_MQFLAG_DC;
- }
+ if (devc->mq == SR_MQ_CURRENT)
+ devc->mqflags |= (rs & 0x08) ? SR_MQFLAG_AC : SR_MQFLAG_DC;
switch (rs & 0x03) {
case 0:
@@ -290,10 +274,7 @@ static void decode_rs_18(uint8_t rs, struct dev_context *devc)
devc->scale += range - 5;
break;
case SR_MQ_CURRENT:
- if (devc->scale1000 == -1)
- devc->scale += range - 5;
- else
- devc->scale += range - 4;
+ devc->scale += (devc->scale1000 == -1) ? range - 5 : range - 4;
break;
case SR_MQ_RESISTANCE:
devc->scale += range - 2;
@@ -530,10 +511,7 @@ static void decode_rs_2x(uint8_t rs, struct dev_context *devc)
range = rs & 0x07;
switch (devc->mq) {
case SR_MQ_VOLTAGE:
- if (devc->unit == SR_UNIT_DECIBEL_VOLT)
- devc->scale += -3;
- else
- devc->scale += range - 6;
+ devc->scale += (devc->unit == SR_UNIT_DECIBEL_VOLT) ? -3 : range - 6;
break;
case SR_MQ_CURRENT:
if (devc->scale1000 != -1) /* uA, mA */
@@ -1188,7 +1166,7 @@ SR_PRIV int gmc_mh_1x_2x_receive_data(int fd, int revents, void *cb_data)
}
if (sr_sw_limits_check(&devc->limits))
- sdi->driver->dev_acquisition_stop(sdi);
+ sr_dev_acquisition_stop(sdi);
return TRUE;
}
@@ -1231,7 +1209,7 @@ SR_PRIV int gmc_mh_2x_receive_data(int fd, int revents, void *cb_data)
}
if (sr_sw_limits_check(&devc->limits))
- sdi->driver->dev_acquisition_stop(sdi);
+ sr_dev_acquisition_stop(sdi);
/* Request next data set, if required */
if (sdi->status == SR_ST_ACTIVE) {
@@ -1296,9 +1274,7 @@ static void create_cmd_14(guchar addr, guchar func, guchar *params, guchar *buf)
}
}
-/** Request one measurement from 2x multimeter (msg 8).
- *
- */
+/** Request one measurement from 2x multimeter (msg 8). */
int req_meas14(const struct sr_dev_inst *sdi)
{
struct dev_context *devc;
@@ -1374,7 +1350,8 @@ int req_stat14(const struct sr_dev_inst *sdi, gboolean power_on)
return SR_OK;
}
-/** Decode model in "send mode".
+/**
+ * Decode model in "send mode".
*
* @param[in] mcode Model code.
* @return Model code.
@@ -1434,10 +1411,7 @@ SR_PRIV int gmc_decode_model_bd(uint8_t mcode)
{
switch (mcode & 0x1f) {
case 2:
- if (mcode & 0x20)
- return METRAHIT_22M;
- else
- return METRAHIT_22S;
+ return (mcode & 0x20) ? METRAHIT_22M : METRAHIT_22S;
case 3:
return METRAHIT_23S;
case 4:
@@ -1445,10 +1419,7 @@ SR_PRIV int gmc_decode_model_bd(uint8_t mcode)
case 5:
return METRAHIT_25S;
case 1:
- if (mcode & 0x20)
- return METRAHIT_26M;
- else
- return METRAHIT_26S;
+ return (mcode & 0x20) ? METRAHIT_26M : METRAHIT_26S;
case 12:
return METRAHIT_28S;
case 14:
@@ -1524,9 +1495,6 @@ SR_PRIV int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *s
(void)cg;
- if (sdi->status != SR_ST_ACTIVE)
- return SR_ERR_DEV_CLOSED;
-
devc = sdi->priv;
switch (key) {