From 78f16f0248f5a6da09e98bc645f10505299c7d7f Mon Sep 17 00:00:00 2001 From: Stefan Wahren Date: Thu, 4 Oct 2012 22:30:53 +0200 Subject: [PATCH] New defines for purge behavior (echo cancelation) --- mbus/mbus-protocol-aux.c | 7 +++++++ mbus/mbus-protocol-aux.h | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/mbus/mbus-protocol-aux.c b/mbus/mbus-protocol-aux.c index 57758eb..dd6ddb5 100755 --- a/mbus/mbus-protocol-aux.c +++ b/mbus/mbus-protocol-aux.c @@ -1467,6 +1467,13 @@ mbus_recv_frame(mbus_handle * handle, mbus_frame *frame) } result = handle->recv(handle, frame); + + /* frame valid, but wrong direction */ + if (mbus_frame_direction(frame) == MBUS_CONTROL_MASK_DIR_M2S) + { + /* purge echo and retry (echo cancelation) */ + result = handle->recv(handle, frame); + } if (frame != NULL) { diff --git a/mbus/mbus-protocol-aux.h b/mbus/mbus-protocol-aux.h index 5b63188..02694d9 100755 --- a/mbus/mbus-protocol-aux.h +++ b/mbus/mbus-protocol-aux.h @@ -70,12 +70,17 @@ #define MBUS_PROBE_COLLISION 2 #define MBUS_PROBE_ERROR -1 +#define MBUS_FRAME_PURGE_S2M 2 +#define MBUS_FRAME_PURGE_M2S 1 +#define MBUS_FRAME_PURGE_NONE 0 + /** * Unified MBus handle type encapsulating either Serial or TCP gateway. */ struct _mbus_handle { int fd; int max_retry; + char purge_first_frame; char is_serial; /**< _handle type (non zero for serial) */ int (*open) (struct _mbus_handle *handle); int (*close) (struct _mbus_handle *handle);