F-NET on K60n512 send() Function Error

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

F-NET on K60n512 send() Function Error

958件の閲覧回数
seungbackjung
Contributor II

Dear all.

I am porting F-NET 2.5 on K60n512 without RTOS.(Only Firmware.)

Then I succesed UDP Send message to Server(PC) . (10 times)

However I changed the protocol  to TCP from UDP .

And send the data to server with 10 times

But server didn't receive the data.......

Just, Server received first data.

and when, Client(Kinetis K60N) was closed() socket. server received other dataa(9 datas),

Where I check on source code????

PLS Help me.

This code is based democode is as follow.

All configuration is default.

////////////////code. ////////////////////////

        /* Create socket */

        if((fapp_bench.socket_foreign = socket(AF_INET, SOCK_STREAM, 0)) == SOCKET_INVALID)

        {

              goto ERROR_1;

        }

       

        /* Set Socket options. */

        if( /* Setup linger option. */

            (setsockopt (fapp_bench.socket_foreign, SOL_SOCKET, SO_LINGER, (char *)&linger_option, sizeof(linger_option)) == SOCKET_ERROR) ||

            /* Set socket buffer size. */

            (setsockopt(fapp_bench.socket_foreign, SOL_SOCKET, SO_RCVBUF, (char *) &bufsize_option, sizeof(bufsize_option))== SOCKET_ERROR) ||

            (setsockopt(fapp_bench.socket_foreign, SOL_SOCKET, SO_SNDBUF, (char *) &bufsize_option, sizeof(bufsize_option))== SOCKET_ERROR) ||

            /* Enable keepalive_option option. */

            (setsockopt (fapp_bench.socket_foreign, SOL_SOCKET, SO_KEEPALIVE, (char *)&keepalive_option, sizeof(keepalive_option)) == SOCKET_ERROR) ||

            /* Keepalive probe retransmit limit. */

            (setsockopt (fapp_bench.socket_foreign, IPPROTO_TCP, TCP_KEEPCNT, (char *)&keepcnt_option, sizeof(keepcnt_option)) == SOCKET_ERROR) ||

            /* Keepalive retransmit interval.*/

            (setsockopt (fapp_bench.socket_foreign, IPPROTO_TCP, TCP_KEEPINTVL, (char *)&keepintvl_option, sizeof(keepintvl_option)) == SOCKET_ERROR) ||

            /* Time between keepalive probes.*/

            (setsockopt (fapp_bench.socket_foreign, IPPROTO_TCP, TCP_KEEPIDLE, (char *)&keepidle_option, sizeof(keepidle_option)) == SOCKET_ERROR)

        )

      

        /* Connect to the server.*/

        fnet_memset(&foreign_addr, 0, sizeof(foreign_addr));

        foreign_addr.sin_addr.s_addr = SERVER_ADDR;;

        foreign_addr.sin_port = SERVER_PORT;   

        foreign_addr.sin_family = AF_INET;

       

        connect(fapp_bench.socket_foreign, (struct sockaddr *)(&foreign_addr), sizeof(foreign_addr));

       do

        {

            option_len = sizeof(connection_state);

            getsockopt(fapp_bench.socket_foreign, SOL_SOCKET, SO_STATE, (char*)&connection_state, &option_len);

        }

        while (connection_state == SS_CONNECTING);

       

        if(connection_state != SS_CONNECTED)

        {

           goto ERROR_2;

        }

       

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

        {

            send_result = send( fapp_bench.socket_foreign, (char*)test_data, 1030, 0);   //10 times send.

          }          

ラベル(2)
0 件の賞賛
返信
2 返答(返信)

545件の閲覧回数
Hui_Ma
NXP TechSupport
NXP TechSupport

I do a test with FNET [benchmark] demo to send 10 tcp frames with 1500 bytes.

If there just with below code, there could cause some delay to get the TCP package:

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

        {

          send_result = send( fapp_bench.socket_foreign, (char*)(&fapp_bench.buffer[buffer_offset]), (packet_size-buffer_offset), 0);

            if ( send_result == SOCKET_ERROR )

            {        fnet_shell_println(desc, "socket error" );}

            else if(send_result == FNET_OK)

            {      

              fnet_shell_println(desc, "send ok" );

            }

  }

If I add some delay during the TCP package transmit, there will be much better, you could get Ethernet package transfer status from attached picture below.

Ethernet monitor status.png

I think your code without any problem, the way to send data package could cause the transmit problem.

I have checked there with Kinetis 100MHz errata e6358, which shows If the ready bit in the transmit buffer descriptor (TxBD[R]) is previously detected as not set during a prior frame transmission, then at a later time the ENET_TDAR[TDAR] bit is cleared even if additional TxBDs were added to the ring and the ENET_TDAR[TDAR] bit set. 

You could get more detailed info from below link:

http://cache.freescale.com/files/microcontrollers/doc/errata/KINETIS_8N30D.pdf

So, I suggest to use workaround way to detect the previous package had been send, then transfer the next package.

Wish it helps.

0 件の賞賛
返信

545件の閲覧回数
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi Jung,

I am checking with this thread, it will take some time, I will let you know when I could get any updated info.

Thank you for the patience.

B.R.

Ma Hui

0 件の賞賛
返信