I spent some time today checking out the code for the webserver demo and the camera demo.
Wow. This is sooo not the quick and easy project I thought it would be!
The code consists of some heavy duty C, and there's lots of it.
It's nicely organized though - the projects separate out the libraries (which we shouldn't need to touch) from the code specific to the project. This specific project code is kept separately in a folder named "User", so that narrows things down when looking to find out how things work.
The webserver sample (standalone/Httpserver) appears to be quite a capable full-featured web server. The pages are read from the SD card (thankfully my card works for reading, if not for writing), and specific tags are replaced on the fly. In this example they use a tag to read the millivolts value of a pin that is connected to a potentiometer.
The handling of the tags is set up in the User folder in the file httpd_cgi_ssi.c, and basically assigns a function to a given tag. The function is then called when needed, populates a structure, and returns the number of characters it is providing to replace the tag.
Pretty cool design actually.
The camera sample is interesting too.
While trying it out, I could see the camera streaming the image to the display - very cool! However, I was never able to get it to successfully write to my SD card, which appears to be because of limitations in compatibility with different cards. I think my card is a Lexar, and they only officially support 3 specific cards: "Kingston 1GB/2GB andSanDisk 2GB".
Looking at the code for that, it seems to be set up to stream the image information from the camera straight to the display. Then when the user presses the button it pauses the streaming and copies the image from the display and saves it to the file. In my case it then hangs, but looking at the code it should finish the picture, update the counter in another file, and happily go back to streaming the image to the display.
So I have a few hurdles coming up:
1. My time limit of the IAR software is coming up, after which I won't be able to use the webserver demo anymore because it's too big for the size limit. And I don't want to spend $300/month leasing the software. I might have to try a different IDE (I think Keil is the only other option I have there).
2. I need to figure out how to take a snapshot of an image from the camera so that it can be served up by a webserver. I like having the display available for debug information, but in a pinch I suppose I could use the same method the camera sample uses - ie, stream to the display and then take what's on the display to send to the client browser.
3. I need to figure out how to serve up an image from the webserver. As this is already done in the sample with images from the SD card, that part shouldn't be too hard - I could probably even fake it by saving a picture to disk using a specific file name. Using that filename would be similar to the use of a special tag, except that I wouldn't have to do any extra coding on the webserver side.
A few things bother me about these demos and this dev board, and it's mostly because I've been using Arduino - I have SEEN the other side, and the grass really IS greener!
For example, the Arduino "Ethernet/Webserver" example is exactly the kind of quick and easy sample I would have loved for this webcam project - it's not a full-out webserver, but in a tiny clean and easy simple sketch it allows me to serve up some really cool information. Their implementation of EthernetServer and EthernetClient objects makes the whole process so much easier.
I think what it comes down to for me is this - I'm doing this as a hobby, and I don't require the power and complexity of a full web server. I want to be able to go in, easily see what's going on, and make a few simple changes to customize the examples to work for something I need in my hobby world.
I really wish companies like STM would take the time to port the Arduino samples to their platforms. If they could also include a simple Arduino-like IDE, that would be even better.
That would open up the door for a hobbyist like me to try out different boards without having to relearn everything for every platform. And the Arduino samples would give a much better stepping stone towards far more potential projects than the current, usually limited, set of examples that come with non-Arduino dev boards.
Maybe it's because I've already spent so much of my life writing code in C that I just don't want to be doing it the hard way anymore!
Well, that's it for tonight!
Cheers,
-Nico