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/TM4C1294NCPDT: RTOS

Part Number: TM4C1294NCPDT
Other Parts Discussed in Thread: SYSBIOS

Tool/software: TI-RTOS

I have created couple of tasks in my application.  one of the task as follows

Void ethcmdxmit(UArg arg0, UArg arg1)
{
    int                bytesSent1;
    int                status;
    for (;;) {
        if(sockcreated)
        {
        if(!isXmitQEmpty())
         {

            tbuff=retrieveXmitQ();
             bytesSent1=sendto(server, tbuff, 5, 0,
                                                   (struct sockaddr *)&clientAddr, addrlen);
         }
     }
    } //for loop
}
The task is created with following code snippet
   Task_Handle taskHandle;
    Task_Params taskParams;
    Error_Block eb;
    /* Make sure Error_Block is initialized */
    Error_init(&eb);
    Task_Params_init(&taskParams);
     taskParams.stackSize = 1024;
     taskParams.priority = 1;
     taskParams.arg0 = UDPPORT;
     taskHandle = Task_create((Task_FuncPtr)ethcmdxmit, &taskParams, &eb);
     if (taskHandle == NULL) {
         System_printf("main: Failed to create ethcmdxmit Task\n");
In run time the application stuck with this task( as I see from ROV).  Can you help me what could be the issue
0x2000f5c8 NDK Stack Thread 2 Blocked ti_ndk_config_Global_stackThread 0x0 0x0 780 1536 0x2000db78 n/a n/a Semaphore: 0x20000d98
0x2000f614 ti.sysbios.knl.Task.IdleTask 0 Ready ti_sysbios_knl_Idle_loop__E 0x0 0x0 124 768 0x2000e178 n/a n/a 
0x20000478  2 Blocked ethcmdrecv 0x0 0x0 332 1024 0x200004c8 n/a n/a Event: 0x200003a8
0x200008e8  1 Running ethcmdxmit 0xfa0 0x0 352 1024 0x20000938 n/a n/a 
0x20000e30  5 Terminated NS_BootTask 0x2000542c 0x0 708 2048 0x20000e80 n/a n/a 
0x200016d0  1 Ready echoFxn 0xfa0 0x0 124 1024 0x20001720 n/a n/a 
  • US is on holiday on 5/27. Your thread will be answered soon.

  • My apologies!! I went on vacation and realized I had not assigned this to an engineer.

    Since you have ethcmdxmit in an infinite loop, I except it will be running most of the time. Are the higher priorities tasks running? What exactly do you mean by "application stuck with this task"

    Todd
  • Other tasks are not getting run. Following is another task which need to receive external ip data and print "socket creation finished" when the socket is created. But this never runs. Actually I trying to modify the Udpecho example. When I comment ethcmdxmit task echoFxn is getting run.

    Void echoFxn(UArg arg0, UArg arg1)
    {
    int bytesRcvd;
    int bytesSent;
    int bytesSent1;
    int status;
    // int server;
    // fd_set readSet;
    // struct sockaddr_in localAddr;
    // struct sockaddr_in clientAddr;
    // socklen_t addrlen;
    char buffer[UDPPACKETSIZE];
    char custombuff[9]={1,2,3,4,5,6,7,8,9};
    char tbf[5]= {0x23,0x45,0x67,0x89,0x90};

    ethMsgObj ethrecvmsg;
    Event_Handle tEvt;
    Mailbox_Handle tMbx;

    server = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
    if (server == -1) {
    System_printf("Error: socket not created.\n");
    goto shutdown;
    }

    memset(&localAddr, 0, sizeof(localAddr));
    localAddr.sin_family = AF_INET;
    localAddr.sin_addr.s_addr = htonl(INADDR_ANY);
    localAddr.sin_port = htons(arg0);

    status = bind(server, (struct sockaddr *)&localAddr, sizeof(localAddr));
    if (status == -1) {
    System_printf("Error: bind failed.\n");
    goto shutdown;
    }
    else sockcreated=TRUE;
    System_printf("socket creation finished.\n");
    System_flush();
    do {
    /*
    * readSet and addrlen are value-result arguments, which must be reset
    * in between each select() and recvfrom() call
    */
    FD_ZERO(&readSet);
    FD_SET(server, &readSet);
    addrlen = sizeof(clientAddr);

    /* Wait forever for the reply */
    status = select(server + 1, &readSet, NULL, NULL, NULL);
    if (status > 0) {
    if (FD_ISSET(server, &readSet)) {
    bytesRcvd = recvfrom(server, buffer, UDPPACKETSIZE, 0,
    (struct sockaddr *)&clientAddr, &addrlen);

    if (bytesRcvd > 0) {
    bytesSent = sendto(server, buffer, bytesRcvd, 0,
    (struct sockaddr *)&clientAddr, addrlen);
    bytesSent1=sendto(server, custombuff, 9, 0,
    (struct sockaddr *)&clientAddr, addrlen);
    postCmdMBoxMsg(buffer,30 );
    if (bytesSent < 0 || bytesSent != bytesRcvd) {
    System_printf("Error: sendto failed.\n");
    goto shutdown;
    }
    }
    }
    }
    if(!isXmitQEmpty())
    {


    tbuff=retrieveXmitQ();
    // copyCharArry(tbuff, tbf,5 );
    bytesSent1=sendto(server, tbuff, 5, 0,
    (struct sockaddr *)&clientAddr, addrlen);
    }

    } while (status > 0);

    shutdown:
    if (server > 0) {
    close(server);
    }
    }
  • The problem is because I misunderstood 1 as high priority and greater than 1 as low priority. I fixed the same and is fine now.