From d755ae38d8ce132fa7b73205e64f5a5ca16a51b7 Mon Sep 17 00:00:00 2001 From: Thomas Debrunner Date: Tue, 2 Apr 2024 10:54:35 +0200 Subject: [PATCH 1/3] libmav: update to latest --- src/libmav | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libmav b/src/libmav index 4c612dc..141060b 160000 --- a/src/libmav +++ b/src/libmav @@ -1 +1 @@ -Subproject commit 4c612dc707ec6509a5b01ee132de35c080abf90d +Subproject commit 141060be805a31354b1362f1084cc60b7f89540a From d8a2c262474af29f70e544fdae56fbe1815f8b3c Mon Sep 17 00:00:00 2001 From: Thomas Debrunner Date: Tue, 2 Apr 2024 10:54:57 +0200 Subject: [PATCH 2/3] udp server: bind join multicast group --- src/bind_PhysicalNetwork.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/bind_PhysicalNetwork.cpp b/src/bind_PhysicalNetwork.cpp index c1fb476..fd44232 100644 --- a/src/bind_PhysicalNetwork.cpp +++ b/src/bind_PhysicalNetwork.cpp @@ -51,6 +51,7 @@ void bind_PhysicalNetwork(py::module m) { py::class_(m, "UDPServer") .def(py::init(), py::arg("local_port")) + .def("join_multicast_group", &UDPServer::joinMulticastGroup) .def("close", &UDPServer::close); py::class_(m, "TCPServer") From 73b43f49c10eb93dc790520a127b2644938a9510 Mon Sep 17 00:00:00 2001 From: Thomas Debrunner Date: Tue, 2 Apr 2024 11:09:50 +0200 Subject: [PATCH 3/3] message: bind float-pack and float-unpack to python --- src/bind_Message.cpp | 8 ++++++++ src/bind_utils.cpp | 4 ++++ test.py | 5 +++++ 3 files changed, 17 insertions(+) diff --git a/src/bind_Message.cpp b/src/bind_Message.cpp index 5253c2b..2a53350 100644 --- a/src/bind_Message.cpp +++ b/src/bind_Message.cpp @@ -90,6 +90,14 @@ void bind_Message(py::module m) { py::arg("field_key"), py::arg("value"), py::arg("array_index") = 0) .def("__setitem__", &Message::set, py::arg("field_key"), py::arg("value"), py::arg("array_index") = 0) + .def("set_as_float_pack", &Message::setAsFloatPack, + py::arg("field_key"), py::arg("value"), py::arg("array_index") = 0) + .def("set_as_float_pack", &Message::setAsFloatPack, + py::arg("field_key"), py::arg("value"), py::arg("array_index") = 0) + .def("get_as_float_unpack", &Message::getAsFloatUnpack, + py::arg("field_key"), py::arg("array_index") = 0) + .def("get_as_float_unpack_unsigned", &Message::getAsFloatUnpack, + py::arg("field_key"), py::arg("array_index") = 0) .def("set_from_dict", [](Message &m, const py::dict &d) { setFromDict(m, d); return m; diff --git a/src/bind_utils.cpp b/src/bind_utils.cpp index 171ef99..8d88a21 100644 --- a/src/bind_utils.cpp +++ b/src/bind_utils.cpp @@ -47,4 +47,8 @@ void bind_utils(py::module m) { .def("crc16", &CRC::crc16) .def("crc8", &CRC::crc8); + m.def("float_pack", &floatPack); + m.def("float_pack", &floatPack); + m.def("float_unpack", &floatUnpack); + m.def("float_unpack_unsigned", &floatUnpack); } \ No newline at end of file diff --git a/test.py b/test.py index 98e6b1e..5474539 100644 --- a/test.py +++ b/test.py @@ -100,6 +100,11 @@ def testMessageSetGet(self): self.assertEqual(message['float_arr_field'], [1.0, 2.0, 3.0]) self.assertEqual(message['int32_arr_field'], [4, 5, 6]) + def testMessageFloatPackUnpack(self): + message = self.message_set.create('BIG_MESSAGE') + message.set_as_float_pack('float_field', 12) + self.assertEqual(message.get_as_float_unpack('float_field'), 12) + def testSetFromDict(self): message = self.message_set.create('BIG_MESSAGE')