Shop OBEX P1 Docs P2 Docs Learn Events
Spinneret losing connection??? — Parallax Forums

Spinneret losing connection???

TagametTagamet Posts: 22
edited 2011-12-01 06:51 in Accessories
Recently while running through my tests using Mike G's examples, my browsers haven't been able to stay connected. The Hello World (index.htm) would show, but as soon as I select the LED link, the page changes and the browser times out. Then the original page won't load again either. I've tried this on every port on my router, changed port addresses, same thing. The PWR, SPD, FDX led's stay lit on the Spinneret while RX & TX light up intermittently. Any help would be appreciated.

Thanks,

Tagamet

Comments

  • Mike GMike G Posts: 2,702
    edited 2011-11-25 15:52
    Tagamet, please post your source code.
  • TagametTagamet Posts: 22
    edited 2011-11-25 17:20
    Mike,

    It's your out of the box HTTPServer.spin file. It worked fine before. Now I have some extensive coding for my HTML portion that I'm not able to test. I'm still trying to decide whether to use your Get & Post methods. These worked fine until today...

    Thanks,

    Tagamet

    P.S. - I've saved the text files in ANSI & UTF in the xxxxx.htm format & have used both IE & FF previously.
  • TagametTagamet Posts: 22
    edited 2011-11-25 18:00
    Also, when I try to access http://192.168.1.120, RX & TX flash together about 3x in FF & about 6x in IE before it times out(< 1 second for each). If I add the :5000, TX lights up just once while TX continues to blink and FF takes quite some time before it times out. Just tried both browsers again, & they time out almost immediately.

    Tagamet
  • Mike GMike G Posts: 2,702
    edited 2011-11-25 18:28
    Tagamet, if you post your source code SPIN and HTML, I'll take a look.
  • TagametTagamet Posts: 22
    edited 2011-11-25 18:50
    These are basically your examples. In the spin code, I changed the IP settings and some pins in LedStatus method. The text files were saved as .htm files & all worked fine a couple of weeks ago. I have 3 HTML pages that I need to start testing their functionality in IE.

    Thanks for your time,

    Tagamet
  • Mike GMike G Posts: 2,702
    edited 2011-11-26 05:38
    In the Dispatcher method, the first filter is picking up the led.htm request. The Led() method is invoked and returns without invoking the StaticFileHandler. I'm not sure if this is your intention as I see a similar filter at the end of the Dispatcher method. This filter is never reached.
    PRI Dispatcher(id)
    
      'pst.str(string(13,"Dispatcher(id)",13))
         
      ''Do some processing before sending the response
      if(strcomp(Request.GetFileName(id), string("led.htm")) AND Request.GetDepth(id) == 1)
        if(Led(id))
          return
          
      if(strcomp(Request.GetFileName(id), string("post.htm")) AND Request.GetDepth(id) == 1)
        Post(id)
    
      if(strcomp(Request.GetFileName(id), string("aled.htm")) AND Request.GetDepth(id) == 1)
        SendLedResposne(id)
        return
        
      '' The RESTful command is in the root location
      if(strcomp(Request.GetPathNode(id, 0), string("led")))
        RestLed(id)
        return
    
      '' HTML time  
      if(strcomp(Request.GetPathNode(id, 0), string("time")))
        GetTime(id)
        return
    
      '' XML time
      if(strcomp(Request.GetPathNode(id, 0), string("xmltime")))
        XmlTime(id)
        return
    
      if(strcomp(Request.GetName(id), string("led")))
        Led(id)
      
     
      StaticFileHandler(id)
      return
    

    The browser requests led.htm?led=on or led.htm?led=off and the Led(id) method is invoked. The Led method reads the query string, changes the state of an LED, and returns true if all went well. Execution is passed back to the Dispatcher and since Led(id) == true, the Dispatcher returns. StaticFileHandler(id) is not invoked and the led.htm is not sent to the caller.

    Clean up the Dispatcher method and include only the required filters.
    PRI Dispatcher(id)
    
      if(strcomp(Request.GetName(id), string("led")))
        Led(id)
      
     
      StaticFileHandler(id)
      return
    
    

    In all HTTP transactions there is a request and a response. The Dispatcher method provides the programmer an opportunity to filter incoming requests and execute custom logic before sending a response. You must send a response or the browser will timeout.
  • TagametTagamet Posts: 22
    edited 2011-11-26 07:08
    Thanks MIke! I'll try this very shortly.

    I really appreciate it,

    Tagamet
  • Mike GMike G Posts: 2,702
    edited 2011-11-26 16:34
    Are you up and running?
  • TagametTagamet Posts: 22
    edited 2011-11-27 13:32
    Had a basketball game yesterday, I'm trying it now.

    Thanks again,

    Tagamet
  • TagametTagamet Posts: 22
    edited 2011-11-27 17:21
    Apparently, a virus I got last Friday evening destroyed all my files. I made the changes to the Dispatcher Method with no success. I'm going to step away & try again tomorrow. Frustrated on many levels.

    Thanks,

    Tagamet
  • TagametTagamet Posts: 22
    edited 2011-11-30 06:43
    Mike,

    I got the Spinneret up and working (partially) last night! I inserted your PRI SendLedResposne(id) | headerLen, qstr method from your services/ajaxled.htm page and the led turns on & off w/ no issues. For some reason, the much simpler PRI Led(id) | qstr method isn't working for me. In my html code, I'm wanting to query two radio button values and execute spin code based upon the selections. I don't think I would be able to use the a href anchor tag technique because I need to return 2 values to the Spinneret when the submit button is clicked. I'm going to try the POST option later this evening.

    Thanks again,

    Tagamet
  • Mike GMike G Posts: 2,702
    edited 2011-11-30 13:56
    HTTP POST or GET will handle two variables.

    GET Example
    myurl.com?var1=1&var2=2&var3=3

    For user entry, like radio buttons, set the method attribute of the form tag to get. Doing so will append user entry fields in the URL. Set method="post" to append the fields to the message body.
    <form action="led.htm" method="get">
      First name: <input type="text" name="fname" /><br />
      Last name: <input type="text" name="lname" /><br />
      <input type="submit" value="Submit" />
    </form>
    

    Check out w3schools for easy to follow HTML tutorials. Also see my Spinneret tutorial.

    Please post your code if you need further assistance.
  • TagametTagamet Posts: 22
    edited 2011-12-01 06:51
    I will try that those this evening. I have used w3schools extensively for my project & that has been a great help. I'll be using your returning XML as well. I'll keep you updated.

    Thanks again,

    Tagamet
Sign In or Register to comment.