2 * This file is part of the libsigrok project.
4 * Copyright (C) 2012 Bert Vermeulen <bert@biot.com>
5 * Copyright (C) 2017 John Chajecki <subs@qcontinuum.plus.com>
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #ifndef LIBSIGROK_HARDWARE_FLUKE_45_PROTOCOL_H
22 #define LIBSIGROK_HARDWARE_FLUKE_45_PROTOCOL_H
28 #define LOG_PREFIX "fluke-45"
30 #define FLUKEDMM_BUFSIZE 256
32 /* Always USB-serial, 1ms is plenty. */
33 #define SERIAL_WRITE_TIMEOUT_MS 1
36 /* Fluke 45 uses IEEE488v2. */
49 SCPI_CMD_SET_ACVOLTAGE,
50 SCPI_CMD_SET_ACDCVOLTAGE,
51 SCPI_CMD_SET_DCVOLTAGE,
52 SCPI_CMD_SET_ACCURRENT,
53 SCPI_CMD_SET_ACDCCURRENT,
54 SCPI_CMD_SET_DCCURRENT,
55 SCPI_CMD_SET_FREQUENCY,
56 SCPI_CMD_SET_RESISTANCE,
57 SCPI_CMD_SET_CONTINUITY,
63 SCPI_CMD_GET_RANGE_D1,
64 SCPI_CMD_GET_RANGE_D2,
86 static const struct scpi_command fluke_45_cmdset[] = {
87 { SCPI_CMD_CLS, "*CLS" },
88 { SCPI_CMD_RST, "*RST" },
89 { SCPI_CMD_REMS, "*REMS" },
90 { SCPI_CMD_RWLS, "*RWLS" },
91 { SCPI_CMD_LOCS, "LOCS" },
92 { SCPI_CMD_LWLS, "LWLS" },
93 { SCPI_CMD_REMOTE, "REMS" },
94 { SCPI_CMD_LOCAL, "LOCS" },
95 { SCPI_CMD_SET_ACVOLTAGE, "VAC" },
96 { SCPI_CMD_SET_ACDCVOLTAGE, "VACDC" },
97 { SCPI_CMD_SET_DCVOLTAGE, "VDC" },
98 { SCPI_CMD_SET_ACCURRENT, "AAC" },
99 { SCPI_CMD_SET_ACDCCURRENT, "AACDC" },
100 { SCPI_CMD_SET_DCCURRENT, "ADC" },
101 { SCPI_CMD_SET_FREQUENCY, "FREQ" },
102 { SCPI_CMD_SET_RESISTANCE, "OHMS" },
103 { SCPI_CMD_SET_CONTINUITY, "CONT" },
104 { SCPI_CMD_SET_DIODE, "DIODE" },
105 { SCPI_CMD_SET_AUTO, "AUTO" },
106 { SCPI_CMD_GET_AUTO, "AUTO?" },
107 { SCPI_CMD_SET_FIXED, "FIXED" },
108 { SCPI_CMD_SET_RANGE, "RANGE" },
109 { SCPI_CMD_GET_RANGE_D1, "RANGE1?" },
110 { SCPI_CMD_GET_RANGE_D2, "RANGE2?" },
111 { SCPI_CMD_SET_DB, "DB" },
112 { SCPI_CMD_SET_DBCLR, "DBCLR" },
113 { SCPI_CMD_SET_DBPOWER, "DBPOWER" },
114 { SCPI_CMD_SET_DBREF, "DBREF" },
115 { SCPI_CMD_GET_DBREF, "DBREF?" },
116 { SCPI_CMD_SET_HOLD, "HOLD" },
117 { SCPI_CMD_SET_HOLDCLR, "HOLDCLR" },
118 { SCPI_CMD_SET_MAX, "MAX" },
119 { SCPI_CMD_SET_MIN, "MIN" },
120 { SCPI_CMD_SET_MMCLR, "MMCLR" },
121 { SCPI_CMD_SET_REL, "REL" },
122 { SCPI_CMD_SET_RELCLR, "RELCLR" },
123 { SCPI_CMD_GET_MEAS_DD, "MEAS?" },
124 { SCPI_CMD_GET_MEAS_D1, "MEAS1?" },
125 { SCPI_CMD_GET_MEAS_D2, "MEAS2?" },
126 { SCPI_CMD_SET_RATE, "RATE" },
127 { SCPI_CMD_GET_RATE, "RATE?" },
128 { SCPI_CMD_SET_TRIGGER, "TRIGGER" },
129 { SCPI_CMD_GET_TRIGGER, "TRIGGER?" },
133 struct fluke_scpi_dmm_model {
137 int poll_period; /* How often to poll, in ms. */
140 struct channel_spec {
142 /* Min, max, programming resolution, spec digits, encoding digits. */
145 double resistance[5];
146 double capacitance[5];
147 double conductance[5];
151 struct channel_group_spec {
153 uint64_t channel_index_mask;
159 unsigned int hw_output_idx;
164 struct dmm_channel_instance {
170 struct dmm_channel_group {
175 struct sr_sw_limits limits;
176 unsigned int num_channels;
177 const struct scpi_command *cmdset;
189 int get_reading_dd(char *reading, size_t size);
191 SR_PRIV extern const struct fluke_scpi_dmm_model dmm_profiles[];
193 SR_PRIV int fl45_scpi_receive_data(int fd, int revents, void *cb_data);
194 SR_PRIV int fl45_scpi_get_response(const struct sr_dev_inst *sdi, char *cmd);
195 SR_PRIV int fl45_get_status(const struct sr_dev_inst *sdi,
196 struct sr_datafeed_analog *analog, int idx);
197 SR_PRIV int fl45_get_modifiers(const struct sr_dev_inst *sdi,
198 struct sr_datafeed_analog *analog, int idx);