]> sigrok.org Git - libsigrok.git/commitdiff
python: Add override for Context.create_logic_packet()
authorMartin Ling <redacted>
Thu, 27 Dec 2018 19:38:06 +0000 (20:38 +0100)
committerUwe Hermann <redacted>
Fri, 28 Dec 2018 11:47:59 +0000 (12:47 +0100)
bindings/python/sigrok/core/classes.i

index 63a5143ebc96b8379b14a3fe86035641159719f4..a00efff2536d78911cd7a8b41f2744ad418c8479 100644 (file)
@@ -568,5 +568,23 @@ std::map<std::string, Glib::VariantBase> dict_to_map_options(PyObject *dict,
 }
 }
 
+/* Create logic packet from Python buffer. */
+%extend sigrok::Context
+{
+    std::shared_ptr<Packet> _create_logic_packet_buf(PyObject *buf, unsigned int unit_size)
+    {
+        Py_buffer view;
+        PyObject_GetBuffer(buf, &view, PyBUF_SIMPLE);
+        return $self->create_logic_packet(view.buf, view.len, unit_size);
+    }
+}
+
+%pythoncode
+{
+    def _Context_create_logic_packet(self, buf, unit_size):
+        return self._create_logic_packet_buf(buf, unit_size)
+
+    Context.create_logic_packet = _Context_create_logic_packet
+}
 
 %include "doc_end.i"