lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] Problem with do_writemore() + LWIP for AVR32


From: patelbaroda
Subject: Re: [lwip-users] Problem with do_writemore() + LWIP for AVR32
Date: Wed, 9 Dec 2009 18:17:38 -0800 (PST)

>From this lwIP init,
 /*!
 *  \brief start lwIP layer.
 */
static void prvlwIPInit( void )
{
  sys_sem_t sem;


  sem = sys_sem_new(0); // Create a new semaphore.
  tcpip_init(tcpip_init_done, &sem);
  sys_sem_wait(sem);    // Block until the lwIP stack is initialized.
  sys_sem_free(sem);    // Free the semaphore.

  /* Set hw and IP parameters, initialize MACB too */
  prvEthernetConfigureInterface(NULL);
}

to prvEthernetConfigureInterface...........

/*!
 *  \brief set ethernet config
 */
static void prvEthernetConfigureInterface(void * param)
{
        struct ip_addr xIpAddr, xNetMask, xGateway;
        extern err_t ethernetif_init( struct netif *netif );
        unsigned portCHAR MacAddress[6];
        portSHORT NbDigits = 0;
        unsigned int AddrByte;
        portCHAR token[18];
        portCHAR * current;
        //unsigned char IPAddr[4] = {10, 0, 0, 147};
        //unsigned char Gateway[4] = {10,0,0,1};
        unsigned char IPAddr[4] = {192, 168, 1, 199};
        unsigned char Subnet[4] = {255, 255, 255, 0};
        unsigned char Gateway[4] = {192,168,1,1};
        GetIPAddress(IPAddr, 0);
        GetIPAddress(Subnet, 1);
        GetIPAddress(Gateway, 2);

    int i = 0;
        if (config_file_get_value(ETHERNET_CONFIG_FILE, "macaddr" , token)
>= 0)
        {
          current = token;
          while (NbDigits < 6)
          {
                // get two next bytes and convert as integer
                sscanf(current, "%02x", &AddrByte);
                MacAddress[NbDigits++] = (portCHAR)AddrByte;
                current = strpbrk(current, ":");

                if ((current == NULL) && (NbDigits != 6))
                {
                        prv_v_set_default_macaddr( MacAddress );
                        break;
                }
                current++;

          }
        }
        else
        {
          /* can't find field in config file, use default parameters */
          prv_v_set_default_macaddr( MacAddress );
        }
#if 0
        IPAddr[0] = 10;
                IPAddr[1] = 0;
                IPAddr[2] = 0;
                IPAddr[3] = 147;
                Gateway[0] = 10;
                Gateway[1] = 0;
                Gateway[2] = 0;
                Gateway[3] = 1;
#endif
        //prv_v_set_default_macaddr( MacAddress );
        vMACBSetMACAddress( MacAddress );
        for (i = 0; i < 6; i++)
                MACB_if.hwaddr[i] = MacAddress[i];
        if (IsDHCPEnabled())
    {
    IP4_ADDR( &xIpAddr,0,0,0,0 );
    IP4_ADDR( &xNetMask,0,0,0,0 );
    IP4_ADDR( &xGateway,0,0,0,0 );
    netif_add( &MACB_if, &xIpAddr, &xNetMask, &xGateway, NULL,
ethernetif_init, tcpip_input );
    netif_set_default( &MACB_if );
    dhcp_start(&MACB_if);
    usart_write_line(SHL_USART, "DHCP On\r\n");
    }
    else
    {
    IP4_ADDR( &xIpAddr,IPAddr[0],IPAddr[1],IPAddr[2],IPAddr[3] );
                IP4_ADDR( &xNetMask,Subnet[0],Subnet[1],Subnet[2],Subnet[3]
);
                IP4_ADDR( &xGateway,Gateway[0],Gateway[1],Gateway[2],
Gateway[3] );
                netif_add( &MACB_if, &xIpAddr, &xNetMask, &xGateway, NULL,
ethernetif_init, tcpip_input );
                netif_set_default( &MACB_if );
                netif_set_up( &MACB_if );
                usart_write_line(SHL_USART, "DHCP Off\r\n");
        }
}


DHCP is not enabled and system work with fix IP at present. So netif_add is
called with
ethernetif_init, tcpip_input. 

Simon Goldschmidt wrote:
> 
> patelbaroda wrote:
>> I have one thread for web server, that call "netconn_write" function. The
>> other thread is from ethernetif.c that handles the MACB input packets.
>> The
>> TCPIP thread is handling TCPIP process as defined 
>>
>> sys_thread_new(TCPIP_THREAD_NAME, tcpip_thread, NULL,
>> TCPIP_THREAD_STACKSIZE, TCPIP_THREAD_PRIO); (FreeRTOS)
>>
>> Those lwip core functions are called from these two threads. Now I don't
>> understand, how I can combine these threads and make one.  
> Could you tell us the code line where you call 'netif_add()'? Then I 
> might tell you what to do.
> 
> Simon
> 
> 
> _______________________________________________
> lwip-users mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/lwip-users
> 
> 

-- 
View this message in context: 
http://old.nabble.com/Problem-with-do_writemore%28%29-%2B-LWIP-for-AVR32-tp26681732p26721146.html
Sent from the lwip-users mailing list archive at Nabble.com.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]