modbus
modbus copied to clipboard
EOF panic modbus tcp-client.
i just create simple mobdus tcp-client(modbus master). Everythings works perfectly. But, some of condition, my program panic triggeren and closed. this is my piece of code:
data, err := client.ReadHoldingRegisters(41201, 100)
if err != nil {
fmt.Println("e1:", err)
if strings.Contains(err.Error(), "tcp") {
break
}
}
simple and this code is buggy. my program always panic and closed when the ethernet wire is disconnected(accidentally). the error caused by EOF. how to detect EOF and i can reconnect if possible?
i just create simple mobdus tcp-client(modbus master). Everythings works perfectly. But, some of condition, my program panic triggeren and closed. this is my piece of code:
data, err := client.ReadHoldingRegisters(41201, 100) if err != nil { fmt.Println("e1:", err) if strings.Contains(err.Error(), "tcp") { break } }
simple and this code is buggy. my program always panic and closed when the ethernet wire is disconnected(accidentally). the error caused by EOF. how to detect EOF and i can reconnect if possible?
I encountered the same problem. Has your problem been solved?