Shop OBEX P1 Docs P2 Docs Learn Events
Dynamic Spinneret with HttpRequest Object and EEPROM Configuration Page — Parallax Forums

Dynamic Spinneret with HttpRequest Object and EEPROM Configuration Page

Mike GMike G Posts: 2,702
edited 2011-02-24 20:35 in Accessories
Here's my latest Spinneret Web Server source. I added a configuration page that reads setting from EEPROM. I'll leave the server up for a few hours today if anyone wants to check it out.
http://spinneret.servebeer.com:5000/

Plus I attached the source files. Just go to the configuration link from the home page.

I'm thinking of moving the configuration page to EEPROM. Right now it's just a bunch of string writes in a method.

Source code:
http://www.agaverobotics.com/spinneret/source/

Comments

  • Mike GMike G Posts: 2,702
    edited 2011-01-05 06:42
    Updated code base with W5100 driver fix.
  • schillschill Posts: 741
    edited 2011-01-05 07:02
    I like the configuration saved in EEPROM.

    I've been thinking about a different variation but I haven't implemented it yet. I was thinking that it would be useful to put this information in a standard text file saved on an SD card - something like address.txt. Instead of reading from EEPROM, it could just read from the card. A form like your configuration page could still be used to set the data.

    Of course, this would require that you have a card on the board but they are so cheap these days that I don't see that being too much of a problem.

    The major benefit I see to this approach is that you can edit that file on any PC, save it to the card, and then plug it into the Spinneret. You don't have to know a default IP or anything else to access the Spinneret the first time in order to change the configuration.
  • Mike GMike G Posts: 2,702
    edited 2011-01-05 07:32
    You still need to know the IP address, right?

    My plan is to use Roy's awesome DHCP code with the configuration code. That way network setting are remotely available when the Spinneret is assigned an IP. Just need ot add a little ping application to find the Spinneret or connect the Spinneret directly to a PC the first time or just do it with the Prop tool and spin . From there a user can assign an IP and disable DHCP or leave the settings as is. I think this is a better approach for ease of use for future Parallax Spinneret customers. Parallax can load the EEPROM during manufacturing. Plus a configuration interface provides a method to validate user input.
  • schillschill Posts: 741
    edited 2011-01-05 07:49
    I'm assuming that between the time I write the file to the SD card and the time I try to access the Spinneret, I won't forget the IP. What I like about the text file/SD card approach is that it does not require any hardware or software beyond what people typically already have. It also doesn't depend on too much knowledge of network configuration, managing DHCP (on the router), etc.
  • Mike GMike G Posts: 2,702
    edited 2011-01-05 09:07
    Don't you need to know the subnet and gateway IPs too? That requires some basic network knowledge and the main reason I though DHCP would be a lot easier for first time users.

    I'm not knocking your approach at all, do whatever is clever. I'm simply following a different path.

    Looking forward to seeing your work. The more options available just make things easier for Spinneret users.
  • schillschill Posts: 741
    edited 2011-01-05 09:23
    I don't have any problems with your approach, either.

    Regarding subnet masks, etc... I expect that 99.99999% of users can just be told that the subnet mask should be 255.255.255.0. So that's not too hard to specify.

    I do have a question, though. Do you think the gateway IP is required in general or only for specific uses? I know a lot of things don't really care about it. This question has nothing to do with the approaches we are talking about, I'm just not sure what's really required.

    If you use DHCP, then the user needs to identify the device. A lot of devices do this with a separate utility program that you run (which you mention in your post) - whether it's a custom program or a "ping" approach. Ideally, you will need to support that utility on multiple OSs (I guess if it's in Java, Python, etc. that can be handled pretty easily, but then people will need those installed). If you require it to be connected directly to the PC through USB, then people will need that additional hardware (prop plug or similar).

    Of course, my approach requires people to have the ability to write to an SD card from their PC. I think having this stored as human readable text on the SD card is just more versatile than storing it on the EEPROM (although it requires more code in the Prop to parse it). The data can still come from DHCP - in that case maybe the file contents could look like this:

    000820223939
    DHCP
    5000

    Which would specify the MAC address and port. The rest could come from DHCP.

    I guess we could all just add LCD displays to our devices to display the results of the DHCP.


    Edit:
    One other issue with using a utility to find the device occurs when you have multiple devices on the network. You need to identify which is which (the identification will be easiest by looking at the MAC address, I guess - assuming they have been configured with the correct one (matching the sticker)). I've been doing most of my testing with two Spinnerets on my network (mounted to a custom carrier board for now - I'm addicted to having things laser cut).
  • GadgetmanGadgetman Posts: 2,436
    edited 2011-01-21 13:18
    You need the Subnet mask and Gateway address if you want to communicate with anything outside the local network.

    The Subnet mask is used to mask the address to see if it's outside the local network, and alter the packet accordingly.

    But you can find those numbers on ANY computer on the local network as they al need to use the same values.
    On windows, just open a command prompt(Start -> Run... "CMD.EXE")
    Type this command:
    IPCONFIG
    And voila, you find all the numbers you need.
  • pthartmannpthartmann Posts: 27
    edited 2011-02-24 19:56
    Hey Mike - I really appreciate you sharing this code. I've been able to load our page straight from the SD card now.

    - I've noticed if the page is directed to a particular file, example;
    Sometimes if http://IP_ADDRESS/file.ext is typed into the browser, it seems to crash the webpage.(-Your .jpg comes up fine when pointed to directly, until I type something else in that is - then I lock up the Spinneret)

    -Is this due to the use, my misuse that is, of your temp.htm?

    As I've mentioned in my thread, I'm trying to write to a text file, but I am having trouble hosting/accessing the text file from the SD card.

    Thanks.
  • pthartmannpthartmann Posts: 27
    edited 2011-02-24 20:35
    ah, figured out first problem:

    as dully noted from the thread here, I needed to include:
    elseif strcomp(Request.FileExtension, string("js"))
    StringSend(0, string("Content-Type: text/javascript")

    I also needed to change:
    StringSend(0, string("Content-Type: text/plain; charset=utf-8"))

    Looks like things are moving forward now!
  • Do somebody have the spin of the first post, or example equivalent?
    I do not really need the eeprom side

    I try to make a quick html config page, last part of a project.
    So push Ip web input settings to spin.

    Thank-you
Sign In or Register to comment.