2 * This file is part of the libsigrok project.
4 * Copyright (C) 2019 Derek Hageman <hageman@inthat.cloud>
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_MOOSHIMETER_DMM_PROTOCOL_H
21 #define LIBSIGROK_HARDWARE_MOOSHIMETER_DMM_PROTOCOL_H
25 #include <libsigrok/libsigrok.h>
26 #include "libsigrok-internal.h"
28 #define LOG_PREFIX "mooshimeter-dmm"
32 GSList *reorder_buffer;
40 enum tree_node_datatype {
41 TREE_NODE_DATATYPE_PLAIN = 0,
42 TREE_NODE_DATATYPE_LINK,
43 TREE_NODE_DATATYPE_CHOOSER,
44 TREE_NODE_DATATYPE_U8,
45 TREE_NODE_DATATYPE_U16,
46 TREE_NODE_DATATYPE_U32,
47 TREE_NODE_DATATYPE_S8,
48 TREE_NODE_DATATYPE_S16,
49 TREE_NODE_DATATYPE_S32,
50 TREE_NODE_DATATYPE_STRING,
51 TREE_NODE_DATATYPE_BINARY,
52 TREE_NODE_DATATYPE_FLOAT,
61 struct config_tree_node {
64 size_t index_in_parent;
66 enum tree_node_datatype type;
67 union tree_value value;
69 size_t count_children;
70 struct config_tree_node *children;
72 uint32_t update_number;
73 void (*on_update)(struct config_tree_node *node, void *param);
74 void *on_update_param;
80 struct config_tree_node tree_root;
81 struct config_tree_node *tree_id_lookup[0x7F];
82 uint32_t buffer_bps[2];
83 float buffer_lsb2native[2];
85 void (*channel_autorange[3])(const struct sr_dev_inst *sdi, float value);
87 struct sr_sw_limits limits;
88 struct sr_analog_meaning channel_meaning[3];
90 gboolean enable_value_stream;
93 SR_PRIV int mooshimeter_dmm_open(const struct sr_dev_inst *sdi);
94 SR_PRIV int mooshimeter_dmm_close(const struct sr_dev_inst *sdi);
95 SR_PRIV int mooshimeter_dmm_set_chooser(const struct sr_dev_inst *sdi, const char *path, const char *choice);
96 SR_PRIV int mooshimeter_dmm_set_integer(const struct sr_dev_inst *sdi, const char *path, int value);
97 SR_PRIV int mooshimeter_dmm_set_larger_number(const struct sr_dev_inst *sdi, const char *path, const char *parent, float number);
98 SR_PRIV gboolean mooshimeter_dmm_set_autorange(const struct sr_dev_inst *sdi, const char *path, const char *parent, float latest);
99 SR_PRIV int mooshimeter_dmm_get_chosen_number(const struct sr_dev_inst *sdi, const char *path, const char *parent, float *number);
100 SR_PRIV int mooshimeter_dmm_get_available_number_choices(const struct sr_dev_inst *sdi, const char *path, float **numbers, size_t *count);
101 SR_PRIV int mooshimeter_dmm_poll(int fd, int revents, void *cb_data);
102 SR_PRIV int mooshimeter_dmm_heartbeat(int fd, int revents, void *cb_data);