Hi,

I am now testing lwip-socket by modifying safertos_demo example. My
development environments are LM3S9B96, StellarisWare 10636, ccs 5.4.x,
lwip-1.3.2, f=80Mhz

TCP Listener task is implemented to communicate with Unix server(using
lwip-socket) and this listener task runs concurrently with other tasks used
in safertos_demo example : led_task, idle_task, lwip_task, and
display_task(spider and web server modules are not used).

*1. setup tcp ip socket service.*

   //
    // Setup the remaining services inside the TCP/IP thread's context.
    //
    tcpip_callback(SetupServices, 0);

*2. Initialize lwip-socket in SetupServices()*

   lwip_socket_init();

*3. Make cmdListnerTaskInit() in cmdListener_task*

   if(xTaskCreate(cmdListenerTask, (signed portCHAR *)"TCP_LISTENER",
                   (signed portCHAR *)g_pulcmdListenerTaskStack,
                   sizeof(g_pulcmdListenerTaskStack), NULL,
PRIORITY_CMDLISTENER_TASK,
                   NULL) != pdPASS)
    {
        return(1);
    }

    TaskCreated();

*4. Make main task function, cmdListenerTask(void *pvParameters)*

    // Setup the local address.
    memset((char *) &sClient, 0, sizeof(sClient));
    sClient.sin_family = AF_INET;
    sClient.sin_len = sizeof(sClient);
    sClient.sin_addr.s_addr = lwIPLocalIPAddrGet();
    sClient.sin_port = htons(sPort);

    //setup the destination address
    memset((char *) &sDestAddr, 0, sizeof(sDestAddr));
    sDestAddr.sin_family = AF_INET;
    sDestAddr.sin_len = sizeof(sDestAddr);
    sDestAddr.sin_addr.s_addr = inet_addr("192.2.0.3");// for test,
hard-corded
    sDestAddr.sin_port = htons(sPort);


    while(1)
    {
        while((socket_fd = lwip_socket(AF_INET, SOCK_DGRAM, 0)) == 0)
        {
            xTaskDelay(CHGD_OPEN_TIME);
        }

        //bind socket to the local address and port
        lwip_bind(socket_fd, (struct sockaddr *) &sClient, sizeof(sClient));

        //receive from server
        length = lwip_recvfrom(socket_fd, (char *) msg_buf, sizeof(msg_buf),
                MSG_DONTWAIT, (struct sockaddr *)&sDestAddr, &size);

        if(length > 0)
        {
            sMsg = (NET_MSG *) (msg_buf);
            mon_cmd_do(socket_fd, &sDestAddr, sMsg, length);
        }
        lwip_close(socket_fd);

    }

*5. call cmdListnerTaskInit() in main()*

The scenario is as lwip_task is running, the client IP is assigned from
server(DHCP) and bind lwip-socket with the given IP, so I LWIP_DHCP and
LWIP_SOCKET are defined in lwipopts.h.

Ths priority of each task is led_task= 3, cmd Listener_task =1,
display_task=2

As I test this:

*1. led_task keeps flashing*

*2. IP is sent to the client but it doesn't display(Wireshark tells IP was
sent to client from server)*

*3. Idle_task seems like not working. That's why running time and RX packet
don't show up on LED.*

*4. If cmd Listener task is suspended, other tasks work fine.(using
xTaskSuspend()).*

So far I don't see any clues to figure this out. Whenever I try to debug,
the safeRTOS scheduler shows me "Failed to start scheduler", so I don't
know how possibly to look inside.

What do I make a mistake?

Regards,

Jin
_______________________________________________
lwip-users mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/lwip-users

Reply via email to