Skip to content

Commit

Permalink
add missing lreal to utile.py
Browse files Browse the repository at this point in the history
  • Loading branch information
spreeker committed Jan 31, 2024
1 parent 5f9de73 commit 72c52d7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions snap7/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 72c52d7

Please sign in to comment.