diff --git a/tests/test_plc_read.py b/tests/test_plc_read.py index 5eaa241..af48c90 100644 --- a/tests/test_plc_read.py +++ b/tests/test_plc_read.py @@ -134,3 +134,32 @@ def test_comapare_values(address: str, timeout: float): assert v1 == v2 lsv2.disconnect() + + +def test_plc_mem_access(address: str, timeout: float): + """test to see if reading via plc address and plc memory returns the same value""" + + lsv2 = pyLSV2.LSV2(address, port=19000, timeout=timeout, safe_mode=False) + lsv2.connect() + + for mem_address in [0, 1, 2, 4, 8, 12, 68, 69, 151, 300, 420]: + v1 = lsv2.read_plc_memory(mem_address, pyLSV2.MemoryType.DWORD, 1)[0] + v2 = lsv2.read_plc_address("D%d" % (mem_address * 4)) + assert v1 == v2 + + for mem_address in [0, 1, 2, 4, 8, 12, 68, 69, 151, 300, 420]: + v1 = lsv2.read_plc_memory(mem_address, pyLSV2.MemoryType.WORD, 1)[0] + v2 = lsv2.read_plc_address("W%d" % (mem_address * 2)) + assert v1 == v2 + + for mem_address in [0, 1, 2, 4, 8, 12, 68, 69, 151, 300, 420]: + v1 = lsv2.read_plc_memory(mem_address, pyLSV2.MemoryType.BYTE, 1)[0] + v2 = lsv2.read_plc_address("B%d" % (mem_address * 1)) + assert v1 == v2 + + for mem_address in [0, 1, 2, 4, 8, 12, 68, 69, 151, 300, 420]: + v1 = lsv2.read_plc_memory(mem_address, pyLSV2.MemoryType.MARKER, 1)[0] + v2 = lsv2.read_plc_address("M%d" % (mem_address * 1)) + assert v1 == v2 + + lsv2.disconnect()