lwip-users
[Top][All Lists]
Advanced

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

[lwip-users] dhcp stuff.. thanks leon


From: Eric Shufro
Subject: [lwip-users] dhcp stuff.. thanks leon
Date: Sun, 19 Sep 2004 12:11:53 -0400

Yeah, I was able to figure it out.

I wasn't paying close attention to my lwip options (which I have since
cleaned up). I simply increased the size of the heap from 500b to 1000b.

Prob solved there. DHCP does its thing fine now, with one exception:

I don't think im initializing timers correctly because they do not fire.

I have the dhcp option set to do an arp check after an offer is accepted.

Naturally, no timers, no arp expiration, and therefore no dhcp assigned
address set permanently. (works when I shut arp check off) - break points
don't fire on the timer expirations though.)

Tell me what you think of this, it's a copy of my main lwip task (snippits
to keep it short) with my timer init code. Below that are the timer
functions. I've traced through it and see that its semaphore based, other
than that, im not sure why it doesn't work unless something conceptually is
wrong. Thanks.

--eric

//---------------------------------------------------------------
static void  AppStartTask (void *p_arg)
{
  err_t err;
 
  struct netif netif;
  struct ip_addr ipaddr, netmask, gw;
  sys_sem_t sem;

  struct ip_addr dest_host;
  
  (void)p_arg; 
  
  OSTickISR_Init();  
  EnableInterrupts;
 
  sem = sys_sem_new(0);  
  tcpip_init(tcpip_init_done, &sem);
  sys_sem_wait(sem);
  sys_sem_free(sem);
  netif_init();

  IP4_ADDR(&gw, 0,0,0,0);
  IP4_ADDR(&ipaddr, 0,0,0,0);
  IP4_ADDR(&netmask, 0,0,0,0);
  
  sys_timeout(DHCP_FINE_TIMER_MSECS,
    (sys_timeout_handler)dhcp_fine_timer, NULL);
  sys_timeout((u32_t)DHCP_COARSE_TIMER_SECS * 1000,
    (sys_timeout_handler)dhcp_coarse_timer, NULL);

  netif_add(&netif, &ipaddr, &netmask, &gw, NULL, cs8900if_init, ip_input);
  netif_set_default(&netif);
  netif_set_up(&netif);

  sys_thread_new(ServiceCS8900, &netif, TASK_START_PRIO);

  err = dhcp_start(&netif);   
  if(err!=ERR_OK)
  {
    printf("DHCP start failed\n");              
  }  

  sys_timeout(OS_TICKS_PER_SEC * (ARP_TMR_INTERVAL / 1000),
    (sys_timeout_handler)Etharp_Timer, NULL);
  sys_timeout((u32_t)OS_TICKS_PER_SEC / 4,
    (sys_timeout_handler)TCP_Timer, NULL);
    
  printf("Timers initialized.\n\x0a");
          
  while (TRUE) 
  {
      LED_Toggle(4);
      OSTimeDly(OS_TICKS_PER_SEC);
  }  
}

//---------------------------------------------------------------

/*
*******************************************************
*                         TCPIP Init Call Back
*******************************************************
*/

static void tcpip_init_done(void *arg)
{
  sys_sem_t *sem;
  sem = arg;
  sys_sem_signal(*sem);
}

/*
**********************************************************
*                            LWIP Timers
**********************************************************
*/

void dhcp_fine_timer(void *arg)
{
        dhcp_fine_tmr();
        sys_timeout(DHCP_FINE_TIMER_MSECS, 
           (sys_timeout_handler)dhcp_fine_timer, NULL);
}

void dhcp_coarse_timer(void *arg)
{
        dhcp_coarse_tmr();
        sys_timeout((u32_t)DHCP_COARSE_TIMER_SECS * 1000, 
           (sys_timeout_handler)dhcp_coarse_timer, NULL);
}

void  Etharp_Timer(void *p_arg)
{
      etharp_tmr();                                      
          sys_timeout((u32_t)OS_TICKS_PER_SEC * (ARP_TMR_INTERVAL / 1000),
                (sys_timeout_handler)Etharp_Timer, NULL);
}

void  TCP_Timer(void *p_arg) //tcp_tmr() - called every 250ms
{
      tcp_tmr();                                      
      sys_timeout((u32_t)OS_TICKS_PER_SEC / 4,
                (sys_timeout_handler)TCP_Timer, NULL);
}





reply via email to

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