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