aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAurelien Jacobs <aurel@gnuage.org>2017-01-16 11:47:42 +0100
committerAurelien Jacobs <aurel@gnuage.org>2017-01-22 19:03:29 +0100
commit1af3f40eec5042ec3b22dc8c5e61ec8e291531d5 (patch)
tree5a9787d6b60d0704de210a3c82cc1822ebfd9537
parent29bdeeb54937cdfd3adaef98d6acee510cb91a47 (diff)
agilent_dmm: Split generic part of recv_log_u128x() to recv_log().
-rw-r--r--src/hardware/agilent-dmm/protocol.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/hardware/agilent-dmm/protocol.c b/src/hardware/agilent-dmm/protocol.c
index 1e178ae..a1823b8 100644
--- a/src/hardware/agilent-dmm/protocol.c
+++ b/src/hardware/agilent-dmm/protocol.c
@@ -772,11 +772,10 @@ static int send_log(const struct sr_dev_inst *sdi)
source[devc->data_source - 1], devc->cur_sample);
}
-static int recv_log_u128x(const struct sr_dev_inst *sdi, GMatchInfo *match)
+static int recv_log(const struct sr_dev_inst *sdi, GMatchInfo *match,
+ const int mqs[], const int units[], const int exponents[],
+ unsigned int num_functions)
{
- static const int mqs[] = { SR_MQ_VOLTAGE, SR_MQ_VOLTAGE, SR_MQ_CURRENT, SR_MQ_CURRENT, SR_MQ_RESISTANCE, SR_MQ_VOLTAGE, SR_MQ_TEMPERATURE, SR_MQ_CAPACITANCE, SR_MQ_FREQUENCY, SR_MQ_DUTY_CYCLE, SR_MQ_PULSE_WIDTH, SR_MQ_VOLTAGE, SR_MQ_CURRENT, SR_MQ_CONDUCTANCE };
- static const int units[] = { SR_UNIT_VOLT, SR_UNIT_VOLT, SR_UNIT_AMPERE, SR_UNIT_AMPERE, SR_UNIT_OHM, SR_UNIT_VOLT, SR_UNIT_CELSIUS, SR_UNIT_FARAD, SR_UNIT_HERTZ, SR_UNIT_PERCENTAGE, SR_UNIT_SECOND, SR_UNIT_DECIBEL_MW, SR_UNIT_PERCENTAGE, SR_UNIT_SIEMENS };
- static const int exponents[] = { -6, -4, -9, -4, -3, -4, -1, -12, -3, -3, -6, -3, -2, -11 };
struct dev_context *devc;
struct sr_datafeed_packet packet;
struct sr_datafeed_analog analog;
@@ -794,7 +793,7 @@ static int recv_log_u128x(const struct sr_dev_inst *sdi, GMatchInfo *match)
devc = sdi->priv;
mstr = g_match_info_fetch(match, 2);
- if (sr_atoi(mstr, (int*)&function) != SR_OK || function >= ARRAY_SIZE(mqs)) {
+ if (sr_atoi(mstr, (int*)&function) != SR_OK || function >= num_functions) {
g_free(mstr);
sr_dbg("Invalid function.");
return SR_ERR;
@@ -860,6 +859,15 @@ static int recv_log_u128x(const struct sr_dev_inst *sdi, GMatchInfo *match)
return JOB_LOG;
}
+static int recv_log_u128x(const struct sr_dev_inst *sdi, GMatchInfo *match)
+{
+ static const int mqs[] = { SR_MQ_VOLTAGE, SR_MQ_VOLTAGE, SR_MQ_CURRENT, SR_MQ_CURRENT, SR_MQ_RESISTANCE, SR_MQ_VOLTAGE, SR_MQ_TEMPERATURE, SR_MQ_CAPACITANCE, SR_MQ_FREQUENCY, SR_MQ_DUTY_CYCLE, SR_MQ_PULSE_WIDTH, SR_MQ_VOLTAGE, SR_MQ_CURRENT, SR_MQ_CONDUCTANCE };
+ static const int units[] = { SR_UNIT_VOLT, SR_UNIT_VOLT, SR_UNIT_AMPERE, SR_UNIT_AMPERE, SR_UNIT_OHM, SR_UNIT_VOLT, SR_UNIT_CELSIUS, SR_UNIT_FARAD, SR_UNIT_HERTZ, SR_UNIT_PERCENTAGE, SR_UNIT_SECOND, SR_UNIT_DECIBEL_MW, SR_UNIT_PERCENTAGE, SR_UNIT_SIEMENS };
+ static const int exponents[] = { -6, -4, -9, -4, -3, -4, -1, -12, -3, -3, -6, -3, -2, -11 };
+
+ return recv_log(sdi, match, mqs, units, exponents, ARRAY_SIZE(mqs));
+}
+
/* 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