Purge behavior as new context parameter (default = purge master to
slave)
This commit is contained in:
parent
78f16f0248
commit
fef774d98d
@ -1353,6 +1353,7 @@ mbus_context_serial(const char *device)
|
||||
|
||||
handle->max_retry = 3;
|
||||
handle->is_serial = 1;
|
||||
handle->purge_first_frame = MBUS_FRAME_PURGE_M2S;
|
||||
handle->auxdata = serial_data;
|
||||
handle->open = mbus_serial_connect;
|
||||
handle->close = mbus_serial_disconnect;
|
||||
@ -1395,6 +1396,7 @@ mbus_context_tcp(const char *host, int port)
|
||||
|
||||
handle->max_retry = 3;
|
||||
handle->is_serial = 0;
|
||||
handle->purge_first_frame = MBUS_FRAME_PURGE_M2S;
|
||||
handle->auxdata = tcp_data;
|
||||
handle->open = mbus_tcp_connect;
|
||||
handle->close = mbus_tcp_disconnect;
|
||||
@ -1468,11 +1470,16 @@ 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)
|
||||
switch (mbus_frame_direction(frame))
|
||||
{
|
||||
/* purge echo and retry (echo cancelation) */
|
||||
result = handle->recv(handle, frame);
|
||||
case MBUS_CONTROL_MASK_DIR_M2S:
|
||||
if (handle->purge_first_frame == MBUS_FRAME_PURGE_M2S)
|
||||
result = handle->recv(handle, frame); // purge echo and retry
|
||||
break;
|
||||
case MBUS_CONTROL_MASK_DIR_S2M:
|
||||
if (handle->purge_first_frame == MBUS_FRAME_PURGE_S2M)
|
||||
result = handle->recv(handle, frame); // purge echo and retry
|
||||
break;
|
||||
}
|
||||
|
||||
if (frame != NULL)
|
||||
|
Loading…
x
Reference in New Issue
Block a user