[Top][All Lists]

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

[Savannah-users] LwIP - Receiving data via TCP connection

From: Niels Hendriks
Subject: [Savannah-users] LwIP - Receiving data via TCP connection
Date: Fri, 22 May 2009 14:23:11 -0700 (PDT)

Hello everyone,

I'm not sure if I have the right channel to ask my questions, so my appollogies if it's not.
For a research project I'm doing some benchmarks to see what the impact of the LwIP stack is on a ARM7 (LPC2388).

To test the receiving of data via TCP I've programmed the code at the end of this e-mail. For some reason, when I'm using a interrupt to call tcp_tmr() every 250 ms, the proc. stops at (what appears to be) a random time and reboots.
When I disable the interrupt/timer 1, and just put the tcp_tmr call in main everything just works fine.
Using the same method when sending data works fine though.... I think its memory releated.

Does anybody know what I'm doing wrong, and is it possible to use interrupts as described?

Many thanks in advance for the help, I really appreciate it! :-)


Code from Main.c:
<< all of the nessecary includes >>

static void tcpInit(){
    unsigned int start = 0;
    unsigned int stop = 0;

    lwip_init(); /* Functioncall to initialize the LwIP protocolstack */
    tcp_tmr();     /* Mandatory call to tcp_tmr, required by lwip_init(), has to be called every 250ms */

err_t data_recv_callback(void *arg, struct tcp_pcb *tpcb, struct pbuf *p, err_t err) {
    if(p != NULL){
        total_bytes_received += p->len;
        tcp_recved(tpcb, p->len);
        LCD_puts("CONN CLOSED");
        return ERR_OK;
    return ERR_OK;

err_t accept_callback(void *arg,  struct tcp_pcb *pcb, err_t err){
    tcp_arg(pcb, NULL);
    tcp_recv(pcb, data_recv_callback);
    return ERR_OK;

static int setup_passive_tcp_connection(){

    /* Protocol Control Block for the active tcp connection */
    struct tcp_pcb *pcb;
    struct tcp_pcb *tcpweb_listen;
    /* Fill the struct for the receivers ip address */
    //IP4_ADDR(&recvr_ipaddr_data,  192, 123, 0, 105);
    pcb = tcp_new();
    /* Bind to a portnr, doesn't matter what interface, perform availability check */
    if(tcp_bind(pcb, &my_ipaddr_data, 8282) != ERR_OK){
        return FALSE;
    /* Register callback function, that is to be called on succesfull connection */
    tcpweb_listen = tcp_listen(pcb);
    if (tcpweb_listen == NULL)
        pcb = NULL;
        return FALSE;

    pcb = tcpweb_listen;
    tcp_accept(pcb, accept_callback);
    return TRUE;

int main (void) 
    TICKER1_Start(); // start timer 1, interrupts every 250 ms to call tpc_tmr();
    LCD_init(); // init the lcd
    bmrk_init(); // init the own written benchmark module...
    TICKER0_Start(); // start timer0 later because it calls LWIP functions!
    LCD_gotoxy(1,2); // move LCD cursor to 2nd line (x,y)
    LCD_puts("Passive TCP ref");
    bmrk_fill_view(); // fill a array with things that has to be displayed on screen, using UART1
    if (setup_passive_tcp_connection()){
    return FALSE;   

reply via email to

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