From 6e9a435813870c964dd6b4d4d3bd65f02da6e2be Mon Sep 17 00:00:00 2001 From: Sébastien Dailly Date: Sun, 11 Aug 2024 15:56:58 +0200 Subject: Updated the connection between the application and the device --- interfaces/endpoint.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'interfaces') diff --git a/interfaces/endpoint.py b/interfaces/endpoint.py index 15356c2..2fbf792 100755 --- a/interfaces/endpoint.py +++ b/interfaces/endpoint.py @@ -100,13 +100,14 @@ class EndPoint(object): self.queue.put((layout, title)) def send(self, data: list[dict[str, str]]): - """ Send the data to the macropad + """ Send the data to the macropad. The data must be the representation + of a json element. """ if self.state != self.STATE_CONNECTED: return try: - j = json.dumps( data ) - self.connection.write(bytes(j, "utf-8")) + j = json.JSONEncoder().encode( data ) + "\n" + self.connection.write(str.encode(j)) except Exception as e: print("send error", e) self.state = self.STATE_DISCONNECTED -- cgit v1.2.3