* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "libsigrok/libsigrok.hpp"
+#include "libsigrokcxx/libsigrokcxx.hpp"
#include <sstream>
#include <cmath>
new Input(shared_from_this(), input), Input::Deleter());
}
+map<string, string> Context::serials(shared_ptr<Driver> driver)
+{
+ GSList *serial_list = sr_serial_list(driver ? driver->_structure : NULL);
+ map<string, string> 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),
void Session::set_trigger(shared_ptr<Trigger> 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;
}
map<string, shared_ptr<Option>> InputFormat::options()
{
const struct sr_option **options = sr_input_options_get(_structure);
- auto option_array = shared_ptr<const struct sr_option *>(
- options, sr_input_options_free);
map<string, shared_ptr<Option>> result;
- for (int i = 0; options[i]; i++)
- result[options[i]->id] = shared_ptr<Option>(
- new Option(options[i], option_array), Option::Deleter());
+ if (options)
+ {
+ auto option_array = shared_ptr<const struct sr_option *>(
+ options, sr_input_options_free);
+ for (int i = 0; options[i]; i++)
+ result[options[i]->id] = shared_ptr<Option>(
+ new Option(options[i], option_array), Option::Deleter());
+ }
return result;
}
map<string, shared_ptr<Option>> OutputFormat::options()
{
const struct sr_option **options = sr_output_options_get(_structure);
- auto option_array = shared_ptr<const struct sr_option *>(
- options, sr_output_options_free);
map<string, shared_ptr<Option>> result;
- for (int i = 0; options[i]; i++)
- result[options[i]->id] = shared_ptr<Option>(
- new Option(options[i], option_array), Option::Deleter());
+ if (options)
+ {
+ auto option_array = shared_ptr<const struct sr_option *>(
+ options, sr_output_options_free);
+ for (int i = 0; options[i]; i++)
+ result[options[i]->id] = shared_ptr<Option>(
+ new Option(options[i], option_array), Option::Deleter());
+ }
return result;
}