Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
353 views
in Technique[技术] by (71.8m points)

python - How to write an exception for the pymodbus via TCP connection protocol where it tells me that the device is not connected

Hello i have a problem when i implement de exception to my connection with the device using the protocol pymodbus tcp v3.4. I need that when the device is not connected, the program shows me that the device is not connected and that it waits to be connected.

this is my code for python:

# ciclo para la conexion con la pantalla HMI
def conexion(self):
    while(True):
        try:
            clientCon= self.client.connect()
        except ConnectionException:
            print("conexion fallida")
            pass
        else:
            self.client.write_coil(address=0, value=clientCon, unit=self.UNIT)
            return clientCon
question from:https://stackoverflow.com/questions/65904865/how-to-write-an-exception-for-the-pymodbus-via-tcp-connection-protocol-where-it

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...