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.

Compiler/TM4C1294NCPDT: TM4C1294NCPDT

Part Number: TM4C1294NCPDT

Tool/software: TI C/C++ Compiler

  1.         Controller                            : TM4C1294NCNPDT
  2.         Make                                    : Texas Instruments
  3.          Ethernet communication :   TCP protocol
  4.           issue facing :

Our controller is configured as server and we need to communicate with two clients parallel through TCP protocol.

At present we are not facing issue by sending one by one request to controller (server) from two client.

But if we send data request from server to client1 and client 2 in same time controller is responding for any one request (second request) and it is not sending for response for first request.

Also, if controller receives another request from client 2 while sending of data to client 1, controller stops sending data to client 1 and sends data to client 2 for the request. Due to this we are facing data loss issue in client side

We need to communicate with two clients simultaneously from controller (server) as like multithreading

 

Looking forward for your favourable reply

  • Hi,
    What type of TCP stacks do you use, i.e. LwIP?
  • Dear Sir,

           Im new to TCP protocol,Please guide me ,I will post my source code for ur reference.

    uip_init(void)
    {
    #if UIP_TCP
    for(c = 0; c < UIP_LISTENPORTS; ++c) {
    uip_listenports[c] = 0;
    }
    for(c = 0; c < UIP_CONNS; ++c) {
    uip_conns[c].tcpstateflags = UIP_CLOSED;
    }
    #endif /* UIP_TCP */
    #if UIP_ACTIVE_OPEN
    lastport = 1024;
    #endif /* UIP_ACTIVE_OPEN */

    #if UIP_UDP
    for(c = 0; c < UIP_UDP_CONNS; ++c) {
    uip_udp_conns[c].lport = 0;
    }
    #endif /* UIP_UDP */

    //////////////////////////////////////////////////////////////////////////

    uip_connect(uip_ipaddr_t *ripaddr, u16_t rport)
    {
    register struct uip_conn *conn, *cconn;

    /* Find an unused local port. */
    again:
    ++lastport;

    if(lastport >= 32000) {
    lastport = 4096;
    }

    /* Check if this port is already in use, and if so try to find
    another one. */
    for(c = 0; c < UIP_CONNS; ++c) {
    conn = &uip_conns[c];
    if(conn->tcpstateflags != UIP_CLOSED &&
    conn->lport == htons(lastport)) {
    goto again;
    }
    }

    conn = 0;
    for(c = 0; c < UIP_CONNS; ++c) {
    cconn = &uip_conns[c];
    if(cconn->tcpstateflags == UIP_CLOSED) {
    conn = cconn;
    break;
    }
    if(cconn->tcpstateflags == UIP_TIME_WAIT) {
    if(conn == 0 ||
    cconn->timer > conn->timer) {
    conn = cconn;
    }
    }
    }

    if(conn == 0) {
    return 0;
    }

    conn->tcpstateflags = UIP_SYN_SENT;

    conn->snd_nxt[0] = iss[0];
    conn->snd_nxt[1] = iss[1];
    conn->snd_nxt[2] = iss[2];
    conn->snd_nxt[3] = iss[3];

    conn->initialmss = conn->mss = UIP_TCP_MSS;

    conn->len = 1; /* TCP length of the SYN is one. */
    conn->nrtx = 0;
    conn->timer = 1; /* Send the SYN next time around. */
    conn->rto = UIP_RTO;
    conn->sa = 0;
    conn->sv = 16; /* Initial value of the RTT variance. */
    conn->lport = htons(lastport);
    conn->rport = rport;
    uip_ipaddr_copy(&conn->ripaddr, ripaddr);

    return conn;
    }
    #endif /* UIP_ACTIVE_OPEN && UIP_TCP */

  • Hi,

     We are not experts of the uip tcp stack. I think you will get best assistance and knowledge by posting your question in the uip forum. Reading the wikipedia about the uIP it has the below comments. It seems that simultaneously transmission is not well supported. Again, the uIP experts will be able to clarify the capabilities. 

    It is normal for IP protocol stack software to keep many copies of different IP packets, for transmission, reception and to keep copies in case they need to be resent. uIP is economical in its use of memory because it uses only one packet buffer. First, it uses the packet buffer in a half-duplex way, using it in turn for transmission and reception. Also, when uIP needs to retransmit a packet, it calls the application code in a way that requests for the previous data to be reproduced.

    Another oddity is how uIP manages connections. Most IP implementations have one task per connection, and the task communicates with a task in a distant computer on the other end of the connection. In uIP, no multitasking operating system is assumed. Connections are held in an array. On each call, uIP tries to serve a connection, making a subroutine call to application code that responds to, or sends data. The size of the connection array is a number that can be adjusted when uIP is recompiled.

  • Hi,
    I have not heard back from you. Are you able to resolve the issue and get some guidance from uIP provider? As mentioned, we are not expert in this third-party TCP stack. To me there seems to be some limitation in providing simultaneous transmission/reception at the same time using uIP. If you have resolved the issue then it is good, if not I will even suggest LwIP over uIP. My understanding of the uIP is that it is made very compact with a small footprint of program space and RAM usage. It is probably better to use uIP as a Ethernet bootloader, not a full blown application. I could be wrong if you have proven it working. In that case, please share with the community as I'm sure there will be people who can benefit from it.
  • Hi,
    I have not heard back from you. Hopefully you are able to resolve the issue. I will close the thread for now. If you have new questions you can open a new thread. If you resolved your issue you can also share with the community your methods and findings which will benefit people who are looking for the same solution.
  • Dear all, 

                Im new to  TCP  protocol, my requirement - Need to use multi threading.at present iam using QUEUE logic but its not solve my issue.so i need ur help.

    So i need sample codes For TM4C1294NCPDT using multiple threading.

    If you need i will post my existing source code here , plz help me

  • Hi,

     If you want multi-threading support you better use the OS to manage your threads. I can't think of a proper way to manage multi-threads without the OS. There are many TI-RTOS examples you can reference. The TI-RTOS has its now TCP stack called NDK.

     I will suggest you look at below references.

    For TI-RTOS trainings go to below link. You will find both the video and PDF training slides/examples

    For TI-RTOS examples for TM4C129 you can use the TI Resource Explorer and see many examples. Below screenshot shows some Ethernet examples.

  • Hi,
    I hope you had a chance to go through the TI-RTOS training and get a feel for multi threading support using a proper OS - for which the purpose of the OS is to handle the task scheduling in a multi-threading environment. I will close the thread for now. Your question is becoming more software management rather than TM4C129 usage. If your new questions is deviating from the original question please open a new thread.