SR_CONF_LIMIT_MSEC | SR_CONF_GET | SR_CONF_SET,
SR_CONF_MEASURED_QUANTITY | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
SR_CONF_RANGE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
+ SR_CONF_DIGITS | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
};
static const struct {
{SR_MQ_RESISTANCE, SR_MQFLAG_FOUR_WIRE},
};
-
static const struct {
enum sr_mq mq;
enum sr_mqflag mqflag;
{SR_MQ_RESISTANCE, SR_MQFLAG_FOUR_WIRE, 7, "30MR"},
};
+/** Available digits as strings. */
+static const char *digits[] = {
+ "3.5", "4.5", "5.5",
+};
+
+/** Mapping between devc->spec_digits and digits string. */
+static const char *digits_map[] = {
+ "", "", "", "", "3.5", "4.5", "5.5",
+};
+
static struct sr_dev_driver hp_3478a_driver_info;
static int create_front_channel(struct sr_dev_inst *sdi, int chan_idx)
}
*data = g_variant_new_string(range_str);
break;
+ case SR_CONF_DIGITS:
+ ret = hp_3478a_get_status_bytes(sdi);
+ if (ret != SR_OK)
+ return ret;
+ *data = g_variant_new_string(digits_map[devc->spec_digits]);
+ break;
default:
return SR_ERR_NA;
}
GVariant *tuple_child;
unsigned int i;
const char *range_str;
+ const char *digits_str;
(void)cg;
}
}
return SR_ERR_NA;
+ case SR_CONF_DIGITS:
+ digits_str = g_variant_get_string(data, NULL);
+ for (i = 0; i < ARRAY_SIZE(rangeopts); i++) {
+ if (g_strcmp0(digits_map[i], digits_str) == 0)
+ return hp_3478a_set_digits(sdi, i);
+ }
+ return SR_ERR_NA;
default:
return SR_ERR_NA;
}
}
*data = g_variant_builder_end(&gvb);
break;
+ case SR_CONF_DIGITS:
+ *data = g_variant_new_strv(ARRAY_AND_SIZE(digits));
+ break;
default:
return SR_ERR_NA;
}
* NOTE: For faster readings, there are some things one can do:
* - Turn off the display: sr_scpi_send(scpi, "D3SIGROK").
* - Set the line frequency to 60Hz via switch (back of the unit).
- * - Set to 3.5 digits measurement (add config key SR_CONF_DIGITS).
+ * - Set to 3.5 digits measurement.
*/
/* Set to internal trigger. */
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) {
SR_PRIV int hp_3478a_set_mq(const struct sr_dev_inst *sdi, enum sr_mq mq,
enum sr_mqflag mq_flags);
SR_PRIV int hp_3478a_set_range(const struct sr_dev_inst *sdi, int range_exp);
+SR_PRIV int hp_3478a_set_digits(const struct sr_dev_inst *sdi, uint8_t digits);
SR_PRIV int hp_3478a_get_status_bytes(const struct sr_dev_inst *sdi);
SR_PRIV int hp_3478a_receive_data(int fd, int revents, void *cb_data);