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
26 #include <libsigrok/libsigrok.h>
30 using std::ostringstream;
35 DevInst::DevInst(sr_dev_inst *sdi) :
41 sr_dev_inst* DevInst::dev_inst() const
46 string DevInst::format_device_title() const
52 if (_sdi->vendor && _sdi->vendor[0]) {
54 if ((_sdi->model && _sdi->model[0]) ||
55 (_sdi->version && _sdi->version[0]))
59 if (_sdi->model && _sdi->model[0]) {
61 if (_sdi->version && _sdi->version[0])
65 if (_sdi->version && _sdi->version[0])
71 GVariant* DevInst::get_config(const sr_probe_group *group, int key)
73 GVariant *data = NULL;
74 if (sr_config_get(_sdi->driver, _sdi, group, key, &data) != SR_OK)
79 bool DevInst::set_config(const sr_probe_group *group, int key, GVariant *data)
81 if(sr_config_set(_sdi, group, key, data) == SR_OK) {
88 GVariant* DevInst::list_config(const sr_probe_group *group, int key)
90 GVariant *data = NULL;
91 if (sr_config_list(_sdi->driver, _sdi, group, key, &data) != SR_OK)
96 void DevInst::enable_probe(const sr_probe *probe, bool enable)
98 for (const GSList *p = _sdi->probes; p; p = p->next)
99 if (probe == p->data) {
100 const_cast<sr_probe*>(probe)->enabled = enable;
105 // Probe was not found in the device
109 uint64_t DevInst::get_sample_limit()
111 uint64_t sample_limit;
112 GVariant* gvar = get_config(NULL, SR_CONF_LIMIT_SAMPLES);
114 sample_limit = g_variant_get_uint64(gvar);
115 g_variant_unref(gvar);