question

jocm avatar image
jocm asked

Modbus/TCP not working on boot - works after service restart

I have a battery powered machine and use Cerbo GX with a Smartshunt to provide battery/charge status to users. To save battery power the Cerbo GX is powered down when the system is turned off (the Smartshunt stays powered).

For some reason the Modbus/TCP service which I connect to from a PLC doesn't work when the system is powered on. If I go to settings->services->Modbus/TCP and then disable and enable it again while the system is powered on everything works fine. Also, if I disconnect and reconnect from the PLC side it will also work.

This is an example of the error message i get:

mtcp-er.png

About 50% of the time the message is about trying to read register 806&807 (relays) instead.

The strange thing is that I can write to those registers just fine and the relays toggle, but trying to read the very same registers doesn't work.

Am I doing something wrong here?

Modbus TCP
mtcp-er.png (22.7 KiB)
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

1 Answer
jocm avatar image
jocm answered ·

I was able to work around this by delaying the connection after system power on. This is not ideal because it will take a minute after bootup before my customer can check battery state, but for now it is ok. I could also change my code to not use a keep-alive socket and reconnect on every poll, which may be better.


I think there is some bug in the Modbus/TCP server if you connect too soon after power on, it's like the server is responding but there's no data configured yet. This has not been an issue on previous firmware.

2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

Related Resources