Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(python): avoid removal of null characters in bindings #66

Merged
merged 4 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

Release Versions:

- [2.0.1](#201)
- [2.0.0](#200)
- [1.4.1](#141)
- [1.4.0](#140)
Expand All @@ -12,6 +13,13 @@ Release Versions:
- [0.2.0](#020)
- [0.1.0](#010)

## 2.0.1

Version 2.0.1 contains a hotfix that enables socket communiction with any serialized message in Python, which was not
possible before due to an error in the bindings.

- fix(python): avoid removal of null characters in bindings (#66)

## 2.0.0

Version 2.0.0 is a major update to this repository and contains breaking changes.
Expand Down
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

IMAGE_NAME=ghcr.io/aica-technology/communication-interfaces
IMAGE_NAME=ghcr.io/aica-technology/network-interfaces
IMAGE_TAG=latest

ROS2_VERSION=humble
Expand Down
2 changes: 1 addition & 1 deletion python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from pybind11.setup_helpers import ParallelCompile, Pybind11Extension, build_ext, naive_recompile
from setuptools import setup

__version__ = "1.0.0"
__version__ = "1.0.1"

try:
status = pkgconfig.installed('communication_interfaces', f'>= {__version__}')
Expand Down
1 change: 0 additions & 1 deletion python/src/communication_interfaces_bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ PYBIND11_MODULE(communication_interfaces, m) {
std::string buffer;
auto res = socket.receive_bytes(buffer);
if (res) {
buffer.erase(std::find(buffer.begin(), buffer.end(), '\0'), buffer.end());
return py::bytes(buffer);
} else {
return py::none();
Expand Down
4 changes: 2 additions & 2 deletions python/test/test_tcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def serve(self):
response = self.server.receive_bytes()
if response is None:
pytest.fail("No response from client")
assert response.decode("utf-8") == self.client_message
assert response.decode("utf-8").rstrip("\x00") == self.client_message
assert self.server.send_bytes(self.server_message)

def test_comm(self):
Expand All @@ -28,4 +28,4 @@ def test_comm(self):
assert self.client.send_bytes(self.client_message)
response = self.client.receive_bytes()
assert response
assert response.decode("utf-8") == self.server_message
assert response.decode("utf-8").rstrip("\x00") == self.server_message
4 changes: 2 additions & 2 deletions python/test/test_udp.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def client(udp_config):


def test_send_receive(server, client):
send_string = b"Hello world"
send_string = "Hello world"

try:
server.open()
Expand All @@ -39,7 +39,7 @@ def test_send_receive(server, client):
assert client.send_bytes(send_string)
response = server.receive_bytes()
assert response
assert response == send_string
assert response.decode("utf-8").rstrip("\x00") == send_string


def test_timeout(udp_config):
Expand Down
2 changes: 1 addition & 1 deletion source/communication_interfaces/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.15)

set(COMMUNICATION_INTERFACES_VERSION 1.0.0)
set(COMMUNICATION_INTERFACES_VERSION 1.0.1)
project(communication_interfaces VERSION ${COMMUNICATION_INTERFACES_VERSION})

option(BUILD_TESTING "Build tests." OFF)
Expand Down