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


lwip task start

Posted by Maurizio on May 21, 2008
Hi all,
I'm doing a demo on udp lwip working for Str91x with Rowley. My demo is not getting send packages udp, in my opinion there is a problem when the FreeRTOS launches task. Below is my code, to understand how to launch the task I have taken inspiration from demo WebServer included in the package FreeRTOS 5.
someone can help me? it's my code ok?

/* Create the lwIP task. This uses the lwIP RTOS abstraction layer.*/
sys_set_state(( signed portCHAR * ) "httpd", lwipBASIC_SERVER_STACK_SIZE );
sys_thread_new( vBasicWEBServer, ( void * ) NULL, ( tskIDLE_PRIORITY + 2 )basicwebWEBSERVER_PRIORITY );

#ifndef UDP_SENDER_H
#define UDP_SENDER_H

#include <91x_type.h>

/* MACROS */
#define basicudp_SENDER_PRIORITY ( tskIDLE_PRIORITY + 2 )

/* The port on which we listen. */
#define webUDP_PORT( 1234 )

/* Delay on close error. */
#define webSHORT_DELAY( 10 / portTICK_RATE_MS )

/* The IP address being used. */
#define emacIPADDR010
#define emacIPADDR1 200
#define emacIPADDR2 200
#define emacIPADDR3 2

/* The gateway address being used. */
#define emacGATEWAY_ADDR0 10
#define emacGATEWAY_ADDR1 200
#define emacGATEWAY_ADDR2 200
#define emacGATEWAY_ADDR3 1

/* The network mask being used. */
#define emacNET_MASK0 255
#define emacNET_MASK1 255
#define emacNET_MASK2 255
#define emacNET_MASK3 252

#define STATIC_IP 1
#define DHCP_IP 2


/* The function that implements the WEB server task. */
void vBasicUDPSender( void *pvParameters );

/* Initialisation required by lwIP. */
void vlwIPInit( void );



#define basicwebWEBSERVER_PRIORITY ( tskIDLE_PRIORITY + 2 )
#define lwipTCP_STACK_SIZE600

/* Standard includes. */
#include <stdio.h>
#include <string.h>
#include <91x_type.h>

/* Scheduler includes. */
#include "FreeRTOS.h"
#include "task.h"
#include "semphr.h"

/* Demo includes. */
#include "lwIPWebServer/BasicWEB.h"
#include "udpecho-sender.h"
/* lwIP includes. */
#include "lwip/api.h"
#include "lwip/tcpip.h"
#include "lwip/memp.h"
#include "lwip/stats.h"
#include "Dnetif/loopif.h"
//#include "lcd.h"
#include "httpd.h"

//#define lwipTCP_STACK_SIZE600
#include "lwip/udp.h"
#include "lwip/mem.h"
#include "lwip/debug.h"
static struct netif EMAC_if;

void vlwIPInit( void )
/* Initialize lwIP and its interface layer. */
sys_set_state(( signed portCHAR * ) "lwIP", lwipTCP_STACK_SIZE);

void udp_echo_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, struct ip_addr *addr, u16_t port)

if (p != NULL)
/* send received packet back to sender */

udp_sendto(pcb, p, addr, port);
/* free the pbuf */

void udp_echo_init(void)
struct udp_pcb * pcb;

/* get new pcb */
pcb = udp_new();
if (pcb == NULL) {
LWIP_DEBUGF(UDP_DEBUG, ("udp_new failed!\n"));

/* bind to any IP address on port 7 */
if (udp_bind(pcb, IP_ADDR_ANY, UDP_PORT) != ERR_OK) {
LWIP_DEBUGF(UDP_DEBUG, ("udp_bind failed!\n"));

/* set udp_echo_recv() as callback function
for received packets */
udp_recv(pcb, udp_echo_recv, NULL);

void vBasicWEBServer( void *pvParameters )
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 );
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 */

/* Initialize HTTP */

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


[ 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