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>
39 void DevInst::use(SigSession *owner) throw(QString)
46 void DevInst::release()
49 _owner->release_device(this);
54 SigSession* DevInst::owner() const
59 GVariant* DevInst::get_config(const sr_channel_group *group, int key)
61 GVariant *data = NULL;
63 sr_dev_inst *const sdi = dev_inst();
65 if (sr_config_get(sdi->driver, sdi, group, key, &data) != SR_OK)
70 bool DevInst::set_config(const sr_channel_group *group, int key, GVariant *data)
73 sr_dev_inst *const sdi = dev_inst();
75 if(sr_config_set(sdi, group, key, data) == SR_OK) {
82 GVariant* DevInst::list_config(const sr_channel_group *group, int key)
84 GVariant *data = NULL;
86 sr_dev_inst *const sdi = dev_inst();
88 if (sr_config_list(sdi->driver, sdi, group, key, &data) != SR_OK)
93 void DevInst::enable_probe(const sr_channel *probe, bool enable)
96 sr_dev_inst *const sdi = dev_inst();
98 for (const GSList *p = sdi->channels; p; p = p->next)
99 if (probe == p->data) {
100 const_cast<sr_channel*>(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);
122 bool DevInst::is_trigger_enabled() const
127 void DevInst::start()
129 if (sr_session_start(SigSession::_sr_session) != SR_OK)
130 throw tr("Failed to start session.");
135 sr_session_run(SigSession::_sr_session);