From 72c52d7aabebfb0d8ab9a1697a1209d30484b2b1 Mon Sep 17 00:00:00 2001 From: Stephan Preeker Date: Wed, 31 Jan 2024 10:17:32 +0100 Subject: [PATCH] add missing lreal to utile.py --- snap7/util.py | 3 +++ tests/test_util.py | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/snap7/util.py b/snap7/util.py index 97f61024..cf44ef83 100644 --- a/snap7/util.py +++ b/snap7/util.py @@ -1801,6 +1801,9 @@ def set_value(self, byte_index: Union[str, int], type_: str, value: Union[bool, if type_ == 'REAL': return set_real(bytearray_, byte_index, value) + if type_ == 'LREAL': + return set_lreal(bytearray_, byte_index, value) + if isinstance(value, int): type_to_func = { 'DWORD': set_dword, diff --git a/tests/test_util.py b/tests/test_util.py index ab5bcb53..90e03f49 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -143,6 +143,12 @@ def test_set_byte(self): row['testByte'] = 255 self.assertEqual(row['testByte'], 255) + def test_set_lreal(self): + test_array = bytearray(_bytearray) + row = util.DB_Row(test_array, test_spec, layout_offset=4) + row['testLreal'] = 123.123 + self.assertEqual(row['testLreal'], 123.123) + def test_get_s5time(self): """ S5TIME extraction from bytearray