Quality RTOS & Embedded Software

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




Loading

Problems with uIP webclient

Posted by davebu on April 15, 2009
Can anyone point me to a reference or provide help to get the uIP webclient demo to work? I examined the documentation for the uIP stack and examples and did not find something to explain the usage. I did see where there are 4 callback functions to be implemented. The issue I am having is getting the client to successfully initiate a GET. (I wish to integrate the client with server so that ultimately I can use an external browser to initiate a GET from the embedded client via the embedded web server.)

I am using FreeRTOS V5.2.0 CORTEX M3 IAR (IAR Workbench 5.4), and am using the webserver example with uIP_Task.c and emac.c. The server runs fine. I integrated the webclient code by making an init function that calls both the webclient init and the webserver init, and an appcall function that calls both the webclient appcall and the webserver appcall.

I have not found in the code where I can initiate a GET other than to call webclient_get function with host, port, and file parameters. When do this, I get a hardware fault at runtime. I isolated the fault to be a result of uip_buf being uninitialized (i.e. null).

I see that uip_appdata is filed in by senddata() in the web client, however there is no code that I could find that sets up uip_buf to point to it.

In addition to resolving the fault, at some point I imagine I will have to discriminate between received packets on port 80 for the server and another port (e.g. 84?) for the client, and call the appropriate processing.

I'm new to http clients and servers and uIP and FreeRTOS, so I feel I am missing something in the big picture.

Thank you :-)

RE: Problems with uIP webclient

Posted by Richard on April 16, 2009
I would try getting onto the uIP mail list. Somebody there should be able to give you some example code for what you want.

Regards.

RE: Problems with uIP webclient

Posted by Tonau on April 16, 2009
Maybe it is not exactly what you want, but mayby it can help you.
You can send HTML forms with the method get to the webserver and then you can readout all form parameters in the httpd.c @
...
if(uip_appdata[4] == ISO_slash &&
uip_appdata[5] == ISO_c &&
uip_appdata[6] == ISO_g &&
uip_appdata[7] == ISO_i &&
uip_appdata[8] == ISO_slash) {
//______________________________________________________________________________
/* If the request is for a file that starts with "/cgi/", we
check for ? and save all paramters appended */
if (uip_appdata[26] == 0x3F)
//______________________________________________________________________________
/* If the request is for a file that starts with "/cgi/", we
prepare for invoking a script. */
hs->script = fsfile.data;
next_scriptstate();

}
...
Your html form should look like this:
<form name="Formular" action="\cgi\test" method="get" target="_self" accept-charset="UTF-8">
You have to addapt the index of uip_appdata[] to point to the start of your form parameter.

This code comes from the SAM7X uip Demo and uses an old version of uIP. Maybe in newer version everything has changed.
Good Luck

RE: Problems with uIP webclient

Posted by davebu on April 16, 2009
Thanks Richard -
I followed the suggestion for the uip mail list.

Thanks Tonau -
I'm not sure I understand, but it might be useful if the idea is to focus on making the embedded server do the download (and omit the client code). Is the suggestion to use an external web browser (e.g. on a PC) to send the html form you specified ("Formular") to the embedded web server? Secondly, how would that make the embedded server download a file from the PC (say, "foo.x")?


P.S. I also tried disabling running the server code, and just use the client code with the uIP_Task and uIP/EMAC. Same basic issue - I think there is code missing (that I would have to write) to properly glue the client code to the uIP stack and EMAC. The specific problem remains that uip_buf is null and does not point to the appdata.

RE: Problems with uIP webclient

Posted by Tonau on April 23, 2009
Yes the suggestion was to send configuration data to the embedded device via a formular hostet on the embedded webserver.
If you want to use this mechanism you have to add your file to the addressline of your browser.
For example: http://192.168.0.12/cgi/config?data_from_your_textfile_foo.x
Of course this is not the nicest way to do a data transmission to your embedded device, but it should work.

If you use the webserver task, all received and transmitted data is temporary stored in uip_buf. Also all protocoll header information are stored in uip_buf. You can then use the uip_appdata pointer, which points to the beginning of the data. The task should be waked by an semaphore from the emac isr. I hope this works at your programm. Normaly one functions is called after new data has arrived.
uipopt.h:
#ifndef UIP_APPCALL
#define UIP_APPCALL httpd_appcall
#endif
If you change httpd_appcall to the name of your own function, you should be able to receive every tcp ip packet.

Good luck!


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




Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

FreeRTOS kernel V10 is available for immediate download. Now MIT licensed.


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

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

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

OpenRTOS and SafeRTOS