Closed kiekerjan closed 4 years ago
Strange, any idea how this can work for the rest of us?
Well, if the check for the sock value never triggers, you won't be hit by this. And that should not happen because the inverter connect happens just before it. I think it has to do with my specific installation. I have powered my rs485-2-Ethernet converter from the rs485 socket on the inverter. However, it seems that during startup (and shutdown) it can happen that not enough power is supplied to the converter, causing it to reboot. This means the socket is gone and would explain why the bug hits my situation. In the meantime I have been working on somewhat more robust code for the send_request sub as well. Once I have tested it enough, I'll share it here.
Thanks for the workover, I was planning to look into tidy and code checking, nice work!
I encountered an unending loop which brought me quite a few gigabytes of logging ;) The log shows:
This seems to be caused by send_request returning FALSE:
This FALSE is then evaluated by register_inverter:
Because Perl evaluates the FALSE value to true, register_inverter happily proceeds with trying to register a inverter with serial number FALSE. At which it fails because there is no socket (the reason that send_request returned FALSE to start with).
I think I fixed it by replacing FALSE with 0. Additionally, I added a break in the aggressive polling loop:
Without a socket, register_inverter will never succeed in registering inverters, keeping the %inverters empty and thus the while condition always true.