Shop OBEX P1 Docs P2 Docs Learn Events
Web Control of BASIC Stamp — Parallax Forums

Web Control of BASIC Stamp

ChuckyChucky Posts: 4
edited 2007-06-03 04:01 in BASIC Stamp
I'm trying to send commands to my BASIC Stamp from a remote PC via Ethernet and my PINK module, and I realized that I should try to build in some failure modes into the control algorithm so my outputs don't remain high if no one is manning the control computer.· Is there any set variable on the PINK module that indicates whether or not someone is viewing the webpage stored on its FTP server?· I looked in the manual but was unable to find a variable defintion that matches what I need (there's a variable which indicates refresh status, but that isn't what I need).· If there isn't a variable that does what I need, does anyone have any solutions to determining if the page is being viewed using the other available variables on the PINK?

Thanks,
Q

Comments

  • FranklinFranklin Posts: 4,747
    edited 2007-06-03 00:08
    How long would the stamp run without input if it was being controlled? Even if someone is looking at the page if they are not inputting corrections you would want the stamp to go to standby mode at a reasonable interval. (I would guess as you haven't told us what the stamp IS doing)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • ChuckyChucky Posts: 4
    edited 2007-06-03 00:17
    Right now, the Stamp would go on indefinitely because I'm using it to control a motor via a web interface.· I wouldn't want the motor to shut down just because I didn't tell it to do anything for a while.· I'd really like to build in the failsafe where if the Stamp registers a closing of the control webpage window, it shuts down everything it's controlling.· This is in an attempt to prevent runaway devices and to account for accidental webpage closure.
  • FranklinFranklin Posts: 4,747
    edited 2007-06-03 00:24
    I don't understand web servers as well as I should but it is my understanding that the server sets waiting for inout on port 80 and when it receives a 'get' request it returns the page requested and has no other connection to the requesting computer. What they do with that page is unknown to the server.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • Kevin WoodKevin Wood Posts: 1,266
    edited 2007-06-03 02:21
    The problem with tying the failsafe to the webpage is that if you lose that connection for any reason, you also lose your failsafe option.

    You can certainly put a big red STOP button on the webpage, but if there is a problem at the motor, that's where it needs to be handled as a last resort.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2007-06-03 04:01
    One way to do what you want is to include code in the webpage that forces, at fixed intervals, either a complete refresh of the page (Google: http meta refresh) or less intrusive requests to the server (Google: javascript setinterval). The server will know when the control window has closed, because it will cease receiving these requests and can simply time out.

    Another method is to force a request when the browser leaves or closes the page (Google: javascript onunload).

    Requests can be sent to the server using JavaScript (Google: javascript submit) to submit a form, which can be empty if you like.

    If all this sounds like Greek, O'Reilly has graciously posted the entire texts of its essential HTML, JavaScript and "Ajax" references. Go check 'em out!

    -Phil
Sign In or Register to comment.