Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training




Loading

str912 + lwip + freertos5.0.2

Posted by telkim on April 1, 2010
I use freertos version 5.0.2 and lwip.

target board program following code for server

1. calling founction

void vBasicWEBServer( void *pvParameters ) // basicweb.c
{
unsigned char pcMessageToExchange[] = "\n init socket\r\n";

struct ip_addr xIpAddr, xNetMast, xGateway;
extern err_t ethernetif_init( struct netif *netif );

/* Parameters are not used - suppress compiler error. */
( void ) pvParameters;

/* Create and configure the EMAC interface. */
IP4_ADDR( &xIpAddr, emacIPADDR0, emacIPADDR1, emacIPADDR2, emacIPADDR3 );
IP4_ADDR( &xNetMast, emacNET_MASK0, emacNET_MASK1, emacNET_MASK2, emacNET_MASK3 );
IP4_ADDR( &xGateway, emacGATEWAY_ADDR0, emacGATEWAY_ADDR1, emacGATEWAY_ADDR2, emacGATEWAY_ADDR3 );
netif_add( &EMAC_if, &xIpAddr, &xNetMast, &xGateway, NULL, ethernetif_init, tcpip_input );

/* make it the default interface */
netif_set_default( &EMAC_if );

/* bring it up */
netif_set_up(&EMAC_if);


vSerialPutString( 0, pcMessageToExchange, strlen( pcMessageToExchange ) );
/* Initialize HTTP */
// httpd_init(); //kcs

kcs_server(); // kcs


/* Nothing else to do. No point hanging around. */
vTaskDelete( NULL );
}


void kcs_server() // httpd.c
{

struct tcp_pcb *pcb;

pcb = tcp_new();

tcp_bind(pcb, IP_ADDR_ANY,2000);

tcp_arg(pcb,NULL);

pcb = tcp_listen(pcb);

tcp_accept( pcb, helloworld_accept);
}

void helloworld_accept( void *arg, struct tcp_pcb *pcb, err_t err) // kcs
{

int i,j;

vSerialPutString( 0, "accept\r\n", 10 );


vSerialPutString( 0, "read\r\n", 8 );
tcp_err(pcb,conn_err); // 2010.3.4 kim
tcp_recv(pcb, kcs_receive);


for(j = 0; j < 1; j++)
{
vSerialPutString( 0, "write\r\n", 9 );
tcp_write(pcb, GREETING, strlen(GREETING),1);
for( i = 0; i < 100;i++) ;
}



}

err_t kcs_receive(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err) // kcs
{
int i;

vSerialPutString( 0, "receive\r\n", 11);

if( p != NULL)
{

tcp_recved(pcb,p->tot_len); // add kcs 2010.3.4



vSerialPutString( 0, p->payload, p->tot_len );
err = tcp_write(pcb,p->payload,p->tot_len ,1);
}
else if( err == ERR_OK)
{
vSerialPutString( 0, "socket close\r\n", 16 );
tcp_close(pcb);
}

err = tcp_write(pcb,p->payload,p->len,1);

}


Above code run 8 times packet and ping reply, but don't run 9 times. and ping don't reply
why did it run?

RE: str912 + lwip + freertos5.0.2

Posted by Richard on April 1, 2010
Sorry, but I have no idea and cannot read the code very easily. I would guess either a problem in your Ethernet driver, or you are not freeing memory buffers and so are simply running out of buffers. I think you would have to switch on some of the debugging/logging in lwIP to see why it stops running.

Also, the lwIP mailing list is a very active place to get lwIP specific support.

Regards.


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists