rossmann-engineering / EasyModbusTCP.NET

Modbus TCP, Modbus UDP and Modbus RTU client/server library for .NET implementations
928 stars 402 forks source link

Recursive calls for retries #20

Closed mcurry-va closed 5 years ago

mcurry-va commented 5 years ago

Very bad practise to use recursion when other methods are available.

I came across an issue whereby framing errors were occuring on the bus and the code-route was zeroing the retry count sometimes through, causing a stack overflow.

I would recommend a complete refactor to avoid recursion.

rossmann-engineering commented 5 years ago

I am always open to suggestions, but only complaining about the code quality unfortunately doesn’t help.

mcurry-va commented 5 years ago

This is an actual bug report though! The cause was from framing errors being caught on the serial port, for which the windows driver inserts '?' The stack should retry 3 times and then throw a CRC error, however a certain code route zeros the retry count when the slave address in the reply does not match.

My original report was that the fundamental recursive calls need to be fixed rather than this specific bug.