X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=bindings%2Fcxx%2Fclasses.cpp;h=f8a0231497c599480be06565c735650b3e612453;hb=8b2a184327900fd7d08bb09f58699d62e2578eea;hp=a5c9e4cdfa689a011c8ef1e445391d4b1b9b11b6;hpb=8a174d23427735617d69c7502ed8dcade786bbf9;p=libsigrok.git diff --git a/bindings/cxx/classes.cpp b/bindings/cxx/classes.cpp index a5c9e4cd..f8a02314 100644 --- a/bindings/cxx/classes.cpp +++ b/bindings/cxx/classes.cpp @@ -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] = @@ -652,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() @@ -668,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() @@ -889,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; } @@ -899,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) @@ -1439,9 +1438,9 @@ shared_ptr Input::device() return _device->get_shared_pointer(shared_from_this()); } -void Input::send(string data) +void Input::send(void *data, size_t length) { - auto gstr = g_string_new(data.c_str()); + auto gstr = g_string_new_len((gchar *)data, length); auto ret = sr_input_send(_structure, gstr); g_string_free(gstr, false); check(ret); @@ -1566,10 +1565,33 @@ shared_ptr OutputFormat::create_output( Output::Deleter()); } +shared_ptr OutputFormat::create_output(string filename, + shared_ptr device, map options) +{ + return shared_ptr( + new Output(filename, shared_from_this(), device, options), + Output::Deleter()); +} + +bool OutputFormat::test_flag(const OutputFlag *flag) +{ + return sr_output_test_flag(_structure, flag->id()); +} + Output::Output(shared_ptr format, shared_ptr device, map options) : UserOwned(sr_output_new(format->_structure, - map_to_hash_variant(options), device->_structure)), + map_to_hash_variant(options), device->_structure, NULL)), + _format(format), + _device(device), + _options(options) +{ +} + +Output::Output(string filename, shared_ptr format, + shared_ptr device, map options) : + UserOwned(sr_output_new(format->_structure, + map_to_hash_variant(options), device->_structure, filename.c_str())), _format(format), _device(device), _options(options)