2 * This file is part of the sigrok project.
4 * Copyright (C) 2012 Bert Vermeulen <bert@biot.com>
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/>.
21 #include "libsigrok.h"
22 #include "libsigrok-internal.h"
26 SR_PRIV struct sr_dev_driver driver_info;
27 static struct sr_dev_driver *di = &driver_info;
29 /* TODO move to header file */
30 struct drv_context { GSList *instances; };
31 struct dev_context { };
33 /* Properly close and free all devices. */
34 static int clear_instances(void)
36 struct sr_dev_inst *sdi;
37 struct drv_context *drvc;
38 struct dev_context *devc;
42 for (l = drvc->instances; l; l = l->next) {
43 if (!(sdi = l->data)) {
44 /* Log error, but continue cleaning up the rest. */
45 sr_err("TODO: %s: sdi was NULL, continuing", __func__);
48 if (!(devc = sdi->priv)) {
49 /* Log error, but continue cleaning up the rest. */
50 sr_err("TODO: %s: sdi->priv was NULL, continuing", __func__);
56 sr_dev_inst_free(sdi);
59 g_slist_free(drvc->instances);
60 drvc->instances = NULL;
65 static int hw_init(void)
67 struct drv_context *drvc;
69 if (!(drvc = g_try_malloc0(sizeof(struct drv_context)))) {
70 sr_err("TODO: driver context malloc failed.");
81 static GSList *hw_scan(GSList *options)
83 struct drv_context *drvc;
89 drvc->instances = NULL;
96 static GSList *hw_dev_list(void)
98 struct drv_context *drvc;
102 return drvc->instances;
105 static int hw_dev_open(struct sr_dev_inst *sdi)
113 static int hw_dev_close(struct sr_dev_inst *sdi)
121 static int hw_cleanup(void)
131 static int hw_info_get(int info_id, const void **data,
132 const struct sr_dev_inst *sdi)
145 static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
150 if (sdi->status != SR_ST_ACTIVE)
163 static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
172 static int hw_dev_acquisition_stop(const struct sr_dev_inst *sdi,
178 if (sdi->status != SR_ST_ACTIVE)
186 SR_PRIV struct sr_dev_driver driver_info = {
188 .longname = "Fluke 18x/28x series DMMs",
191 .cleanup = hw_cleanup,
193 .dev_list = hw_dev_list,
194 .dev_clear = clear_instances,
195 .dev_open = hw_dev_open,
196 .dev_close = hw_dev_close,
197 .info_get = hw_info_get,
198 .dev_config_set = hw_dev_config_set,
199 .dev_acquisition_start = hw_dev_acquisition_start,
200 .dev_acquisition_stop = hw_dev_acquisition_stop,