Announcements

Help us improve the Power & Sensing Selection Guide. Share feedback

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Not applicable
Hello,

I'm designing a web server with the Hexagon Application Kit and DHCP protocol. In the second example of Infineon web server is possible switch a LED from the internet page, and I would like know how I can write a string from the microcontroller on the index.html to visualize this on the internet page. I know that is possible do this with cgi handlers but I don't know exactly how to do it.

Could anyone show me please how to do it or let me an example?

Thanks in advance.
0 Likes
26 Replies
oreste
Employee
Employee
Welcome! 50 replies posted 25 replies posted
Hi Photon,
CGI handlers are used to trigger function execution on the server.
What you need it is SSI Server Side Includes.

To activate this, you just need to activate the appropriate defines. in http.c.
Until now I never tried this but the http.c and http.h are quite well commented so you can start from here.
I would like to prepare a demo like this:
e.g. show the micro-controller temperature in the index.htm.
Unfortunately I am out of office but I should be able to prepare it before Christmas vacation.
I will post it in this thread as soon as it will be available.
Best Regards
Oreste Bernardi



MagicPhoton wrote:
Hello,

I'm designing a web server with the Hexagon Application Kit and DHCP protocol. In the second example of Infineon web server is possible switch a LED from the internet page, and I would like know how I can write a string from the microcontroller on the index.html to visualize this on the internet page. I know that is possible do this with cgi handlers but I don't know exactly how to do it.

Could anyone show me please how to do it or let me an example?

Thanks in advance.
0 Likes
Not applicable
Dear Oreste,

I'm so gratefull for your help and for your intention of prepare a demo, but I’m working in a research project and would be great make it works before Christmas.

I have been reading the comments of http.c and http.h and examples about SSI but I still need a little help.

I have built the next code but I'm not able to delete all compiler errors.

tSSIHandler SSIHandler;

#define NUM_CONFIG_SSI_TAGS (sizeof{g_pcConfigSSITags} / sizeof{char *});

const char *g_ppcTags[]=
{
"Hello World",
};

http_set_ssi_handler(SSIHandler, g_ppcTags, NUM_CONFIG_SSI_TAGS);


I don’t know how to use the typedef defined for the handler and in what way build a function for the SSI handler.

