Various minor whitespace and consistency fixes.
[pulseview.git] / pv / binding / device.cpp
index 7547a46b341b33d3f472c2fce56812fa491fbe9c..77c772c088b07dabcbba1ed782339560527dae09 100644 (file)
@@ -56,9 +56,15 @@ namespace binding {
 Device::Device(shared_ptr<sigrok::Configurable> configurable) :
        configurable_(configurable)
 {
-       assert(configurable);
+       std::map< const ConfigKey*, std::set<Capability> > keys;
 
-       for (auto entry : configurable->config_keys(ConfigKey::DEVICE_OPTIONS)) {
+       try {
+               keys = configurable->config_keys(ConfigKey::DEVICE_OPTIONS);
+       } catch (const Error) {
+               return;
+       }
+
+       for (auto entry : keys) {
                auto key = entry.first;
                auto capabilities = entry.second;
 
@@ -82,8 +88,7 @@ Device::Device(shared_ptr<sigrok::Configurable> configurable) :
                        config_changed();
                };
 
-               switch (key->id())
-               {
+               switch (key->id()) {
                case SR_CONF_SAMPLERATE:
                        // Sample rate values are not bound because they are shown
                        // in the MainBar
@@ -106,6 +111,7 @@ Device::Device(shared_ptr<sigrok::Configurable> configurable) :
 
                case SR_CONF_EXTERNAL_CLOCK:
                case SR_CONF_RLE:
+               case SR_CONF_POWER_OFF:
                        bind_bool(name, get, set);
                        break;
 
@@ -121,6 +127,10 @@ Device::Device(shared_ptr<sigrok::Configurable> configurable) :
                        bind_enum(name, key, capabilities, get, set, print_voltage_threshold);
                        break;
 
+               case SR_CONF_PROBE_FACTOR:
+                       bind_int(name, "", pair<int64_t, int64_t>(1, 500), get, set);
+                       break;
+
                default:
                        break;
                }