From ab91feafd097f96aabe98a1c71b060d9fbef6adb Mon Sep 17 00:00:00 2001 From: Wolfgang Hottgenroth Date: Wed, 17 Jul 2019 14:17:51 +0100 Subject: [PATCH] fix uint32 converter --- src/Converters.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Converters.py b/src/Converters.py index 8870fc6..9ca0ea6 100644 --- a/src/Converters.py +++ b/src/Converters.py @@ -3,7 +3,7 @@ # out: from MQTT to Modbus, input is the format received from MQTT, output shall be a list of # 16bit integers to be written to the Modbus slave -import struct +from struct import pack, unpack Converters = { @@ -12,7 +12,7 @@ Converters = { "out": None }, "uint32": { - "in": lambda x : struct.unpack('I', x)[0], - "out": lambda x : struct.pack('I', x) + "in": lambda x : unpack('L', pack('HH', *x))[0], + "out": lambda x : unpack('HH', pack('L', x)) } -} \ No newline at end of file +}