X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fdevinst.cpp;h=b28fce08269f4c3f238d01c8fd016e5aecb560ec;hp=4a152e0c6b6d119d53d7608db2817157403eff73;hb=ab4e1fcb5fc453c811d25038f872f3326f8f846e;hpb=19adbc2c342b190161ec1223377a3619974b91f7 diff --git a/pv/devinst.cpp b/pv/devinst.cpp index 4a152e0c..b28fce08 100644 --- a/pv/devinst.cpp +++ b/pv/devinst.cpp @@ -21,6 +21,8 @@ #include #include +#include + #include #include "devinst.h" @@ -66,4 +68,55 @@ string DevInst::format_device_title() const return s.str(); } +GVariant* DevInst::get_config(const sr_probe_group *group, int key) +{ + GVariant *data = NULL; + if (sr_config_get(_sdi->driver, _sdi, group, key, &data) != SR_OK) + return NULL; + return data; +} + +bool DevInst::set_config(const sr_probe_group *group, int key, GVariant *data) +{ + if(sr_config_set(_sdi, group, key, data) == SR_OK) { + config_changed(); + return true; + } + return false; +} + +GVariant* DevInst::list_config(const sr_probe_group *group, int key) +{ + GVariant *data = NULL; + if (sr_config_list(_sdi->driver, _sdi, group, key, &data) != SR_OK) + return NULL; + return data; +} + +void DevInst::enable_probe(const sr_probe *probe, bool enable) +{ + for (const GSList *p = _sdi->probes; p; p = p->next) + if (probe == p->data) { + const_cast(probe)->enabled = enable; + config_changed(); + return; + } + + // Probe was not found in the device + assert(0); +} + +uint64_t DevInst::get_sample_limit() +{ + uint64_t sample_limit; + GVariant* gvar = get_config(NULL, SR_CONF_LIMIT_SAMPLES); + if (gvar != NULL) { + sample_limit = g_variant_get_uint64(gvar); + g_variant_unref(gvar); + } else { + sample_limit = 0U; + } + return sample_limit; +} + } // pv