2 * This file is part of the PulseView project.
4 * Copyright (C) 2014 Joel Holdsworth <joel@airwebreathe.org.uk>
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 2 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, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 #include <libsigrok/libsigrok.h>
29 #include <pv/sigsession.h>
34 DevInst::DevInst(sr_dev_inst *sdi) :
41 sr_dev_inst* DevInst::dev_inst() const
46 void DevInst::use(SigSession *owner)
54 void DevInst::release()
57 _owner->release_device(this);
63 SigSession* DevInst::owner() const
68 GVariant* DevInst::get_config(const sr_probe_group *group, int key)
70 GVariant *data = NULL;
71 if (sr_config_get(_sdi->driver, _sdi, group, key, &data) != SR_OK)
76 bool DevInst::set_config(const sr_probe_group *group, int key, GVariant *data)
78 if(sr_config_set(_sdi, group, key, data) == SR_OK) {
85 GVariant* DevInst::list_config(const sr_probe_group *group, int key)
87 GVariant *data = NULL;
88 if (sr_config_list(_sdi->driver, _sdi, group, key, &data) != SR_OK)
93 void DevInst::enable_probe(const sr_probe *probe, bool enable)
95 for (const GSList *p = _sdi->probes; p; p = p->next)
96 if (probe == p->data) {
97 const_cast<sr_probe*>(probe)->enabled = enable;
102 // Probe was not found in the device
106 uint64_t DevInst::get_sample_limit()
108 uint64_t sample_limit;
109 GVariant* gvar = get_config(NULL, SR_CONF_LIMIT_SAMPLES);
111 sample_limit = g_variant_get_uint64(gvar);
112 g_variant_unref(gvar);