From 51ee6f59f6970c5629d569074daf7636d917dc38 Mon Sep 17 00:00:00 2001 From: Max Date: Thu, 30 May 2024 11:40:41 +0200 Subject: [PATCH 1/2] add dword for input and output memory --- pyLSV2/client.py | 10 ++++++++++ pyLSV2/const.py | 2 ++ 2 files changed, 12 insertions(+) diff --git a/pyLSV2/client.py b/pyLSV2/client.py index 65fc7b8..e32cfb6 100644 --- a/pyLSV2/client.py +++ b/pyLSV2/client.py @@ -1279,6 +1279,16 @@ def read_plc_memory( max_elements = self._sys_par.number_of_output_words mem_byte_count = 2 unpack_string = " Date: Thu, 20 Jun 2024 19:40:53 +0200 Subject: [PATCH 2/2] add test and demo for input/output word and dword --- pyLSV2/scripts/demo.py | 6 +++++- tests/test_plc_read.py | 5 ++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/pyLSV2/scripts/demo.py b/pyLSV2/scripts/demo.py index 17b7f98..3a4df18 100644 --- a/pyLSV2/scripts/demo.py +++ b/pyLSV2/scripts/demo.py @@ -100,7 +100,11 @@ def comprehensive_demo(): print("## double word: {}".format(con.read_plc_memory(0, MemoryType.DWORD, 5))) print("## string: {}".format(con.read_plc_memory(0, MemoryType.STRING, 5))) print("## input: {}".format(con.read_plc_memory(0, MemoryType.INPUT, 5))) - print("## output: {}".format(con.read_plc_memory(0, MemoryType.OUTPUT_WORD, 5))) + print("## output: {}".format(con.read_plc_memory(0, MemoryType.OUTPUT, 5))) + print("## input word: {}".format(con.read_plc_memory(0, MemoryType.INPUT_WORD, 5))) + print("## output word: {}".format(con.read_plc_memory(0, MemoryType.OUTPUT_WORD, 5))) + print("## input dword: {}".format(con.read_plc_memory(0, MemoryType.INPUT_DWORD, 5))) + print("## output dword: {}".format(con.read_plc_memory(0, MemoryType.OUTPUT_DWORD, 5))) print("# data values via data path, only available on some iTNC530") if con.versions.is_itnc(): diff --git a/tests/test_plc_read.py b/tests/test_plc_read.py index 4c22ef5..5eaa241 100644 --- a/tests/test_plc_read.py +++ b/tests/test_plc_read.py @@ -16,8 +16,11 @@ def test_plc_read(address: str, timeout: float): assert lsv2.read_plc_memory(0, pyLSV2.MemoryType.WORD, 1) is not False assert lsv2.read_plc_memory(0, pyLSV2.MemoryType.DWORD, 1) is not False assert lsv2.read_plc_memory(0, pyLSV2.MemoryType.STRING, 1) is not False - assert lsv2.read_plc_memory(0, pyLSV2.MemoryType.INPUT, 1) is not False assert lsv2.read_plc_memory(0, pyLSV2.MemoryType.OUTPUT_WORD, 1) is not False + assert lsv2.read_plc_memory(0, pyLSV2.MemoryType.OUTPUT_DWORD, 1) is not False + assert lsv2.read_plc_memory(0, pyLSV2.MemoryType.INPUT, 1) is not False + assert lsv2.read_plc_memory(0, pyLSV2.MemoryType.INPUT_WORD, 1) is not False + assert lsv2.read_plc_memory(0, pyLSV2.MemoryType.INPUT_DWORD, 1) is not False lsv2.logout(pyLSV2.Login.PLCDEBUG)