X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=bindings%2Fcxx%2Fclasses.cpp;h=c915c8a7479920a23069a8c45dfe02983a766456;hb=c7bc82ffa1b09a228a8395049e2b691cd7bd85f8;hp=da21086c50510199456e8b0a18c2a85815be825c;hpb=624d16100e0c850e2c28e10638a9e5a37cd938f1;p=libsigrok.git diff --git a/bindings/cxx/classes.cpp b/bindings/cxx/classes.cpp index da21086c..c915c8a7 100644 --- a/bindings/cxx/classes.cpp +++ b/bindings/cxx/classes.cpp @@ -17,7 +17,7 @@ * along with this program. If not, see . */ -#include "libsigrok/libsigrok.hpp" +#include "libsigrokcxx/libsigrokcxx.hpp" #include #include @@ -318,6 +318,20 @@ shared_ptr Context::open_stream(string header) new Input(shared_from_this(), input), Input::Deleter()); } +map Context::serials(shared_ptr driver) +{ + GSList *serial_list = sr_serial_list(driver ? driver->_structure : NULL); + map serials; + + for (GSList *serial = serial_list; serial; serial = serial->next) { + struct sr_serial_port *port = (sr_serial_port *) serial->data; + serials[string(port->name)] = string(port->description); + } + + g_slist_free_full(serial_list, (GDestroyNotify)sr_serial_free); + return serials; +} + Driver::Driver(struct sr_dev_driver *structure) : ParentOwned(structure), Configurable(structure, NULL, NULL), @@ -1138,7 +1152,11 @@ shared_ptr Session::trigger() void Session::set_trigger(shared_ptr trigger) { - check(sr_session_trigger_set(_structure, trigger->_structure)); + if (!trigger) + // Set NULL trigger, i.e. remove any trigger from the session. + check(sr_session_trigger_set(_structure, NULL)); + else + check(sr_session_trigger_set(_structure, trigger->_structure)); _trigger = trigger; } @@ -1367,15 +1385,27 @@ string InputFormat::description() return valid_string(sr_input_description_get(_structure)); } +vector InputFormat::extensions() +{ + vector exts; + for (const char *const *e = sr_input_extensions_get(_structure); + e && *e; e++) + exts.push_back(*e); + return exts; +} + map> InputFormat::options() { const struct sr_option **options = sr_input_options_get(_structure); - auto option_array = shared_ptr( - options, sr_input_options_free); map> result; - for (int i = 0; options[i]; i++) - result[options[i]->id] = shared_ptr