Skip to main content
. 2023 Jun 18;23(12):5694. doi: 10.3390/s23125694
Listing 2. Code snippet using Snap7 to extract a variable from a PLC.
db_number = 129
start_byte = 0
client = snap7.client.Client()
client.connect(PLC_IP, rack=0, slot=2)
byte_array = client.db_read(db_number, start_byte, 4)
value = snap7.util.get_real(byte_array,0)