From 6f76632728f88ec1706c1d7b0f6b5376d66e0687 Mon Sep 17 00:00:00 2001 From: Robert Johansson Date: Sun, 13 May 2012 16:32:17 +0900 Subject: [PATCH] fix bug in breakout of loop due to max_frames condition --- mbus/mbus-protocol-aux.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/mbus/mbus-protocol-aux.c b/mbus/mbus-protocol-aux.c index df836e4..52e336f 100644 --- a/mbus/mbus-protocol-aux.c +++ b/mbus/mbus-protocol-aux.c @@ -24,7 +24,7 @@ #define MBUS_DEBUG(...) #endif -static int debug = 1; +static int debug = 0; typedef struct _mbus_variable_vif { unsigned vif; @@ -1557,14 +1557,7 @@ mbus_sendrecv_request(mbus_handle *handle, int address, mbus_frame *reply, int m while (more_frames) { frame_count++; - - if ((max_frames > 0) && - (frame_count > max_frames)) - { - // only readout max_frames - break; - } - + if (debug) printf("%s: debug: receiving response frame #%d\n", __PRETTY_FUNCTION__, frame_count); @@ -1601,7 +1594,8 @@ mbus_sendrecv_request(mbus_handle *handle, int address, mbus_frame *reply, int m { more_frames = 0; - if (reply_data.data_var.more_records_follow) + if (reply_data.data_var.more_records_follow && + ((max_frames > 0) && (frame_count < max_frames))) // only readout max_frames { if (debug) printf("%s: debug: expecting more frames\n", __PRETTY_FUNCTION__);