2 * This file is part of the libsigrok project.
4 * Copyright (C) 2018 Gerhard Sittig <gerhard.sittig@gmx.net>
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #ifndef LIBSIGROK_HARDWARE_SCPI_DMM_PROTOCOL_H
21 #define LIBSIGROK_HARDWARE_SCPI_DMM_PROTOCOL_H
27 #include <libsigrok/libsigrok.h>
28 #include "libsigrok-internal.h"
31 #define LOG_PREFIX "scpi-dmm"
33 #define SCPI_DMM_MAX_CHANNELS 1
35 enum scpi_dmm_cmdcode {
44 DMM_CMD_QUERY_RANGE_AUTO,
46 DMM_CMD_SETUP_RANGE_AUTO,
52 enum sr_mqflag mqflag;
53 const char *scpi_func_setup;
54 const char *scpi_func_query;
55 int default_precision;
58 #define NO_DFLT_PREC -99
60 #define FLAG_NO_RANGE (1 << 0)
62 struct scpi_dmm_model {
67 const struct scpi_command *cmdset;
68 const struct mqopt_item *mqopts;
70 int (*get_measurement)(const struct sr_dev_inst *sdi, size_t ch);
71 const uint32_t *devopts;
73 unsigned int read_timeout_us; /* If zero, use default from src/scpi/scpi.c. */
74 float infinity_limit; /* If zero, use default from protocol.c */
76 const char *(*get_range_text)(const struct sr_dev_inst *sdi);
77 int (*set_range_from_text)(const struct sr_dev_inst *sdi,
79 GVariant *(*get_range_text_list)(const struct sr_dev_inst *sdi);
84 const struct scpi_command *cmdset;
85 const struct scpi_dmm_model *model;
86 struct sr_sw_limits limits;
89 enum sr_mqflag curr_mqflag;
91 struct scpi_dmm_acq_info {
94 struct sr_datafeed_packet packet;
95 struct sr_datafeed_analog analog[SCPI_DMM_MAX_CHANNELS];
96 struct sr_analog_encoding encoding[SCPI_DMM_MAX_CHANNELS];
97 struct sr_analog_meaning meaning[SCPI_DMM_MAX_CHANNELS];
98 struct sr_analog_spec spec[SCPI_DMM_MAX_CHANNELS];
104 SR_PRIV void scpi_dmm_cmd_delay(struct sr_scpi_dev_inst *scpi);
105 SR_PRIV const struct mqopt_item *scpi_dmm_lookup_mq_number(
106 const struct sr_dev_inst *sdi, enum sr_mq mq, enum sr_mqflag flag);
107 SR_PRIV const struct mqopt_item *scpi_dmm_lookup_mq_text(
108 const struct sr_dev_inst *sdi, const char *text);
109 SR_PRIV int scpi_dmm_get_mq(const struct sr_dev_inst *sdi,
110 enum sr_mq *mq, enum sr_mqflag *flag, char **rsp,
111 const struct mqopt_item **mqitem);
112 SR_PRIV int scpi_dmm_set_mq(const struct sr_dev_inst *sdi,
113 enum sr_mq mq, enum sr_mqflag flag);
114 SR_PRIV const char *scpi_dmm_get_range_text(const struct sr_dev_inst *sdi);
115 SR_PRIV int scpi_dmm_set_range_from_text(const struct sr_dev_inst *sdi,
117 SR_PRIV GVariant *scpi_dmm_get_range_text_list(const struct sr_dev_inst *sdi);
118 SR_PRIV int scpi_dmm_get_meas_agilent(const struct sr_dev_inst *sdi, size_t ch);
119 SR_PRIV int scpi_dmm_get_meas_gwinstek(const struct sr_dev_inst *sdi, size_t ch);
120 SR_PRIV int scpi_dmm_receive_data(int fd, int revents, void *cb_data);