From: Martin Ling Date: Thu, 24 Jul 2014 11:43:27 +0000 (+0100) Subject: bindings: Revise Session::append() API. X-Git-Tag: libsigrok-0.4.0~1200 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=1d67cfb4eaa3884ded5d78d3ac53d19c9ee45ecb;p=libsigrok.git bindings: Revise Session::append() API. --- diff --git a/bindings/cxx/classes.cpp b/bindings/cxx/classes.cpp index 889c996e..5833c332 100644 --- a/bindings/cxx/classes.cpp +++ b/bindings/cxx/classes.cpp @@ -729,7 +729,7 @@ void Session::begin_save(string filename) save_samplerate = 0; } -void Session::append(shared_ptr device, shared_ptr packet) +void Session::append(shared_ptr packet) { if (!saving) throw Error(SR_ERR); @@ -756,8 +756,9 @@ void Session::append(shared_ptr device, shared_ptr packet) { GVariant *samplerate; - check(sr_config_get(device->structure->driver, - device->structure, NULL, SR_CONF_SAMPLERATE, &samplerate)); + check(sr_config_get(packet->device->structure->driver, + packet->device->structure, NULL, SR_CONF_SAMPLERATE, + &samplerate)); save_samplerate = g_variant_get_uint64(samplerate); @@ -768,7 +769,7 @@ void Session::append(shared_ptr device, shared_ptr packet) { vector> save_channels; - for (auto channel : device->get_channels()) + for (auto channel : packet->device->get_channels()) if (channel->structure->enabled && channel->structure->type == SR_CHANNEL_LOGIC) save_channels.push_back(channel); @@ -801,6 +802,12 @@ void Session::append(shared_ptr device, shared_ptr packet) } } +void Session::append(void *data, size_t length, unsigned int unit_size) +{ + check(sr_session_append(structure, save_filename.c_str(), + (uint8_t *) data, unit_size, length)); +} + static void datafeed_callback(const struct sr_dev_inst *sdi, const struct sr_datafeed_packet *pkt, void *cb_data) { diff --git a/bindings/cxx/include/libsigrok/libsigrok.hpp b/bindings/cxx/include/libsigrok/libsigrok.hpp index c4150904..960d0d69 100644 --- a/bindings/cxx/include/libsigrok/libsigrok.hpp +++ b/bindings/cxx/include/libsigrok/libsigrok.hpp @@ -516,7 +516,9 @@ public: /** Begin saving session to a file. */ void begin_save(string filename); /** Append a packet to the session file being saved. */ - void append(shared_ptr device, shared_ptr packet); + void append(shared_ptr packet); + /** Append raw logic data to the session file being saved. */ + void append(void *data, size_t length, unsigned int unit_size); /** Get current trigger setting. */ shared_ptr get_trigger(); /** Set trigger setting. */