X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=bindings%2Fcxx%2Fclasses.cpp;h=bb709fe2613092a2a78c2ff7af7810ec4204b95c;hb=48d92e2c2e6291412e8a4d2218184112ebf0fad9;hp=7becfb65e4ae472b44c0843e96d3f26731ea8089;hpb=304be4a77186f4524e3894af8279690f28ffd98f;p=libsigrok.git diff --git a/bindings/cxx/classes.cpp b/bindings/cxx/classes.cpp index 7becfb65..bb709fe2 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; } @@ -1147,6 +1165,11 @@ string Session::filename() return _filename; } +shared_ptr Session::context() +{ + return _context; +} + Packet::Packet(shared_ptr device, const struct sr_datafeed_packet *structure) : UserOwned(structure), @@ -1365,12 +1388,15 @@ string InputFormat::description() 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