]>
Commit | Line | Data |
---|---|---|
7a396ff5 GS |
1 | /* |
2 | * This file is part of the libsigrok project. | |
3 | * | |
4 | * Copyright (C) 2018 Gerhard Sittig <gerhard.sittig@gmx.net> | |
5 | * | |
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. | |
10 | * | |
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. | |
15 | * | |
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/>. | |
18 | */ | |
19 | ||
20 | #ifndef LIBSIGROK_HARDWARE_SCPI_DMM_PROTOCOL_H | |
21 | #define LIBSIGROK_HARDWARE_SCPI_DMM_PROTOCOL_H | |
22 | ||
3cdad416 | 23 | #include <config.h> |
7a396ff5 | 24 | #include <glib.h> |
3cdad416 GS |
25 | #include <stdint.h> |
26 | #include <stdlib.h> | |
7a396ff5 GS |
27 | #include <libsigrok/libsigrok.h> |
28 | #include "libsigrok-internal.h" | |
3cdad416 | 29 | #include "scpi.h" |
7a396ff5 GS |
30 | |
31 | #define LOG_PREFIX "scpi-dmm" | |
32 | ||
3cdad416 GS |
33 | #define SCPI_DMM_MAX_CHANNELS 1 |
34 | ||
35 | enum scpi_dmm_cmdcode { | |
36 | DMM_CMD_SETUP_REMOTE, | |
37 | DMM_CMD_SETUP_FUNC, | |
38 | DMM_CMD_QUERY_FUNC, | |
39 | DMM_CMD_START_ACQ, | |
40 | DMM_CMD_STOP_ACQ, | |
41 | DMM_CMD_QUERY_VALUE, | |
42 | DMM_CMD_QUERY_PREC, | |
43 | }; | |
44 | ||
45 | struct mqopt_item { | |
46 | enum sr_mq mq; | |
47 | enum sr_mqflag mqflag; | |
48 | const char *scpi_func_setup; | |
49 | const char *scpi_func_query; | |
50 | int default_precision; | |
51 | }; | |
52 | #define NO_DFLT_PREC -99 | |
53 | ||
54 | struct scpi_dmm_model { | |
55 | const char *vendor; | |
56 | const char *model; | |
57 | size_t num_channels; | |
58 | ssize_t digits; | |
59 | const struct scpi_command *cmdset; | |
60 | const struct mqopt_item *mqopts; | |
61 | size_t mqopt_size; | |
62 | int (*get_measurement)(const struct sr_dev_inst *sdi, size_t ch); | |
1d2f9963 GS |
63 | const uint32_t *devopts; |
64 | size_t devopts_size; | |
3cdad416 GS |
65 | }; |
66 | ||
7a396ff5 | 67 | struct dev_context { |
3cdad416 GS |
68 | size_t num_channels; |
69 | const struct scpi_command *cmdset; | |
70 | const struct scpi_dmm_model *model; | |
71 | struct sr_sw_limits limits; | |
72 | struct { | |
73 | enum sr_mq curr_mq; | |
74 | enum sr_mqflag curr_mqflag; | |
75 | } start_acq_mq; | |
76 | struct scpi_dmm_acq_info { | |
77 | float f_value; | |
78 | double d_value; | |
79 | struct sr_datafeed_packet packet; | |
80 | struct sr_datafeed_analog analog[SCPI_DMM_MAX_CHANNELS]; | |
81 | struct sr_analog_encoding encoding[SCPI_DMM_MAX_CHANNELS]; | |
82 | struct sr_analog_meaning meaning[SCPI_DMM_MAX_CHANNELS]; | |
83 | struct sr_analog_spec spec[SCPI_DMM_MAX_CHANNELS]; | |
84 | } run_acq_info; | |
7a396ff5 GS |
85 | }; |
86 | ||
3cdad416 GS |
87 | SR_PRIV void scpi_dmm_cmd_delay(struct sr_scpi_dev_inst *scpi); |
88 | SR_PRIV const struct mqopt_item *scpi_dmm_lookup_mq_number( | |
89 | const struct sr_dev_inst *sdi, enum sr_mq mq, enum sr_mqflag flag); | |
90 | SR_PRIV const struct mqopt_item *scpi_dmm_lookup_mq_text( | |
91 | const struct sr_dev_inst *sdi, const char *text); | |
92 | SR_PRIV int scpi_dmm_get_mq(const struct sr_dev_inst *sdi, | |
08f3b427 GS |
93 | enum sr_mq *mq, enum sr_mqflag *flag, char **rsp, |
94 | const struct mqopt_item **mqitem); | |
3cdad416 GS |
95 | SR_PRIV int scpi_dmm_set_mq(const struct sr_dev_inst *sdi, |
96 | enum sr_mq mq, enum sr_mqflag flag); | |
97 | SR_PRIV int scpi_dmm_get_meas_agilent(const struct sr_dev_inst *sdi, size_t ch); | |
7a396ff5 GS |
98 | SR_PRIV int scpi_dmm_receive_data(int fd, int revents, void *cb_data); |
99 | ||
100 | #endif |