Skip to main content
Topic: Getting started building custom web pages/CGI (Read 6326 times) previous topic - next topic

Getting started building custom web pages/CGI

What we're trying to do is make a simple web request such as: http://192.168.0.100/mycode.cgi?somedata=xyz, process that data by sending it out the IO pins and provide some textual/html response. Initially we'd be happy just to call our own code and flicker an LED of course.

We've got the web platform v1.1 board all set up. We've successfully loaded the demo microchip website, and we've successfully loaded our own HTML web pages onto it (as well as the microchip demo pages).

Our next step now is to get the web platform to execute our own code so we can control the hardware.

I don't see any documentation that explains how custom code/webpages get created for the web platform. If such documentation exists I have not been able to find it, please direct me to it.

Without documentation I'm working backwards from the examples that are provided. I've successfully used MPFS2.exe to package our static web pages. I see in the microchip demo HTML code that the webserver can do some fancy server-side code, such as in this example of forms.htm:

 
Code: [Select]
<select name="led4"><option value="1" ~ledSelected(4,TRUE)~>On</option>

where the function ledSelected(...) is clearly defined in customHTTPApp.c (though it's not clear to me how this code ever got deployed to the webserver as I don't see mention of it in any file in the 'WebPages2' directory).

I also see the use of CGI programs deployed along side the html files in the microchip demo app. Though I've compiled a simple hello world cgi app in C using MPLAB and tried renaming the output .HEX file to a .cgi and tossing it in with the webpages, the webserver only serves the binary file as if it was HTML. I don't know how to make it recognize a cgi application (which seems like what we want to be able to do).

Any pointers to documentation or in the correct direction would be helpful.

Re: Getting started building custom web pages/CGI

Reply #1
I think this was the key bit of documentation I didn't know where to look for: http://www.microchip.com/webinars.micro ... e=en543032

At first look I hadn't understood that "Microchips TCP/IP stack" referred to and included the HTTP webserver. I had thought that was an add-on to a lower level "TCP Stack" provided by Microchip, and that those binaries were simply necessary for the build of the HTTP server and such on top of it to succeed.

Now I see that microchip's HTTP stack IS providing the web server, and hence the documentation on the webserver is over there (not here, where I was looking).

Looks like I'm back on track for now.

Re: Getting started building custom web pages/CGI

Reply #2
Follow on question:

I'm now trying to compile the TCPIP Demo App-C30 from the Web Platforms SVN repository.

I've tried two different versions of the microchip TCPIP stack, both the newer 'Microchip Solutions v2010-10-19', and the older 'Microchip Solutionsv2010-02-09' as referenced on the Web Platform site.

I've followed the directions in main.c, as far as I can tell, correctly. And in both instances I get compilation errors:

With TCPIP Stack version: Microchip Solutions v2010-10-19'
Code: [Select]
CustomHTTPApp.c: In function 'HTTPExecuteGet':
CustomHTTPApp.c:247: error: 'LED5_IO' undeclared (first use in this function)
CustomHTTPApp.c:247: error: (Each undeclared identifier is reported only once
CustomHTTPApp.c:247: error: for each function it appears in.)
CustomHTTPApp.c:250: error: 'LED6_IO' undeclared (first use in this function)
CustomHTTPApp.c:253: error: 'LED7_IO' undeclared (first use in this function)
CustomHTTPApp.c: In function 'HTTPPrint_version':
CustomHTTPApp.c:1389: error: 'VERSION' undeclared (first use in this function)
CustomHTTPApp.c: In function 'HTTPPrint_led':
CustomHTTPApp.c:1445: error: 'LED5_IO' undeclared (first use in this function)
CustomHTTPApp.c:1448: error: 'LED6_IO' undeclared (first use in this function)
CustomHTTPApp.c:1451: error: 'LED7_IO' undeclared (first use in this function)
CustomHTTPApp.c: In function 'HTTPPrint_ledSelected':

With TCPIP Stack version: Microchip Solutionsv2010-02-09'
Code: [Select]
Executing: "C:Program FilesMicrochipMPLAB C30binpic30-gcc.exe" -mcpu=33FJ128GP204 -x c -c   "..MicrochipTCPIP StackTick.c" -o"Objects - TCPIP Demo App-C30Tick.o" -I"." -I"C:ProgrammingWebserver1.1Microchip Solutionsv2010-02-09MicrochipInclude" -I"%PROGRAMFILES%MicrochipMPLAB C30include" -g -Wall -mlarge-code
In file included from C:/Programming/Webserver1.1/Microchip Solutionsv2010-02-09/Microchip/Include/TCPIP Stack/TCPIP.h:284,
                from ..MicrochipTCPIP StackTick.c:59:
C:/Programming/Webserver1.1/Microchip Solutionsv2010-02-09/Microchip/Include/TCPIP Stack/Helpers.h:64: error: conflicting types for 'ultoa'
c:/program files/microchip/mplab c30/bin/bin/../../include/stdlib.h:91: error: previous declaration of 'ultoa' was here

Any thoughts? Thanks.

 

Re: Getting started building custom web pages/CGI

Reply #3
Which version of the C30 compiler are you using? v3.30b was the last one that I tried that "just worked".

PM me if you can't find v3.30b.