X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=bindings%2Fcxx%2Fclasses.cpp;h=19b4f8f0c3c5c53ac5472d2faded5b2dc3043b75;hb=032da34b786333a1af811235c5cf29855479f0b6;hp=efb4995db6152f705053f041830daae6c04fbdd6;hpb=e835e8080b6278137ea90f3b10e5d8bc51136a91;p=libsigrok.git
diff --git a/bindings/cxx/classes.cpp b/bindings/cxx/classes.cpp
index efb4995d..19b4f8f0 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
@@ -77,7 +77,7 @@ Context::Context() :
{
check(sr_init(&_structure));
- struct sr_dev_driver **driver_list = sr_driver_list();
+ struct sr_dev_driver **driver_list = sr_driver_list(_structure);
if (driver_list)
for (int i = 0; driver_list[i]; i++)
_drivers[driver_list[i]->name] =
@@ -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),
@@ -638,8 +652,7 @@ string Channel::name()
void Channel::set_name(string name)
{
- check(sr_dev_channel_name_set(_parent->_structure,
- _structure->index, name.c_str()));
+ check(sr_dev_channel_name_set(_structure, name.c_str()));
}
const ChannelType *Channel::type()
@@ -654,7 +667,7 @@ bool Channel::enabled()
void Channel::set_enabled(bool value)
{
- check(sr_dev_channel_enable(_parent->_structure, _structure->index, value));
+ check(sr_dev_channel_enable(_structure, value));
}
unsigned int Channel::index()
@@ -875,7 +888,7 @@ Session::Session(shared_ptr context) :
_context(context),
_saving(false)
{
- check(sr_session_new(&_structure));
+ check(sr_session_new(context->_structure, &_structure));
_context->_session = this;
}
@@ -885,7 +898,7 @@ Session::Session(shared_ptr context, string filename) :
_filename(filename),
_saving(false)
{
- check(sr_session_load(filename.c_str(), &_structure));
+ check(sr_session_load(context->_structure, filename.c_str(), &_structure));
GSList *dev_list;
check(sr_session_dev_list(_structure, &dev_list));
for (GSList *dev = dev_list; dev; dev = dev->next)
@@ -1371,15 +1384,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