cancel
Showing results for 
Search instead for 
Did you mean: 

uIP question

mehmet.karakaya
Associate III
Posted on December 24, 2012 at 17:41

uint32_t uIPMain(
void
) 
{ 
uint32_t i; 
uip_ipaddr_t ipaddr; 
struct
timer periodic_timer, arp_timer; 
// Sys timer init 1/100 sec tick 
clock_init(2); 
timer_set(&periodic_timer, CLOCK_SECOND / 2); 
timer_set(&arp_timer, CLOCK_SECOND * 10); 
// Initialize the ethernet device driver 
// Init MAC 
// Phy network negotiation 
tapdev_init(); 
// uIP web server 
// Initialize the uIP TCP/IP stack. 
uip_init(); 
// Init WEB server 
uip_ipaddr(ipaddr, 192,168,1,100); 
//printf(''IP Address: 0.100\n\r''); 
uip_sethostaddr(ipaddr); 
uip_ipaddr(ipaddr, 192,168,1,3); 
uip_setdraddr(ipaddr); 
uip_ipaddr(ipaddr, 255,255,255,0); 
uip_setnetmask(ipaddr); 
// Initialize the HTTP server. 
httpd_init(); 
// Run WEB server and wait any key for exit 
while
(1) 
{ 
uip_len = tapdev_read(uip_buf); 
if
(uip_len > 0) 
{ 
if
(BUF->type == htons(UIP_ETHTYPE_IP)) 
{ 
uip_process(1); 
/* If the above function invocation resulted in data that 
should be sent out on the network, the global variable 
uip_len is set to a value > 0. */
if
(uip_len > 0) 
{ 
uip_arp_out(); 
tapdev_send(uip_buf,uip_len); 
} 
} 
else
if
(BUF->type == htons(UIP_ETHTYPE_ARP)) 
{ 
uip_arp_arpin(); 
/* If the above function invocation resulted in data that 
should be sent out on the network, the global variable 
uip_len is set to a value > 0. */
if
(uip_len > 0) 
{ 
tapdev_send(uip_buf,uip_len); 
} 
} 
} 
else
if
(timer_expired(&periodic_timer)) 
{ 
timer_reset(&periodic_timer); 
for
(i = 0; i < UIP_CONNS; i++) 
{ 
uip_periodic(i); 
/* If the above function invocation resulted in data that 
should be sent out on the network, the global variable 
uip_len is set to a value > 0. */
if
(uip_len > 0) 
{ 
uip_arp_out(); 
tapdev_send(uip_buf,uip_len); 
} 
} 
/* Call the ARP timer function every 10 seconds. */
if
(timer_expired(&arp_timer)) 
{ 
timer_reset(&arp_timer); 
uip_arp_timer(); 
} 
} 
} 
return
(1); 
} 

hello forum I am new to TCP/IP anybody who used uIP before can answer my question ? this above is main body if uIP how must I modify this code so that it doesnot act as a webserver but receives and sends back 200 or 300 bytes of data ? thank you #3rd-party #uip #uip #lwip
2 REPLIES 2
elazhar
Associate II
Posted on April 09, 2013 at 17:59

Hi ,

I want to know if you've found a solution for your probleme cuz i have the same problem.

I want to ask u also about smthing, i've download Adam dunkel stack uIP and i have a serious problem, i used the simple application named '' hello world'' in apps directory and the uip_len always return 0

int main(void) {

    int i;

    uip_ipaddr_t ipaddr;

    struct timer periodic_timer;

    //struct uip_conn* conn;

    clock_init();

    // Clock second =1000

    timer_set(&periodic_timer, CLOCK_SECOND / 2);

    // Initialize the ethernet device driver

    network_init();

    //Initialize the uIP TCP/IP stack

    uip_init();

    //Init WEB server

    uip_ipaddr(ipaddr, 192,168,1,1);

    uip_sethostaddr(ipaddr);

    //

    //    uip_ipaddr(ipaddr, 192,168,1,2);

    //    uip_setdraddr(ipaddr);

    //

    //    uip_ipaddr(ipaddr, 255,255,255,0);

    //    uip_setnetmask(ipaddr);

    hello_world_init();

    /* 4 test purpose

    conn=uip_connect((192,168,2,1), 1000);

    if(conn==0){

        uip_abort();

        return;

    }*/

    while(1) {

        uip_len = network_read();

        if(uip_len > 0) {

            uip_input();

            /* If the above function invocation resulted in data that

         should be sent out on the network, the global variable

         uip_len is set to a value > 0. */

            if(uip_len > 0) {

                network_send();

            }

        } else if(timer_expired(&periodic_timer)) {

            timer_reset(&periodic_timer);

            for(i = 0; i < UIP_CONNS; i++) {

                uip_periodic(i);

                /* If the above function invocation resulted in data that

           should be sent out on the network, the global variable

           uip_len is set to a value > 0. */

                if(uip_len > 0) {

   /* problem here */

                    network_send();

                }

            }

#if UIP_UDP

            for(i = 0; i < UIP_UDP_CONNS; i++) {

                uip_udp_periodic(i);

                /* If the above function invocation resulted in data that

           should be sent out on the network, the global variable

           uip_len is set to a value > 0. */

                if(uip_len > 0) {

                    network_send();

                }

            }

#endif /* UIP_UDP */

        }

    }

    return 0;

Andrew Neil
Evangelist III
Posted on April 10, 2013 at 08:30

See:

http://e2e.ti.com/support/microcontrollers/stellaris_arm/f/471/p/155813/861350.aspx#861350

  - and replace ''TI'' with ''ST''.

The same applies to uIP.