WebServer_W5100_RTC driver questions
Shawna
Posts: 508
I am going to try and revisit my modbus master project with the spinneret web server as my front end.
My initial goal to start out, will be to get the web server running and to display an array of variables from my spinneret prop to a web page using xml hopefully. I have been following Mike G's beer.com tutorial but I am struggling. After reading through some threads I have gathered that I should switch to the new driver which if I understand correctly is the WebServer_W5100_RTC.
My first question is, how do I turn off the DHCP and set up a static IP address? I see this line of code in the W5100 object (_ip byte $00, $00, $00, $00), however giving an address here does not do anything. I am sure there is a config variable that I need to change to shut off DHCP but I am not sure where.
Thanks
Shawn
My initial goal to start out, will be to get the web server running and to display an array of variables from my spinneret prop to a web page using xml hopefully. I have been following Mike G's beer.com tutorial but I am struggling. After reading through some threads I have gathered that I should switch to the new driver which if I understand correctly is the WebServer_W5100_RTC.
My first question is, how do I turn off the DHCP and set up a static IP address? I see this line of code in the W5100 object (_ip byte $00, $00, $00, $00), however giving an address here does not do anything. I am sure there is a config variable that I need to change to shut off DHCP but I am not sure where.
Thanks
Shawn
Comments
So if I have an array of 6 variables in my prop I can update the areas of the web page once per second, or is this not a realistic goal? My end goal is a web page that could have as many as 60 variables that I would like to update every second, or maybe every 5 seconds. Is this possible, or am I dreaming?
I am still not totally sure which would fire the xml refresh of the data points on my web page, a timer in the prop code or java script that was loaded when the html web page was loaded. If I am understanding what I am reading it would be the java script in the web page that fires a xml request, am I right in thinking this?
Thanks
Shawn
60 variables every 1 second may be pushing it.
And yes, you are correct -- JavaScript in the page fires off an AJAX request (essentially a URL passed "behind the scenes" to a server); the result (text stream) of that URL is handled by an AJAX event function in the webpage (again, JavaScript). The event handler is responsible for repopulating sections of the page based on the response.
Note that you do not have to do XML for AJAX. If you are trying to update a lot of variables, it may be better to compress that data into the tightest text string possible, interpret it as a plain string in the AJAX event handler in the page, and do some extra parsing. I.E., you could do a delimited string that is your 60 variables, and then use a little JavaScript string manipulation in your event handler to split out the info:
value1|value2|value3|value4|......|value60
Actually, you could still do XML, but keep everything in one XML "variable" for compression's sake, then split up that string via JavaScript:
<root>
<data>
value1|value2|value3|value4|......|value60
</data>
</root>
The value of "data" in your XML handler would get split up and digested for the 60 variables.
The InitNetworkParameters method in WebServer_W5200_RTC contains an example of requesting an IP using DHCP. Yes, the client (browser) makes the request. The setInterval() Javascript method invokes a function at a determined intervals.
I agree with zoot, if 60 data elements are needed then getting as many as possible in one request is optimal. Wrapping the data in XML or a propriety format is up to the programmer and application requirements.
The W5200 demo code contains a touch pad example (Propeller Quick Start board). Where the Quick Start touch pad state is displayed on a web page every half second.
I am still researching. I am using the spinneret, which I believe uses the W5100 chip. Should I use the WebServer_W5200_RTC driver or the WebServer_W5100_RTC Driver.
Shawn
W5100.spin wraps the driver.
WebServer_W5100_RTC.spin is a program that references the wrapper object which, in turn, references the driver.
Spi5100CounterPasm.spin and W5100.spin are required for the Spinneret (W5100). All higher level object DHCP, DNS, WebServer_W5x00_RTC will work with either device as long as the appropriate object is referenced on the OBJ block.
The other constraint, hardware sockets. The W5100 has 4 sockets while the W5200 has 8.
http://narnold79.dyndns-at-home.com:5000/
Thanks
Shawn
WebServer_W5100_RTC.spin has 3 available sockets. The web page contains 4 images. That's a possible (worse case) 5 concurrent socket request. Probably more like 3 or 4 depending on the image size and time to transmit.
WebServer_W5100_RTC.spin is updated this morning to function like WebServer_W5100.
http://code.google.com/p/propeller-w5200-driver/source/browse/trunk/#trunk%2F%20propeller-w5200-driver%2FSpinneret
Give the update a shot. If the update does not work, zip and attaching the entire web site.
Mike did you get the images to come up at all. I would like to eventually have more than 6 or 7 images on a page, maybe this is not possible.
Thanks
Shawn
6-7 images is a lot considering the Spinneret has 4 hardware sockets. Functioning as expected depends on the image size and network latency.
The HTTPserver's Tx buffer is 2k. A 10k image file takes 5 reads from file, 5 SPI writes to the W5100, and 5 flushes to complete a send. If there are six to seven 10k images sources on a page, the browser may try to open all 6 to 7 sockets at once - or very close to all at once. The browser and Spinneret can behave unexpectedly if all sockets are busy.
JavaScript can be used as a work-around to load the images one at a time after the page loads.
I can't seem to get any of the new W5100 programs to compile, they all fail at the same spot.
pathElements := req.PathElements
pathElements is highlighted and it say a subroutine is needed.
Even the new file you updated this morning, I am trying to see where I downloaded the folder I have, I can't seem to find it again. Here is the spin folder I have plus the modified W5100_RTC.spin file.
WebServer_W5100_RTC - Archive [Date 2013.02.20 Time 07.00]1.zip
I am still in the process of digging.
Thanks
Shawn
I would be very interested in seeing how this works, I am going to do some research on it.
I have switched to the new code base also, using the W5100_RTC.spin.
Here is a zip file with my html code and spin code, its not very interesting but feel free to take a look.
Spinneret Project.zip
Thanks
Shawn
I guess post 12 was not clear. The Spinneret has 4 hardware sockets. WebServer_W5100_RTC.spin uses 3 sockets for the web server and 1 socket for DHCP/SNTP (UDP). WebServer_W5100_RTC.spin can handle web pages containing 3 file references. Each additional file reference, above 3, has a greater chance of error.
The example below renders an image on a hyperlink click event.
resource = the image URL
elementId = src attribute of an image tag
callerId = source link (could use "this") Experimentation, reading Javascript code references, and DOM references should provide enough knowledge to accomplish the image task.
There's also dropping the images on another web server and referencing the remote images in HTML. Doing so relieves the Spinneret from mundane image rendering.
I read post 12, and it sunk in, actually I have learned a great deal from this thread already. I was not trying to be stubborn or dense, I was merely playing with the hardware that I had available to me.
Am I wrong in thinking the the W5200 chip would do a little better with more pictures on a page since it has 8 sockets, or am I still missing something?
I am kicking around the idea of getting the W5200 board for the quick start board.
Thanks again for you help
Shawn
This is a simple matter of math and application requirements. An HTML page with two images requires three socket requests. One HTTP request for the initial HTML page and two requests for the images. This is true for any web server. WebServer_W5100_RTC.spin, out-of-the-box, has 3 available sockets. WebServer_W5200_RTC.spin has 7 available TCP sockets.
Two other options mentioned above.
1) Use JavaScript to manage the images rendering
2) Drop the images on another web server
IMO, it would be much more rewarding to tackle the 60 data element problem posted earlier. That's got problem solving and learning new stuff. Rendering files from an SD card already works.
I agree with you Mike.
My end goal would be having a bunch of small pictures on the page that will change depending on a value that is received from server. When I say small, I mean small file size, something around 20kb. I think this is called an image swapper.
So I guess my first goal was to serve up images.
My second goal is to pass values to the web page without refreshing the whole page.
And then my third goal is to figure out the image swapper.
I am sure there are many steps in between those steps, but I have to start somewhere.
I like the sound of option 1, and have been trying to do some research on it.
Option 2 is a good idea, but part of the appeal to me about this project is that everything would be on a small low power consuming server. I may not have the programming skills to pull this off but I am going to try.
I already have a small web server running that does all of this, but it is expensive and hard to use, and limited on storage. It also is hard to build custom web pages on.
I went ahead and purchased the w5200 quick start adapter board. I did not realize it even existed. The examples that you have put together for the board look great, I can see why you do not want to support the httpserver anymore.
Thanks
Shawn