diff --git a/pyS7_test.py b/pyS7_test.py new file mode 100644 index 0000000..e36cb70 --- /dev/null +++ b/pyS7_test.py @@ -0,0 +1,30 @@ +import time +from pyS7 import S7Client +import pprint + +LOOPS = 5 +counter = 0 +while counter < LOOPS: + try: + # Create a new 'S7Client' object to connect to S7-300/400/1200/1500 PLC. + # Provide the PLC's IP address and slot/rack information + client = S7Client(address="172.16.3.231", rack=0, slot=1) + + # Establish connection with the PLC + client.connect() + + # Define area tags to read + tags = [ + "DB9,DBD0", + ] + + # Read the data from the PLC using the specified tag list + data = client.read(tags=tags) + + print(data) # [True, False, 123, True, 10, -2.54943805634653e-12, 'Hello'] + except Exception as e: + pprint.pprint(e) + finally: + client.disconnect() + counter += 1 + time.sleep(1)