IndustrialEnergyTracker/snap7_test.py
Igor Barcik f72b2eca75 "Enhance PLC data monitoring and error handling"
Key changes include:

Improved error handling and logging in PLC data reading
Added detailed debug information with pprint
Restructured logging format for better readability
Removed redundant docstrings
Fixed PLC data reading logic with proper value extraction
Added support for extra properties in logger setup
Code cleanup and formatting improvements
2024-12-11 07:20:07 +01:00

18 lines
340 B
Python

import time
import snap7
import pprint
LOOPS = 5
counter = 0
while counter < LOOPS:
try:
plc = snap7.client.Client()
plc.connect("172.16.4.220", 0, 1)
pprint.pprint(plc.get_cpu_state())
except Exception as e:
pprint.pprint(e)
finally:
plc.disconnect()
counter += 1
time.sleep(1)