This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

RTOS/OMAP-L138: NDK_EWOULDBLOCK error when I receive data more than 1456B

Part Number: OMAP-L138

Tool/software: TI-RTOS

Hi,

I have a problem with the NDK_recv function. When I receive less then 1456B of data the program works correctly but when I want  to receive more then 1456B then NDK_recv returns -1 and I see am error NDK_EWOULDBLOCK..

static void NetworkOpen()
{
    hFtp =   DaemonNew( SOCK_STREAM,     0, 21,      dtask_ftp,          OS_TASKPRINORM,  65536, 0, 3);
}

int dtask_ftp(SOCKET s, uint32_t unused){

    struct timeval timeout;

    int ret;

    char buffer[BSIZE];
    int bytes_read;

    Command cmd;// = malloc(sizeof(Command));
    State state;

    /* Configure our socket timeout to be 5 seconds */
    timeout.tv_sec  = 10;
    timeout.tv_usec = 0;

    setsockopt( s, SOL_SOCKET, SO_SNDTIMEO, &timeout, sizeof(timeout) );

    timeout.tv_sec  = 40;   //Ustawienie na 40 sek, gdyz niektore menadzery do FTP wysylaja co okolo 30s zapytanie o nowe dane,
                            //jak bedzie rzadziej niz 40s, wowczas polaczenie bedzie po prostu ponawiane
    timeout.tv_usec = 0;
    setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(timeout) );

    //setsockopt(s, SOL_SOCKET, SO_DEBUG, NULL, 0 );


/** Handle STOR command. TODO: check permissions. */
void ftp_stor(Command *cmd, State *state){

SOCKET connection = NULL;
FRESULT fr;
FIL file;
char buf[BUF_SIZE];
unsigned int numWrite;
int numRecv;

int recv_total = 0;
int fileOpenFlag = 0;

if(state->logged_in){

/* Passive mode */
if(state->mode == SERVER){

fr = f_open(&file, cmd->arg, FA_CREATE_ALWAYS | FA_WRITE); //otwarcie pliku w trybie do zapisu,
//jezeli isnieje to zostanie nadpisany,
//jezeli nie, to zostanie utworzony

if(fr == FR_OK){

fileOpenFlag = 1;
connection = accept_connection(state->sock_pasv);
if(fdClose(state->sock_pasv)){
PRINTF_DEBUG("%s %s():%d, fdClose(), nieudana proba zamkniecia socketu\r\n", __FILE__, __FUNCTION__, __LINE__);
}

state->message = "125 Data connection already open; transfer starting.\n";
write_state(state);

recv_total = 0;

int i = 0;

while(1){

//PRINTF_DEBUG("czekanie na dane, i = %d\r\n", i);
numRecv = recv(connection, buf, BUF_SIZE, MSG_WAITALL ); //HERE I HAVE A PROBLEM

.........................


I'm using the latest SDK

Where should I look for a problem?

Regards, Patryk

  • Hi Patryk,

    From section 4.3.1 of the TI NDK User's Guide (Rev. K):

    "The PBM buffers are configured in the Buffers tab of the Global module configuration in XGCONF. You can set the Number of frames (default = 192), the Frame buffer size (default=1536 bytes), and the memory section where the buffers are stored. 

    Note that when the memory is declared, it is placed on a cache aligned boundary. Also, each packet buffer must be an even number of cache lines in size so that it can be reliably flushed without the risk of conflicting with other buffers."

    Can you see if increasing the buffer size resolves your issue? 

    Also, please see section 2.4.1 Troubleshooting Common Problems:

    UDP application drops packets on NDK_recv() calls.

    • Make sure you have plenty of packet buffers available (see Section 4.3.1).

    • Make sure the packet threshold for UDP is high enough to hold all UDP data received in between calls to NDK_recv() (see CFGITEM_IP_SOCKUDPRXLIMIT in the NDK Programmer’s Reference Guide).

    • Verify you do not have any scheduling issues. Try running the scheduler in high priority (via NC_SystemOpen()).

    • It is possible that packets are being dropped by the Ethernet device driver. Some device drivers have adjustable RX queue depths, while others do not. Refer to the source code of your Ethernet device driver for more details (device driver source code is provided in NDK Support Package for your hardware platform).