typedef u16_t (*tSSIHandler)(int iIndex, char *pcInsert, int iInsertLen


If anyone has made SSI code works would be very nice any advice or example to continue working on it.

Thanks for you time.
0 Likes
oreste
Employee
Employee
Welcome! 50 replies posted 25 replies posted
Hi Photon,
during the weekend I succeed to use SSI in web server. Unfortunately this project is in my home PC and it is done for relax kit.
I will send you my code code this evening when I am at home.
Best Regards
Oreste
0 Likes
Not applicable
Hi Oreste,

Thank you for try to build an example. Is not a problem that you have done the project for relax kit it will be helpful.

Best regards,
MagicPhoton
0 Likes
oreste
Employee
Employee
Welcome! 50 replies posted 25 replies posted
Hi MagicPhoton,
in this forum I can't attach a large file so I can't add my project. (If you send me a direct email I can forward it to you).
However I don't think that there is need.

I guess you already defined enabled the SSI and read the instructions written in the the webserver source code.
#define LWIP_HTTPD_SSI 1
I have put this in the httpd.h

This is my simple handler:



u16_t SSIHandler (int iIndex, char *pcInsert, int iInsertLen) {
memcpy(pcInsert,"Hello",5);
return 5;

}


(In this case I don't use the iIndex becasue I have only one tag and in real application I shall use IInsertLen to avoid buffer overflow. (see documentation in source code))

in the main you have to register the handler, for example with this code


static const char * tags[] ={"showtemp"};
http_set_ssi_handler(SSIHandler, tags, 1);


the html file shall have extension .ssi (other extension described in the source code are not working because the FATFS is configured only to support filenames with format 8.3 .... only three characters for the extension)

Inside the file you shall use the tag

.

This is all
Let me know if you have any problem.

Best Regards
Oreste Bernardi
0 Likes
Not applicable
Hi Oreste,

I have working a web server with SSI tags. Thank you very much for your help. 🙂

Best regards,
MagicPhoton
0 Likes
oreste
Employee
Employee
Welcome! 50 replies posted 25 replies posted
Hi MagicPhoton,
I answer here to you post in the microcontroller forum so this will help also other users:

You wrote:

Hello,

I have programmed the example of WEBSERVER001_Example2 in XMC5400 Hexagon Application Kit but when you switch very fast the LED from the web page, the server stops working and you need to press reset button to restart it.

Could anyone give me any advice to manage the requests and not saturate the server?

Best regards,
MagicPhoton




I have already see this behavior by click repeatedly and very quickly multiple times on refresh button.
It seems that this happens much more easily with IE while whith Firefox it is much more rare this problem.
I also found that it is not required to reset the board, but just wait a long time (1-2 mins but I don't remember exactly) and the if the user send another refresh is working fine.
I performed a very fast analysis using Wireshark and I see that IE is sending the a http request then it sending another one without closing the previous opened TCP connection. (http request are sent using TCP protocol), and so the uC is not responding.
I didn't have the time to investigate further but I have a strong feeling that this is related to some timeout or the handling of a double request on the same port.
For example:

  • lwip is waiting for close TCP connection packet and if not received it waiting for a long time and then aborting the connection (I have to look for this timeout inside the lwip code)
  • lwip should abort a previous connection on the port if it is received a second request on the same port. (I have to check what it is written in TCP spec about this situation)

Unfortunately I am on holiday I can't investigate further.
Best Regards
Oreste Bernardi
0 Likes
Not applicable
Hi Oreste,

Thank you for try to help me with the behavior of switching so fast the LED, I will continue researching on it.

But now I have found another problem more critical in this moment that maybe you or anyone could try to give me an advice.

I have tried to add a graph chart to my web page and everything is working all right when I run it from the local host. However, when I upload the files on the micro SD card of the hexagon board I get an error at the moment that index.htm file calls the javascript. When I look on the source code of the web page I get a red line at that moment (I have attached a screen shot showing it), and the code of the .js file looks different.

I have tried with different Javascript files, I have tried to modify the extensions and the name of those files and always I have a similar error.

Best regards and happy Christmas,
MagicPhoton
0 Likes
oreste
Employee
Employee
Welcome! 50 replies posted 25 replies posted
Hi MagicPhoton,
could you attach the file that put in the sd card and the one that you get from web browser. I would like to compare it to understand exactly the differences. In fact we used this web browser to transfer also pictures and sounds and we didn't find any issues.
0 Likes
lock attach
Attachments are accessible only for community members.
Not applicable
Hi Oreste,

This are the files that I have put in the sd card.


And these others are the files that I have got from the server.


Regards,
MagicPhoton
0 Likes
Not applicable
Hi Oreste,

Did you find why is happening this issue when you try to load JavaScript files from the server?

I'm doing something wrong or is that the compiler doesn't support this kind of files?

Regards,
MagicPhoton
0 Likes
oreste
Employee
Employee
Welcome! 50 replies posted 25 replies posted
Hi Magicphoton,
I have performed a deeper analysis of multiple led switching.
I have answered in the Dave Forum.
See http://www.infineonforums.com/threads/325-XMC4500-Webserver-slow-response.?p=895#post895

Best Regards
Oreste
0 Likes
oreste
Employee
Employee
Welcome! 50 replies posted 25 replies posted
Sorry for the delayed answer but I spend one day on not responsive webserver issue:
http://www.infineonforums.com/threads/325-XMC4500-Webserver-slow-response.?p=895#post895

It should be supported.
I have to prepare an example that involves javascript as well.
Monday I will inform you.
Best Regards
Oreste
0 Likes
lock attach
Attachments are accessible only for community members.
oreste
Employee
Employee
Welcome! 50 replies posted 25 replies posted
MagicPhoton wrote:
Hi Oreste,

Did you find why is happening this issue when you try to load JavaScript files from the server?

I'm doing something wrong or is that the compiler doesn't support this kind of files?

Regards,
MagicPhoton


Hi MagicPhoton,
The example that you sent me use long file names you shall use the format 8.3 see readme of webserver example.
Long filenames option is intentionally not provide to the user because there could be some patent issues. However it is possible to enable it manually at the user responsibility.

I have renamed the files with shorter filenames and I have tried on my relax kit here at home and it is working with Firefox.
In this attachement you can see the modified files
Note: with IE9 the javascript module is not working neither from local pc.

Please let me know if it is working.
Best Regards
Oreste
0 Likes
Not applicable
Hi Oreste,

You are right, the example doesn't support long file names. 😮

The readme.txt file of the example says:
Filesystem supports FAT32 but with filenames should be in the format 8.3.
Filename not longer than 8 characters and extension not longer than 3 characters.

Now is working on Chrome and Safary and is not working on IE9 but is neither working from local PC.

Thank you Oreste,

Best regards,
MagicPhoton
0 Likes
lock attach
Attachments are accessible only for community members.
Not applicable
Dear Oreste,

I'm having again problems to make working files on the server, but in this time filenames are not longer than 8 characters.

I have tried to upload this files from local PC and the web page is running properly. The issue is when you load this files from the server, I have tried to call this files one by one from the browser and they have uploaded fine.

Could you try the next files if they run in your server? Do you have any idea of why is this happening?

1141.attach

Best regards,
MagicPhoton
0 Likes
oreste
Employee
Employee
Welcome! 50 replies posted 25 replies posted
I tried your files and I had the same problem + the system is stalling in loop.
We have just discovered that the ETH004 porting was not done accordingly with lwip wiki guideline.
I don't know if that is the reason. I am investigating this.
Regards
Oreste
0 Likes
Not applicable
When I tried the files the server went down too. 😞

Tell me something if you solve the lwip issue.
0 Likes
oreste
Employee
Employee
Welcome! 50 replies posted 25 replies posted
Hi MagicPhoton,
I have reproduced your issue.
I have done some modification and improvements.
Now the situation is better. I am able to see your graphs.
I will update you today when I clean up the code and make some more experiment.

Regards
Oreste
0 Likes
Not applicable
Hi Oreste,

That is good news :). I hope you achieve performance improvement with yours experiments.

Best Regards,
MagicPhoton
0 Likes
oreste
Employee
Employee
Welcome! 50 replies posted 25 replies posted
MagicPhoton wrote:
Dear Oreste,

I'm having again problems to make working files on the server, but in this time filenames are not longer than 8 characters.

I have tried to upload this files from local PC and the web page is running properly. The issue is when you load this files from the server, I have tried to call this files one by one from the browser and they have uploaded fine.

Could you try the next files if they run in your server? Do you have any idea of why is this happening?



Best regards,
MagicPhoton


Just a test my posting are not added.
0 Likes
Not applicable
MagicPhoton wrote:
Hi Oreste,

I have working a web server with SSI tags. Thank you very much for your help. 🙂

Best regards,
MagicPhoton


Hello SSI-Strugglers!
Thank you for this post. I just got it to read out the LED-status dynamically. Wow 😉
Now I added a short HTML-code as described in httpd.h (sending the whole HTML section as a single include). Works.
How can I add more than one tag with the handler via iIndex: u16_t SSIHandler (int iIndex, char *pcInsert, int iInsertLen) ?

I'll appreciate your advices.
0 Likes
Not applicable
Hi CAN,

could you upload your example? I want to display data received via CAN on the web page and I have no clue how to insert dynamic data.

Kind regards
0 Likes
Not applicable
Hello hhh.
Sorry, vacations and spent some time with other projects.
I think we have similar projects - I also need to display dynamic data from the CAN bus.
Here's what I've got so far:
		    // LED1 auslesen und Wert an SSI-Handler weitergeben
u16_t SSIHandler (int iIndex, char *pcInsert, int iInsertLen) {
char LED_aus[10]="aus";
char LED_an[10]=""; // \"
bool Value=0;
Value = IO004_ReadPin(IO004_Handle0);
if (Value==0){memcpy(pcInsert,LED_aus,10);}
else {memcpy(pcInsert,LED_an,10);}
return 10;
}
// SSI-Handler gibt Inhalt des Tags an index.ssi weiter
static const char * tags[] ={"Wert"}; // Wert1,Wert2
http_set_ssi_handler(SSIHandler, tags, 1); //2


and inside index.ssi there needs to be:



Die LED1 ist !



currently I'll update the value at the website via:

0 Likes
Not applicable
Hello, I'm new and I have a question.
Did anyone of you tried to read some data from the webpage and get it into the xmc?
Example: I will change the value of temperature on the website and the xmc should compare it with an given value!

thanks for your help!
0 Likes
Travis
Employee
Employee
First solution authored Welcome! 500 replies posted
MarV wrote:
Hello, I'm new and I have a question.
Did anyone of you tried to read some data from the webpage and get it into the xmc?
Example: I will change the value of temperature on the website and the xmc should compare it with an given value!

thanks for your help!


Hi MarV,

This version of software uses lwIP RAW API. Subsequently we shall be introducing a new version using socket connection with RTOS.

http://www.infineonforums.com/threads/1828-XMC_HOT-XMC4500-How-to-create-a-CGI-and-SSI-web-server-wi...
0 Likes