ottowayi / pycomm3

A Python Ethernet/IP library for communicating with Allen-Bradley PLCs.
MIT License
397 stars 88 forks source link

Ping the device #166

Closed ld-satori closed 3 years ago

ld-satori commented 3 years ago

Since the controller will drop the inactive connection after a period of idle time, I am wondering what is the best approach to keep pinging the controller and keep the connection long live. Will the following work? Thanks

comm = LogixDriver(ip, init_tags=False)
comm.open()
comm.close()
ottowayi commented 3 years ago

You can leave the connection open, you just need to periodically send some sort of message. What I do is plc.get_plc_name() every 30s or so (I think the timeout is pretty high, but forgetting exactly what it is) and that will keep the PLC from closing the connection.

ld-satori commented 3 years ago

@ottowayi thanks