rscada / libmbus

Meter-bus library and utility programs
http://www.rscada.se/libmbus
BSD 3-Clause "New" or "Revised" License
217 stars 137 forks source link

Problem: mbus_serial_recv_frame() timeout check fails if first read()==0 #106

Closed sappo closed 8 years ago

sappo commented 8 years ago

Solution: Additionally check if len==0.

If the first read() of the loop returns with 0 the timeouts counter is incremented but on the same time mbus_parse() will return with remaining <= 0. Thus the 3 retires that the timeouts counters should guarantee are skip all together.

lategoodbye commented 8 years ago

Hi @sappo, the intention of this function is to wait only one timeout period for a reply. The timeout counter is only for those cases with a partial reply. If i would apply your pull request a scan would take a huge amout of time. In order avoid confusion we will add a comment about timeout handling.

sappo commented 8 years ago

@lategoodbye thanks for clarifying.