I have a working code that I use to send ModbusTCP commands to a device that can read them and perform actions. When network is fine, it works as expected. But if link is down, the packets are stored and buffered somewhere in either the pyModbusTCP or Linux (debian 9 based) buffers, and when the connection re-establishes, are the packets are flushed, causing some unintended behaviour.
Another thing that I’ve noticed is that the buffer eats RAM, and I eventually run out (though the machine has only 256Mb).
The python script that generates the ModbusTCP commands is run every minute via crontab, and there is approx. 10 seconds after the run until it starts again. Is there a way to clear the buffer from either Linux commands or python script itself during this time?
I’ve tried having the auto close option set as True:
mb_client = ModbusClient(host=host, auto_open=True, auto_close = True, port=port, debug=False)
But the buffering still happens.