2008-10-15 10:20:48     Receive data in ethernet

Document created by Aaronwu Employee on Aug 8, 2013
Version 1Show Document
  • View in full screen mode

2008-10-15 10:20:48     Receive data in ethernet

Glauber Tadeu (BRAZIL)

Message: 63722   

 

I need transfer "many" data bytes (1MB) with ethernet from a PC to blackfin (BF537-STAMP-BOARD) with uClinux.

 

What's the buffer size of ethernet in bfin? When the buffer is full (I send the max possible bytes), do I need wait or can I continue send without wait?

 

Thanks in advance...

QuoteReplyEditDelete

 

 

2008-10-15 21:46:05     Re: Receive data in ethernet

Mike Frysinger (UNITED STATES)

Message: 63745   

 

presumably you're talking about TCP/IP communication.  the stack with Linux on the Blackfin processor is the same as the stack on any Linux system.  there is no "sync" operation   there is no "wait until the buffer is empty".  the kernel handles all of the buffers for your userspace applications.

 

QuoteReplyEditDelete

 

 

2008-10-15 22:42:26     Re: Receive data in ethernet

Glauber Tadeu (BRAZIL)

Message: 63747   

 

Yes, it's TCP/IP.

 

Ok, that's I imagine... but doesnt work... When I send all bytes without wait, some bytes lost on uClinux. I need wait 5ms after each package of 100 bytes to work. Why i need this time?

 

Thanks

QuoteReplyEditDelete

 

 

2008-10-16 17:05:27     Re: Receive data in ethernet

Robin Getz (UNITED STATES)

Message: 63810   

 

Glauber:

 

Can you send some test code that reproduces the issue?

 

-Robin

QuoteReplyEditDelete

 

 

2008-10-18 01:25:36     Re: Receive data in ethernet

Glauber Tadeu (BRAZIL)

Message: 63887   

 

This code read ethernet and put in buffer the value.

 

// part of server code

 

int create_soquete_serv(int port)

{

    int sock, b;

    struct sockaddr_in nome;

    /* Cria um soquete */

    sock=socket(PF_INET, SOCK_STREAM, 0);

    if(sock < 0) erro_fatal("socket");

    nome.sin_family=AF_INET;

    nome.sin_port=htons(port);

    nome.sin_addr.s_addr=htonl(INADDR_ANY);

    /* bind: Liga um socket a uma porta de servico */

    b=bind(sock, (struct sockaddr *)&nome, sizeof(nome));

    if(b<0) erro_fatal("bind");

    /* Libera para atender conexoes na porta */

    if(listen(sock,1)<0) erro_fatal("socket");

    return sock;

}

 

int send_client(int filedes, char *msg)

{

    int nbytes;

    char send[50];

 

    nbytes=write(filedes, send, strlen(send));

    printf("write\n");

    if(nbytes<0) erro_fatal("write");

    printf("return\n");

    return nbytes;

}

 

int rcv_client(int filedes)

{

    char aux[MAXMSG];

    char buffer[MAXMSG];

    int nbytes, i;

 

    // clean buffer

    bzero(aux, MAXMSG);

    bzero(buffer, MAXMSG);

 

    // receive data

    nbytes = read(filedes, aux, MAXMSG);

    if(nbytes==0) return -1;

    else if(nbytes<0) return -2;

    //if(nbytes==0) return -1;

    for(i=0; i<MAXMSG; i++)

        if(i<nbytes)

            buffer[i] = aux[i];

        else

            buffer[i] = '\0';

 

    if(nbytes>=0) // if there is a sentence

        trata_comando(filedes, buffer);    // save the sentence

 

    return nbytes;

}

 

When I receive two sentences with 100 bytes (chars) or more I lost some bytes in second sequence. The client need wait 5ms between sentences to server understand all message.

 

Why do client wait 5ms?

 

 

 

Thanks

Attachments

    Outcomes