fluke-45: Add initial driver implementation.

This commit is contained in:
JohnCh 2017-09-09 17:31:15 +01:00 committed by Uwe Hermann
parent e756c595b6
commit ab2b21fb68
3 changed files with 636 additions and 73 deletions

View File

@ -1,6 +1,7 @@
/*
* This file is part of the libsigrok project.
*
* Copyright (C) 2012 Bert Vermeulen <bert@biot.com>
* Copyright (C) 2017 John Chajecki <subs@qcontinuum.plus.com>
*
* This program is free software: you can redistribute it and/or modify
@ -18,120 +19,210 @@
*/
#include <config.h>
#include <glib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <stdint.h>
#include <stdbool.h>
#include <libsigrok/libsigrok.h>
#include "libsigrok-internal.h"
#include "scpi.h"
#include "protocol.h"
static const uint32_t scanopts[] = {
SR_CONF_CONN,
SR_CONF_SERIALCOMM,
};
static const uint32_t drvopts[] = {
SR_CONF_MULTIMETER,
};
static const uint32_t devopts[] = {
SR_CONF_CONTINUOUS,
SR_CONF_LIMIT_SAMPLES | SR_CONF_SET,
SR_CONF_LIMIT_MSEC | SR_CONF_SET,
};
/* Vendor, model, number of channels, poll period */
static const struct fluke_scpi_dmm_model supported_models[] = {
{ "FLUKE", "45", 2, 0 },
};
static struct sr_dev_driver fluke_45_driver_info;
static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi)
{
struct dev_context *devc;
struct sr_dev_inst *sdi;
struct sr_scpi_hw_info *hw_info;
const struct scpi_command *cmdset = fluke_45_cmdset;
unsigned int i;
const struct fluke_scpi_dmm_model *model = NULL;
gchar *channel_name;
char *response;
sdi = g_malloc0(sizeof(struct sr_dev_inst));
sdi->conn = scpi;
/* Test for serial port ECHO enabled. */
sr_scpi_get_string(scpi, "ECHO-TEST", &response);
if (strcmp(response, "ECHO-TEST") == 0) {
sr_err("Serial port ECHO is ON. Please turn it OFF!");
return NULL;
}
/* Get device IDN. */
if (sr_scpi_get_hw_id(scpi, &hw_info) != SR_OK) {
sr_info("Couldn't get IDN response, retrying.");
sr_scpi_close(scpi);
sr_scpi_open(scpi);
if (sr_scpi_get_hw_id(scpi, &hw_info) != SR_OK) {
sr_info("Couldn't get IDN response.");
return NULL;
}
}
/* Check IDN. */
for (i = 0; i < ARRAY_SIZE(supported_models); i++) {
if (!g_ascii_strcasecmp(hw_info->manufacturer,
supported_models[i].vendor) &&
!strcmp(hw_info->model, supported_models[i].model)) {
model = &supported_models[i];
break;
}
}
if (!model) {
sr_scpi_hw_info_free(hw_info);
return NULL;
}
/* Set up device parameters. */
sdi->vendor = g_strdup(model->vendor);
sdi->model = g_strdup(model->model);
sdi->version = g_strdup(hw_info->firmware_version);
sdi->serial_num = g_strdup(hw_info->serial_number);
sdi->conn = scpi;
sdi->driver = &fluke_45_driver_info;
sdi->inst_type = SR_INST_SCPI;
devc = g_malloc0(sizeof(struct dev_context));
devc->num_channels = model->num_channels;
devc->cmdset = cmdset;
/* Create channels. */
for (i = 0; i < devc->num_channels; i++) {
channel_name = g_strdup_printf("P%d", i + 1);
sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, channel_name);
}
sdi->priv = devc;
return sdi;
}
static GSList *scan(struct sr_dev_driver *di, GSList *options)
{
struct drv_context *drvc;
GSList *devices;
(void)options;
devices = NULL;
drvc = di->context;
drvc->instances = NULL;
/* TODO: scan for devices, either based on a SR_CONF_CONN option
* or on a USB scan. */
return devices;
return sr_scpi_scan(di->context, options, probe_device);
}
static int dev_open(struct sr_dev_inst *sdi)
{
(void)sdi;
struct sr_scpi_dev_inst *scpi;
int ret;
/* TODO: get handle from sdi->conn and open it. */
scpi = sdi->conn;
if ((ret = sr_scpi_open(scpi) < 0)) {
sr_err("Failed to open SCPI device: %s.", sr_strerror(ret));
return SR_ERR;
}
return SR_OK;
}
static int dev_close(struct sr_dev_inst *sdi)
{
(void)sdi;
struct sr_scpi_dev_inst *scpi;
/* TODO: get handle from sdi->conn and close it. */
scpi = sdi->conn;
return SR_OK;
}
if (!scpi)
return SR_ERR_BUG;
static int config_get(uint32_t key, GVariant **data,
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
{
int ret;
(void)sdi;
(void)data;
(void)cg;
ret = SR_OK;
switch (key) {
/* TODO */
default:
return SR_ERR_NA;
}
return ret;
return sr_scpi_close(scpi);
}
static int config_set(uint32_t key, GVariant *data,
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
{
int ret;
struct dev_context *devc;
(void)sdi;
(void)data;
(void)cg;
ret = SR_OK;
switch (key) {
/* TODO */
default:
ret = SR_ERR_NA;
}
devc = sdi->priv;
return ret;
return sr_sw_limits_config_set(&devc->limits, key, data);
}
static int config_list(uint32_t key, GVariant **data,
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
{
int ret;
return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts);
}
static int config_get(uint32_t key, GVariant **data,
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
{
struct dev_context *devc = sdi->priv;
(void)sdi;
(void)data;
(void)cg;
ret = SR_OK;
switch (key) {
/* TODO */
default:
return SR_ERR_NA;
}
return ret;
return sr_sw_limits_config_get(&devc->limits, key, data);
}
static int dev_acquisition_start(const struct sr_dev_inst *sdi)
{
/* TODO: configure hardware, reset acquisition state, set up
* callbacks and send header packet. */
struct sr_scpi_dev_inst *scpi;
struct dev_context *devc;
int ret;
(void)sdi;
scpi = sdi->conn;
devc = sdi->priv;
sr_sw_limits_acquisition_start(&devc->limits);
std_session_send_df_header(sdi);
if ((ret = sr_scpi_source_add(sdi->session, scpi, G_IO_IN, 10,
fl45_scpi_receive_data, (void *)sdi)) != SR_OK)
return ret;
return SR_OK;
}
static int dev_acquisition_stop(struct sr_dev_inst *sdi)
{
/* TODO: stop acquisition. */
struct sr_scpi_dev_inst *scpi;
double d;
(void)sdi;
scpi = sdi->conn;
/*
* A requested value is certainly on the way. Retrieve it now,
* to avoid leaving the device in a state where it's not expecting
* commands.
*/
sr_scpi_get_double(scpi, NULL, &d);
sr_scpi_source_remove(sdi->session, scpi);
std_session_send_df_end(sdi);
return SR_OK;
}
SR_PRIV struct sr_dev_driver fluke_45_driver_info = {
static struct sr_dev_driver fluke_45_driver_info = {
.name = "fluke-45",
.longname = "Fluke 45",
.api_version = 1,
@ -149,5 +240,4 @@ SR_PRIV struct sr_dev_driver fluke_45_driver_info = {
.dev_acquisition_stop = dev_acquisition_stop,
.context = NULL,
};
SR_REGISTER_DEV_DRIVER(fluke_45_driver_info);

View File

@ -1,6 +1,7 @@
/*
* This file is part of the libsigrok project.
*
* Copyright (C) 2012 Bert Vermeulen <bert@biot.com>
* Copyright (C) 2017 John Chajecki <subs@qcontinuum.plus.com>
*
* This program is free software: you can redistribute it and/or modify
@ -17,15 +18,215 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <config.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <glib.h>
#include <errno.h>
#include <scpi.h>
#include <libsigrok/libsigrok.h>
#include "libsigrok-internal.h"
#include "protocol.h"
SR_PRIV int fluke_45_receive_data(int fd, int revents, void *cb_data)
/* Get the current state of the meter and sets analog object parameters. */
SR_PRIV int fl45_get_status(const struct sr_dev_inst *sdi,
struct sr_datafeed_analog *analog, int idx)
{
const struct sr_dev_inst *sdi;
struct dev_context *devc;
char *cmd, *func;
int res;
res = 0;
/* Command string to read current function. */
cmd = g_strdup_printf("FUNC%d?", idx + 1);
sr_dbg("Sent command: %s.", cmd);
if (!(devc = sdi->priv))
return TRUE;
/* Default settings. */
analog[idx].meaning->mq = 0;
analog[idx].meaning->unit = 0;
analog[idx].meaning->mqflags = 0;
/* Get a response to the FUNC? command. */
res = fl45_scpi_get_response(sdi, cmd);
if (res == SR_ERR)
return res;
sr_dbg("Response to FUNC: %s.", devc->response);
/* Set up analog mq, unit and flags. */
if (res == SR_OK && devc->response != NULL) {
func = devc->response;
if (strcmp(func, "AAC") == 0) {
analog[idx].meaning->mq = SR_MQ_CURRENT;
analog[idx].meaning->unit = SR_UNIT_AMPERE;
analog[idx].meaning->mqflags = SR_MQFLAG_AC;
} else if (strcmp(func, "AACDC") == 0) {
analog[idx].meaning->mq = SR_MQ_CURRENT;
analog[idx].meaning->unit = SR_UNIT_AMPERE;
analog[idx].meaning->mqflags = SR_MQFLAG_AC;
} else if (strcmp(func, "ADC") == 0) {
analog[idx].meaning->mq = SR_MQ_CURRENT;
analog[idx].meaning->unit = SR_UNIT_AMPERE;
analog[idx].meaning->mqflags = SR_MQFLAG_DC;
} else if (strcmp(func, "CONT") == 0) {
analog[idx].meaning->mq = SR_MQ_CONTINUITY;
analog->meaning->unit = SR_UNIT_BOOLEAN;
} else if (strcmp(func, "DIODE") == 0) {
analog[idx].meaning->mq = SR_MQ_VOLTAGE;
analog[idx].meaning->unit = SR_UNIT_VOLT;
analog[idx].meaning->mqflags = SR_MQFLAG_DIODE;
} else if (strcmp(func, "FREQ") == 0) {
analog[idx].meaning->mq = SR_MQ_FREQUENCY;
analog[idx].meaning->unit = SR_UNIT_HERTZ;
} else if (strcmp(func, "OHMS") == 0) {
analog[idx].meaning->mq = SR_MQ_RESISTANCE;
analog[idx].meaning->unit = SR_UNIT_OHM;
} else if (strcmp(func, "VAC") == 0) {
analog[idx].meaning->mq = SR_MQ_VOLTAGE;
analog[idx].meaning->unit = SR_UNIT_VOLT;
analog[idx].meaning->mqflags = SR_MQFLAG_AC;
} else if (strcmp(func, "VACDC") == 0) {
analog[idx].meaning->mq = SR_MQ_VOLTAGE;
analog[idx].meaning->unit = SR_UNIT_VOLT;
analog[idx].meaning->mqflags |= SR_MQFLAG_AC;
analog[idx].meaning->mqflags |= SR_MQFLAG_DC;
} else if (strcmp(func, "VDC") == 0) {
analog[idx].meaning->mq = SR_MQ_VOLTAGE;
analog[idx].meaning->unit = SR_UNIT_VOLT;
analog[idx].meaning->mqflags = SR_MQFLAG_DC;
}
}
/* Is the meter in autorange mode? */
res = fl45_scpi_get_response(sdi, "AUTO?");
if (res == SR_ERR)
return res;
sr_dbg("Response to AUTO: %s.", devc->response);
if (res == SR_OK && devc->response != NULL) {
if (strcmp(devc->response, "1") == 0)
analog[idx].meaning->mqflags |= SR_MQFLAG_AUTORANGE;
}
return SR_OK;
}
SR_PRIV int fl45_get_modifiers(const struct sr_dev_inst *sdi,
struct sr_datafeed_analog *analog, int idx)
{
struct dev_context *devc;
int res, mod;
if (!(devc = sdi->priv))
return TRUE;
/* Get modifier value. */
res = fl45_scpi_get_response(sdi, "MOD?");
if (res == SR_ERR)
return res;
sr_dbg("Response to MOD: %s.", devc->response);
if (res == SR_OK && devc->response != NULL) {
mod = atoi(devc->response);
if (mod & 0x01) {
analog[idx].meaning->mqflags |= SR_MQFLAG_MIN;
sr_dbg("MIN bit set: %s.", "1");
}
if (mod & 0x02) {
analog[idx].meaning->mqflags |= SR_MQFLAG_MAX;
sr_dbg("MAX bit set: %s.", "2");
}
if (mod & 0x04) {
analog[idx].meaning->mqflags |= SR_MQFLAG_HOLD;
sr_dbg("HOLD bit set: %s.", "4");
}
if (mod & 0x08) {
sr_dbg("dB bit set: %s.", "8");
analog[idx].meaning->mq = SR_MQ_POWER_FACTOR;
analog[idx].meaning->unit = SR_UNIT_DECIBEL_MW;
analog[idx].meaning->mqflags = 0;
analog[idx].encoding->digits = 2;
analog[idx].spec->spec_digits = 2;
}
if (mod & 0x10) {
sr_dbg("dB Power mod bit set: %s.", "16");
analog[idx].meaning->mq = SR_MQ_POWER;
analog[idx].meaning->unit = SR_UNIT_DECIBEL_SPL;
analog[idx].meaning->mqflags = 0;
analog[idx].encoding->digits = 2;
analog[idx].spec->spec_digits = 2;
}
if (mod & 0x20) {
sr_dbg("REL bit set: %s.", "32");
analog[idx].meaning->mqflags |= SR_MQFLAG_HOLD;
}
}
return SR_OK;
}
int get_reading_dd(char *reading, size_t size)
{
int pe, pd, digits;
unsigned int i;
char expstr[3];
char *eptr;
long exp;
/* Calculate required precision. */
pe = pd = digits = 0;
/* Get positions for '.' end 'E'. */
for (i = 0; i < size; i++) {
if (reading[i] == '.')
pd = i;
if (reading[i] == 'E') {
pe = i;
break;
}
}
digits = (pe - pd) - 1;
/* Get exponent element. */
expstr[0] = reading[pe + 1];
expstr[1] = reading[pe + 2];
expstr[2] = '\0';
errno = 0;
exp = strtol(expstr, &eptr, 10);
if (errno != 0)
return 2;
/* A negative exponent increses digits, a positive one reduces. */
exp = exp * (-1);
/* Adjust digits taking into account exponent. */
digits = digits + exp;
return digits;
}
SR_PRIV int fl45_scpi_receive_data(int fd, int revents, void *cb_data)
{
struct sr_dev_inst *sdi;
struct dev_context *devc;
struct sr_datafeed_packet packet;
struct sr_datafeed_analog analog[2];
struct sr_analog_encoding encoding[2];
struct sr_analog_meaning meaning[2];
struct sr_analog_spec spec[2];
struct sr_channel *channel;
char *reading;
float fv;
int res, digits;
unsigned int i;
int sent_ch[2];
(void)fd;
(void)revents;
if (!(sdi = cb_data))
return TRUE;
@ -33,9 +234,116 @@ SR_PRIV int fluke_45_receive_data(int fd, int revents, void *cb_data)
if (!(devc = sdi->priv))
return TRUE;
if (revents == G_IO_IN) {
/* TODO */
res = 0;
sent_ch[0] = sent_ch[1] = 0;
/* Process the list of channels. */
for (i = 0; i < devc->num_channels; i++) {
/* Note: digits/spec_digits will be overridden later. */
sr_analog_init(&analog[i], &encoding[i], &meaning[i], &spec[i], 0);
/* Detect current meter function. */
res = fl45_get_status(sdi, analog, i);
/* Get channel data. */
if (i == 0)
channel = sdi->channels->data;
else
channel = sdi->channels->next->data;
/* Is channel enabled? */
if (analog[i].meaning->mq != 0 && channel->enabled) {
/* Then get a reading from it. */
if (i == 0)
res = fl45_scpi_get_response(sdi, "VAL1?");
if (i == 1)
res = fl45_scpi_get_response(sdi, "VAL2?");
/* Note: Fluke 45 sends all data in text strings. */
reading = devc->response;
/* Deal with OL reading. */
if (strcmp(reading, "+1E+9") == 0) {
fv = INFINITY;
sr_dbg("Reading OL (infinity): %s.",
devc->response);
} else if (res == SR_OK && reading != NULL) {
/* Convert reading to float. */
sr_dbg("Meter reading string: %s.", reading);
res = sr_atof_ascii(reading, &fv);
digits = get_reading_dd(reading, strlen(reading));
analog[i].encoding->digits = digits;
analog[i].spec->spec_digits = digits;
} else {
sr_dbg("Invalid float string: '%s'.", reading);
return SR_ERR;
}
/* Are we on a little or big endian system? */
#ifdef WORDS_BIGENDIAN
analog[i].encoding->is_bigendian = TRUE;
#else
analog[i].encoding->is_bigendian = FALSE;
#endif
/* Apply any modifiers. */
res = fl45_get_modifiers(sdi, analog, i);
/* Channal flag. */
sent_ch[i] = 1;
/* Set up analog object. */
analog[i].num_samples = 1;
analog[i].data = &fv;
analog[i].meaning->channels = g_slist_append(NULL, channel);
packet.type = SR_DF_ANALOG;
packet.payload = &analog[i];
sr_session_send(sdi, &packet);
g_slist_free(analog[i].meaning->channels);
}
}
/* Update appropriate channel limits. */
if (sent_ch[0] || sent_ch[1])
sr_sw_limits_update_samples_read(&devc->limits, 1);
/* Are we done collecting samples? */
if (sr_sw_limits_check(&devc->limits))
sr_dev_acquisition_stop(sdi);
return TRUE;
}
SR_PRIV int fl45_scpi_get_response(const struct sr_dev_inst *sdi, char *cmd)
{
struct dev_context *devc;
devc = sdi->priv;
/* Attempt to get a SCPI reponse. */
if (sr_scpi_get_string(sdi->conn, cmd, &devc->response) != SR_OK)
return SR_ERR;
/* Deal with RS232 '=>' prompt. */
if (strcmp(devc->response, "=>") == 0) {
/*
* If the response is a prompt then ignore and read the next
* response in the buffer.
*/
devc->response = NULL;
/* Now attempt to read again. */
if (sr_scpi_get_string(sdi->conn, NULL, &devc->response) != SR_OK)
return SR_ERR;
}
/* NULL RS232 error prompts. */
if (strcmp(devc->response, "!>") == 0
|| (strcmp(devc->response, "?>") == 0)) {
/* Unable to execute CMD. */
devc->response = NULL;
}
return SR_OK;
}

View File

@ -1,6 +1,7 @@
/*
* This file is part of the libsigrok project.
*
* Copyright (C) 2012 Bert Vermeulen <bert@biot.com>
* Copyright (C) 2017 John Chajecki <subs@qcontinuum.plus.com>
*
* This program is free software: you can redistribute it and/or modify
@ -21,15 +22,179 @@
#define LIBSIGROK_HARDWARE_FLUKE_45_PROTOCOL_H
#include <stdint.h>
#include <glib.h>
#include <libsigrok/libsigrok.h>
#include "libsigrok-internal.h"
#include <stdbool.h>
#include <scpi.h>
#define LOG_PREFIX "fluke-45"
struct dev_context {
#define FLUKEDMM_BUFSIZE 256
/* Always USB-serial, 1ms is plenty. */
#define SERIAL_WRITE_TIMEOUT_MS 1
enum data_format {
/* Fluke 45 uses IEEE488v2. */
FORMAT_IEEE488_2,
};
SR_PRIV int fluke_45_receive_data(int fd, int revents, void *cb_data);
enum dmm_scpi_cmds {
SCPI_CMD_CLS,
SCPI_CMD_RST,
SCPI_CMD_REMS,
SCPI_CMD_RWLS,
SCPI_CMD_LOCS,
SCPI_CMD_LWLS,
SCPI_CMD_REMOTE,
SCPI_CMD_LOCAL,
SCPI_CMD_SET_ACVOLTAGE,
SCPI_CMD_SET_ACDCVOLTAGE,
SCPI_CMD_SET_DCVOLTAGE,
SCPI_CMD_SET_ACCURRENT,
SCPI_CMD_SET_ACDCCURRENT,
SCPI_CMD_SET_DCCURRENT,
SCPI_CMD_SET_FREQUENCY,
SCPI_CMD_SET_RESISTANCE,
SCPI_CMD_SET_CONTINUITY,
SCPI_CMD_SET_DIODE,
SCPI_CMD_SET_AUTO,
SCPI_CMD_GET_AUTO,
SCPI_CMD_SET_FIXED,
SCPI_CMD_SET_RANGE,
SCPI_CMD_GET_RANGE_D1,
SCPI_CMD_GET_RANGE_D2,
SCPI_CMD_SET_DB,
SCPI_CMD_SET_DBCLR,
SCPI_CMD_SET_DBPOWER,
SCPI_CMD_SET_DBREF,
SCPI_CMD_GET_DBREF,
SCPI_CMD_SET_HOLD,
SCPI_CMD_SET_HOLDCLR,
SCPI_CMD_SET_MAX,
SCPI_CMD_SET_MIN,
SCPI_CMD_SET_MMCLR,
SCPI_CMD_SET_REL,
SCPI_CMD_SET_RELCLR,
SCPI_CMD_GET_MEAS_DD,
SCPI_CMD_GET_MEAS_D1,
SCPI_CMD_GET_MEAS_D2,
SCPI_CMD_GET_RATE,
SCPI_CMD_SET_RATE,
SCPI_CMD_SET_TRIGGER,
SCPI_CMD_GET_TRIGGER,
};
static const struct scpi_command fluke_45_cmdset[] = {
{ SCPI_CMD_CLS, "*CLS" },
{ SCPI_CMD_RST, "*RST" },
{ SCPI_CMD_REMS, "*REMS" },
{ SCPI_CMD_RWLS, "*RWLS" },
{ SCPI_CMD_LOCS, "LOCS" },
{ SCPI_CMD_LWLS, "LWLS" },
{ SCPI_CMD_REMOTE, "REMS" },
{ SCPI_CMD_LOCAL, "LOCS" },
{ SCPI_CMD_SET_ACVOLTAGE, "VAC" },
{ SCPI_CMD_SET_ACDCVOLTAGE, "VACDC" },
{ SCPI_CMD_SET_DCVOLTAGE, "VDC" },
{ SCPI_CMD_SET_ACCURRENT, "AAC" },
{ SCPI_CMD_SET_ACDCCURRENT, "AACDC" },
{ SCPI_CMD_SET_DCCURRENT, "ADC" },
{ SCPI_CMD_SET_FREQUENCY, "FREQ" },
{ SCPI_CMD_SET_RESISTANCE, "OHMS" },
{ SCPI_CMD_SET_CONTINUITY, "CONT" },
{ SCPI_CMD_SET_DIODE, "DIODE" },
{ SCPI_CMD_SET_AUTO, "AUTO" },
{ SCPI_CMD_GET_AUTO, "AUTO?" },
{ SCPI_CMD_SET_FIXED, "FIXED" },
{ SCPI_CMD_SET_RANGE, "RANGE" },
{ SCPI_CMD_GET_RANGE_D1, "RANGE1?" },
{ SCPI_CMD_GET_RANGE_D2, "RANGE2?" },
{ SCPI_CMD_SET_DB, "DB" },
{ SCPI_CMD_SET_DBCLR, "DBCLR" },
{ SCPI_CMD_SET_DBPOWER, "DBPOWER" },
{ SCPI_CMD_SET_DBREF, "DBREF" },
{ SCPI_CMD_GET_DBREF, "DBREF?" },
{ SCPI_CMD_SET_HOLD, "HOLD" },
{ SCPI_CMD_SET_HOLDCLR, "HOLDCLR" },
{ SCPI_CMD_SET_MAX, "MAX" },
{ SCPI_CMD_SET_MIN, "MIN" },
{ SCPI_CMD_SET_MMCLR, "MMCLR" },
{ SCPI_CMD_SET_REL, "REL" },
{ SCPI_CMD_SET_RELCLR, "RELCLR" },
{ SCPI_CMD_GET_MEAS_DD, "MEAS?" },
{ SCPI_CMD_GET_MEAS_D1, "MEAS1?" },
{ SCPI_CMD_GET_MEAS_D2, "MEAS2?" },
{ SCPI_CMD_SET_RATE, "RATE" },
{ SCPI_CMD_GET_RATE, "RATE?" },
{ SCPI_CMD_SET_TRIGGER, "TRIGGER" },
{ SCPI_CMD_GET_TRIGGER, "TRIGGER?" },
ALL_ZERO
};
struct fluke_scpi_dmm_model {
const char *vendor;
const char *model;
int num_channels;
int poll_period; /* How often to poll, in ms. */
};
struct channel_spec {
const char *name;
/* Min, max, programming resolution, spec digits, encoding digits. */
double voltage[5];
double current[5];
double resistance[5];
double capacitance[5];
double conductance[5];
double diode[5];
};
struct channel_group_spec {
const char *name;
uint64_t channel_index_mask;
uint64_t features;
};
struct dmm_channel {
enum sr_mq mq;
unsigned int hw_output_idx;
const char *hwname;
int digits;
};
struct dmm_channel_instance {
enum sr_mq mq;
int command;
const char *prefix;
};
struct dmm_channel_group {
uint64_t features;
};
struct dev_context {
struct sr_sw_limits limits;
unsigned int num_channels;
const struct scpi_command *cmdset;
char *response;
const char *mode1;
const char *mode2;
long range1;
long range2;
long autorng;
const char *rate;
long modifiers;
long trigmode;
};
int get_reading_dd(char *reading, size_t size);
SR_PRIV extern const struct fluke_scpi_dmm_model dmm_profiles[];
SR_PRIV int fl45_scpi_receive_data(int fd, int revents, void *cb_data);
SR_PRIV int fl45_scpi_get_response(const struct sr_dev_inst *sdi, char *cmd);
SR_PRIV int fl45_get_status(const struct sr_dev_inst *sdi,
struct sr_datafeed_analog *analog, int idx);
SR_PRIV int fl45_get_modifiers(const struct sr_dev_inst *sdi,
struct sr_datafeed_analog *analog, int idx);
#endif