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

setting up a UDP "connection" in the DEMO

Posted by biker126 on September 27, 2007
hello everyone!

now that I finally managed to adjust the freeRTOS/uIP demo (for LPC2368 under eclipse with GCC) I tried to make a "UDP task" but got some problems.

here's what I did so far:

1. adjusted folder structure of the project (every source is in the project folder now) --> webserver still works
2. switched from thumb to arm compiling mode --> webserver still works when I disable MAM (MAM is bugged for initial revision and revision A)
3. added my own task, a "dummytask" that only counts up a variable every 10 ticks (with "taskdelayuntil()") --> webserver still works

so far, so good :-)

now I replaced that basic dummy task with something more advanced. I set the UIP_CONF_UDP in uip_conf.h and include the "myTask.h" file. The Header files look as follows (just to give you a small overview of what I did).

######################## myTask.h: #######################

#ifndef MYTASK_H_
#define MYTASK_H_

#include "myApp.h"

void mytask( void* pvParameters);
void myapp_call(void);
void udp_config(void);

typedef struct udp_state uip_udp_appstate_t;

#ifndef UIP_UDP_APPCALL
#define UIP_UDP_APPCALL myapp_call
#endif

extern packet p;
extern packet* packet_ptr;

#endif /*MYTASK_H_*/

###################### myApp.h: ######################

#ifndef MYAPP_H_
#define MYAPP_H_

struct udp_state {
int emptyvar;
int nothing;
};
typedef struct my_packet {
unsigned long ticks;
unsigned long number;
} packet;
#endif /*MYAPP_H_*/

######################## myTask.c ######################

#include <math.h>
#include <string.h>

#include "FreeRTOS.h"
#include "Task.h"
#include "myTask.h"
#include "uip.h"

packet p;
int valid_data = 0;
packet *packet_ptr;

struct uip_udp_conn *udp_conn;


void mytask( void* pvParameters)
{
portTickType xLastWakeTime;
const portTickType xFrequency = 10;
portCHAR buf[20];
portLONG i = 0;
p.ticks = 0;
p.number = 0;


xLastWakeTime = xTaskGetTickCount();


for (;;)
{
vTaskDelayUntil( &xLastWakeTime, xFrequency );
i += 2;
if (i%10 == 0)
{
i = 0;
}
if (valid_data == 0)
{
// get ticks
p.ticks = xTaskGetTickCount();
// increase packt number
p.number++;
// indicate that p contains valid (= new) data now
valid_data = 1;
}
}
}

void myapp_call(void)
{
int lala = 5;
if ( uip_udp_conn->rport == HTONS(53) )
{
if ( uip_poll() )
{
if (valid_data == 1)
{
// set packet_ptr to address of uip_appdata (= the uip_buf[])
packet_ptr = (packet*) uip_appdata;
// clear the required memory
memset(packet_ptr, 0, sizeof(packet));
// write the data into the buffer
packet_ptr->ticks = p.ticks;
packet_ptr->number = p.number;
// send out the data
uip_udp_send(sizeof(packet));
// indicate that the data has been send
valid_data == 0;
}
}
if ( uip_newdata() )
{

}
}
}

void udp_config(void)
{
uip_ipaddr_t addr;
uip_ipaddr(&addr, 192,168,2,20);
udp_conn = uip_udp_new(&addr, HTONS(53));
}



the udp_config i call inside the uIP_Task (as the demo calls httpd() in there too) just befor the endless loop. I also adjusted the uIP_Task loop and added the sequence to call uip_udp_periodic() (an example for thats is provided with the uIP stack code/doc).

now my big problem is:
after these changes the uIP_Task gets STUCK when initialising the EMAC controller!!

the following while loop never gets "false" and thus the uIP_Task just sleeps endless (at least thats how it behaves. the other tasks, like LED and LCD still work and when i want to step _over_ that loop GDB stays on "running" mode)

while( Init_EMAC() != pdPASS )
{
vTaskDelay( uipINIT_WAIT );
}


sorry for the long post but maybe anyone got an idea what I'm doing wrong? maybe I missed to change a config-settings?

thanks in advance
D. Holzwarth

RE: setting up a UDP "connection" in the DEMO

Posted by Richard on September 28, 2007
There were some posts on this in the uIP mailing this this week - this might provide some useful examples.

Regards.

RE: setting up a UDP "connection" in the DEMO

Posted by biker126 on September 30, 2007
it seems to work now :-)

even tho I dont really know why it's working now and didn't work before ^^
maybe it got something to do with the unstable MAM of the LPC2368/78 ...


[ 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