From 4dd1401698e008fa7339c2bde63214949384f239 Mon Sep 17 00:00:00 2001 From: nakarlsson Date: Sat, 14 May 2016 15:16:45 +0200 Subject: [PATCH] Add condition that frame must med _TX to be marked as RCVD --- oshw/intime/nicdrv.c | 8 ++------ oshw/linux/nicdrv.c | 4 ++-- oshw/rtk/nicdrv.c | 4 ++-- oshw/win32/nicdrv.c | 9 ++------- 4 files changed, 8 insertions(+), 17 deletions(-) diff --git a/oshw/intime/nicdrv.c b/oshw/intime/nicdrv.c index f0d8276..a476c23 100644 --- a/oshw/intime/nicdrv.c +++ b/oshw/intime/nicdrv.c @@ -137,13 +137,7 @@ int ecx_setupnic(ecx_portt *port, const char *ifname, int secondary) if (status != E_OK) { ECAT_PRINT_ERROR("hpeOpen failed with status %04x ", status); - if(status == E_EXIST) ECAT_PRINT_ERROR("E_EXIST\n"); - else if(status == E_STATE) ECAT_PRINT_ERROR("E_STATE\n"); else if(status == E_PARAM) ECAT_PRINT_ERROR("E_PARAM\n"); - else if(status == E_INVALID_ADDR) ECAT_PRINT_ERROR("E_INVALID_ADDR\n"); - else if(status == E_IO) ECAT_PRINT_ERROR("E_IO\n"); - else if(status == E_TIME) ECAT_PRINT_ERROR("E_TIME\n"); - else ECAT_PRINT_ERROR("UNKNOWN\n"); result = 0; goto end; } @@ -534,6 +528,7 @@ int ecx_inframe(ecx_portt *port, int idx, int stacknumber) } else { + WaitForRtControl(port->rx_region); /* non blocking call to retrieve frame from socket */ if (ecx_recvpkt(port, stacknumber)) { @@ -572,6 +567,7 @@ int ecx_inframe(ecx_portt *port, int idx, int stacknumber) } } } + ReleaseRtControl(); } /* WKC if mathing frame found */ diff --git a/oshw/linux/nicdrv.c b/oshw/linux/nicdrv.c index 8f403d9..29170c1 100644 --- a/oshw/linux/nicdrv.c +++ b/oshw/linux/nicdrv.c @@ -453,8 +453,8 @@ int ecx_inframe(ecx_portt *port, int idx, int stacknumber) } else { - /* check if index exist? */ - if (idxf < EC_MAXBUF) + /* check if index exist and someone is waiting for it */ + if (idxf < EC_MAXBUF && (*stack->rxbufstat)[idxf] == EC_BUF_TX) { rxbuf = &(*stack->rxbuf)[idxf]; /* put it in the buffer array (strip ethernet header) */ diff --git a/oshw/rtk/nicdrv.c b/oshw/rtk/nicdrv.c index 3ca76bb..486c20a 100644 --- a/oshw/rtk/nicdrv.c +++ b/oshw/rtk/nicdrv.c @@ -440,8 +440,8 @@ int ecx_inframe(ecx_portt *port, int idx, int stacknumber) } else { - /* check if index exist? */ - if (idxf < EC_MAXBUF) + /* check if index exist and someone is waiting for it */ + if (idxf < EC_MAXBUF && (*stack->rxbufstat)[idxf] == EC_BUF_TX) { rxbuf = &(*stack->rxbuf)[idxf]; /* put it in the buffer array (strip ethernet header) */ diff --git a/oshw/win32/nicdrv.c b/oshw/win32/nicdrv.c index 583f0e1..7f1b5ed 100644 --- a/oshw/win32/nicdrv.c +++ b/oshw/win32/nicdrv.c @@ -457,8 +457,8 @@ int ecx_inframe(ecx_portt *port, int idx, int stacknumber) } else { - /* check if index exist? */ - if (idxf < EC_MAXBUF) + /* check if index exist and someone is waiting for it */ + if (idxf < EC_MAXBUF && (*stack->rxbufstat)[idxf] == EC_BUF_TX) { rxbuf = &(*stack->rxbuf)[idxf]; /* put it in the buffer array (strip ethernet header) */ @@ -584,11 +584,6 @@ int ecx_waitinframe(ecx_portt *port, int idx, int timeout) osal_timer_start (&timer, timeout); wkc = ecx_waitinframe_red(port, idx, &timer); - /* if nothing received, clear buffer index status so it can be used again */ - if (wkc <= EC_NOFRAME) - { - ec_setbufstat(idx, EC_BUF_EMPTY); - } return wkc; }