Shop OBEX P1 Docs P2 Docs Learn Events
WebServer_W5100_RTC driver questions — Parallax Forums

WebServer_W5100_RTC driver questions

ShawnaShawna Posts: 508
edited 2013-09-17 18:52 in Accessories
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

Comments

  • ShawnaShawna Posts: 508
    edited 2013-09-15 17:07
    I have been reading some on xml and it is very confusing. I can use AJAX to display dynamic data in different areas of a web page without refreshing the whole page, is this correct?

    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
  • ZootZoot Posts: 2,227
    edited 2013-09-15 17:21
    6 variables updated at 1hz is reasonable via AJAX.

    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.
  • Mike GMike G Posts: 2,702
    edited 2013-09-15 17:27
    My first question is, how do I turn off the DHCP and set up a static IP address?
    The "SetRequestIp" field of the DHCP, if populated, will request an IP address. The DHCP server may not grant the request.

    The InitNetworkParameters method in WebServer_W5200_RTC contains an example of requesting an IP using DHCP.
    PRI InitNetworkParameters | i
    
      i := 0 
      'Initialize the DHCP object
      dhcp.Init(@buff, DHCP_SOCK)
    
      'Request an IP. The requested IP
      'might not be assigned by DHCP
      dhcp.SetRequestIp(192, 168, 1, 120)
    
      'Invoke the SHCP process
      repeat until dhcp.DoDhcp(true)
        if(++i > ATTEMPTS)
          return false
      return true
    
    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?
    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.
  • ShawnaShawna Posts: 508
    edited 2013-09-15 17:37
    Thanks Guys.
    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
  • Mike GMike G Posts: 2,702
    edited 2013-09-15 17:48
    The driver is Spi5100CounterPasm.spin.
    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.
    OBJ
      wiz             : "W5100"
    

    The other constraint, hardware sockets. The W5100 has 4 sockets while the W5200 has 8.
  • ShawnaShawna Posts: 508
    edited 2013-09-15 19:30
    Here is what I have been playing with so far. Just a simple page with some pictures on it. The page seems to work well from inside my house but when I view it from an external address I seem to have to hit refresh a couple times. The pictures don't always download, maybe the new software will fix this. Would you guys like to try it and see if it will come up for you. I am still using the old httpserv. My ISP will reset my IP address tonight but I will up date the link tomorrow.
    http://narnold79.dyndns-at-home.com:5000/

    Thanks
    Shawn
  • ZootZoot Posts: 2,227
    edited 2013-09-15 19:33
    The page source comes through fine; none of the images come through.
  • ShawnaShawna Posts: 508
    edited 2013-09-15 19:45
    I have the same problem. If the page is refreshed the images will sometimes show up sometimes. Firefox seems to work better than the rest also. I am not sure the reasoning for this. Hopefully, it is the version of the web server I am using on the prop.
  • Mike GMike G Posts: 2,702
    edited 2013-09-16 04:39
    Good question, which server is loaded? WebServer_W5100_RTC.spin is limited to rendering files from the root while WebServer_W5100.spin can handle sub directories. Images in sub directories should never render with WebServer_W5100_RTC.spin running.

    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.
  • ShawnaShawna Posts: 508
    edited 2013-09-16 10:38
    I was not using the new drivers, I was using the old httpServ from the BeerServ site. When I get home I will load new software on the spinneret and see what happens. I haven't tried to set the DHCP settings like you suggested Mike, I will try that when I get home also.

    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
  • Mike GMike G Posts: 2,702
    edited 2013-09-16 11:28
    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.
    No, the images did not come up. I'd have to see all your source, spin and HTML, to figure out the problem. Honestly, I'd rather not continue supporting the older code base.

    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.
  • ShawnaShawna Posts: 508
    edited 2013-09-16 17:22
    Mike, thanks for the help so far.

    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
  • ShawnaShawna Posts: 508
    edited 2013-09-16 18:09
    Well I am not sure what the problem was but I copied and pasted all of the files from the google site into a new folder and it seems to work now. Try it again if you would guys.
  • ShawnaShawna Posts: 508
    edited 2013-09-16 19:03
    Well I have loaded more pictures just to see what happens, one of the pictures never shows up.
    JavaScript can be used as a work-around to load the images one at a time after the page loads.

    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
  • Mike GMike G Posts: 2,702
    edited 2013-09-17 04:13
    Well I am not sure what the problem was but I copied and pasted all of the files from the google site into a new folder and it seems to work now. Try it again if you would guys.
    The Google Code Repo will always have the latest. The downloads section may not. That's why post 10 links to the source trunk.
    Well I have loaded more pictures just to see what happens, one of the pictures never shows up.
    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.
    I would be very interested in seeing how this works, I am going to do some research on it.
    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")
    <a href="index.htm" id="spinneretlink" onclick="return getImage('images/snetb.png', 'spinneret', 'spinneretlink');">Spinneret Image</a>
    
    function getImage(resource, elementId, callerID)
    {
        var img = document.getElementById(elementId);
        img.src = resource;
        document.getElementById(callerID).style.display = 'none';
        return false;
    }
    
    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.
  • ShawnaShawna Posts: 508
    edited 2013-09-17 07:42
    Thanks for your help Mike.

    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
  • Mike GMike G Posts: 2,702
    edited 2013-09-17 15:14
    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 can't answer the question...

    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.
  • ShawnaShawna Posts: 508
    edited 2013-09-17 18:52
    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.
    Two other options mentioned above.
    1) Use JavaScript to manage the images rendering
    2) Drop the images on another web server

    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
Sign In or Register to comment.