]> sigrok.org Git - libsigrok.git/commitdiff
bindings: Revise Session::append() API.
authorMartin Ling <redacted>
Thu, 24 Jul 2014 11:43:27 +0000 (12:43 +0100)
committerMartin Ling <redacted>
Thu, 24 Jul 2014 22:42:53 +0000 (23:42 +0100)
bindings/cxx/classes.cpp
bindings/cxx/include/libsigrok/libsigrok.hpp

index 889c996e8dfcf948acaa99d0c8422161ab374a9e..5833c33277649c14bc6ed8516f5b1a28c1c57260 100644 (file)
@@ -729,7 +729,7 @@ void Session::begin_save(string filename)
        save_samplerate = 0;
 }
 
-void Session::append(shared_ptr<Device> device, shared_ptr<Packet> packet)
+void Session::append(shared_ptr<Packet> packet)
 {
        if (!saving)
                throw Error(SR_ERR);
@@ -756,8 +756,9 @@ void Session::append(shared_ptr<Device> device, shared_ptr<Packet> 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> device, shared_ptr<Packet> packet)
                        {
                                vector<shared_ptr<Channel>> 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> device, shared_ptr<Packet> 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)
 {
index c4150904b87fd344146c51aad0aa84a0ae34bfdb..960d0d69e97c5797775b4607cdb82712e1e0f9d3 100644 (file)
@@ -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> device, shared_ptr<Packet> packet);
+       void append(shared_ptr<Packet> 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<Trigger> get_trigger();
        /** Set trigger setting. */