Shop OBEX P1 Docs P2 Docs Learn Events
Maddeningly bizarre Spinneret issue - Page 2 — Parallax Forums

Maddeningly bizarre Spinneret issue

2»

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-02-24 01:09
    Have you performed an ethernet packet trace watching the "empty" packet on the net?
    Looking at an earlier trace when it was getting clobbered with packets, the client was sending SYNs, and the Spinneret was responding with RSTs. (I'm not sure what that means, actually.) I'll try to provide more detail in the morning, once I've got my mods to Beau's object in place.

    -Phil
  • Mike GMike G Posts: 2,702
    edited 2011-02-24 05:17
    Phil,

    This is how I handle the socket using the status register.

    Listen - > $14 -> [if $00 then reset the socket] -> TCPestablished? -> [if not $14, $16, $17, or $11 then reset the socket]

    Here's my status register monitoring code.
      repeat
        ' Initialize content pointer
        dynamicContentPtr :=  @dynamicContent
        't1 := 0
        
        W5100.readIND(W5100#_S0_SR, @S0_SR, 1)
       ' PauseMSec(1)
        if(debug)
          SN_SR := S0_SR
          PST.Str(string("****************************", Request#CR))
          PST.Str(string("Status Code 1: "))
          PST.Hex(S0_SR, 2)
          PST.char(Request#CR)
          PST.Str(string("****************************", Request#CR))
          WriteLog(string("Status Code 1: "))
          WriteLog(Request.NumberToAsccii(S0_SR))
          WriteLog(string(Request#CR))
    
        if S0_SR == $00
          ResetSocket 
    
        't1 := cnt + HTTP_TIMEOUT
        reset := 0  
        repeat while !W5100.SocketTCPestablished(0)
          'if(t1 > cnt)
            W5100.readIND(W5100#_S0_SR, @S0_SR, 1)
            ifnot((S0_SR == $14) OR (S0_SR == $16) OR (S0_SR == $17) OR (S0_SR == $11) )
              PST.Str(string("Status Code 2: "))
              PST.Hex(S0_SR, 2)
              WriteLog(string("Status Code 2: "))
              WriteLog(Request.NumberToAsccii(S0_SR))
              WriteLog(string(Request#CR))
              reset := ResetSocket
              quit
    
        if(reset)
          next
          
        if(debug)
          W5100.readIND(W5100#_S0_SR, @S0_SR, 1)
          PST.Str(string("****************************", Request#CR))
          PST.Str(string("Status Code 3: "))
          PST.Hex(S0_SR, 2)
          PST.char(Request#CR)
          PST.Str(string("****************************", Request#CR))
          WriteLog(string("Status Code 3: "))
          WriteLog(Request.NumberToAsccii(S0_SR))
          WriteLog(string(Request#CR))
    

    Next I check the packet size. If the packet is 0 I start a timer and keep trying to get the data. If there is a timeout I reset the socket.

    This is a sample of my log with the status register states.

    This is a normal looking request where the status goes from $14 to $17
    Status Code 1: 20
    Status Code 3: 23
    GET /style/style.css HTTP/1.1
    Host: spinneret.servebeer.com:5000
    User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13
    Accept: text/css,*/*;q=0.1
    Accept-Language: en-us,en;q=0.5
    Accept-Encoding: gzip,deflate
    Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
    Keep-Alive: 115
    Connection: keep-alive
    Referer: http://spinneret.servebeer.com:5000/index.htm
    Cache-Control: max-age=0
    


    This one I held down the F5 key.
    Status Code 1: 20
    Status Code 2: 28
    Reset Socket
    Status Code 1: 20
    Status Code 2: 28
    Reset Socket
    Status Code 1: 20
    Status Code 2: 28
    Reset Socket
    Status Code 1: 20
    Status Code 2: 28
    Reset Socket
    Status Code 1: 20
    Status Code 2: 28
    Reset Socket
    Status Code 1: 20
    Status Code 2: 28
    Reset Socket
    Status Code 1: 20
    Status Code 2: 28
    Reset Socket
    Status Code 1: 20
    Status Code 2: 28
    Reset Socket
    Status Code 1: 20
    Status Code 2: 28
    Reset Socket
    Status Code 1: 20
    Status Code 2: 28
    Reset Socket
    Status Code 1: 20
    Status Code 2: 28
    Reset Socket
    Status Code 1: 20
    Status Code 3: 23
    GET /images/guitar.gif HTTP/1.1
    Host: spinneret.servebeer.com:5000
    User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13
    Accept: image/png,image/*;q=0.8,*/*;q=0.5
    Accept-Language: en-us,en;q=0.5
    Accept-Encoding: gzip,deflate
    Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
    Keep-Alive: 115
    Connection: keep-alive
    Referer: http://spinneret.servebeer.com:5000/index.htm
    Cache-Control: max-age=0
    

    No data returned
    Status Code 1: 20
    Status Code 3: 23
    Status Code 1: 23
    Status Code 3: 23
    Timeout Alert
    Reset Socket
    Status Code 1: 20
    Status Code 3: 23
    GET /shp.shp?ledstate=0&ms=1298430085170 HTTP/1.1
    Host: spinneret.servebeer.com:5000
    Connection: keep-alive
    Referer: http://spinneret.servebeer.com:5000/led.htm
    Accept: */*
    User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/534.13 (KHTML, like Gecko) Chrome/9.0.597.98 Safari/534.13
    Accept-Encoding: gzip,deflate,sdch
    Accept-Language: en-US,en;q=0.8
    Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
    

    Hope this helps.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-02-24 14:45
    Thanks, Mike!

    After looking at Beau's and Mike's code more closely, I decided it was time to take the training wheels off and just dig in with a direct interface to the BrilIdea driver. And I'm glad I did. It's not as onerous as I imagined it might be, and what I've done so far works. I'm not ready to change the thread status to "solved" just yet, but it's getting closer.

    Anyway, I've attached a strip-down version of what I'm working on that works. Now it's time to start adding the original pieces back. Hopefully, it will keep working.

    Thanks to all for the assistance!

    -Phil
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-02-24 19:39
    So I put all the pieces back together, and now everything works! See the result here:

    -Phil
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-02-25 08:16
    Well, apparently it wasn't completely solved, but I had not put any timeouts in the get_request routine, and the webcam was hanging. So I added the timeout:
    PUB get_request : packet_size | time
    
      repeat until w5100.SocketTCPestablished(0)
        ifnot (lookdown(get_status : $14, $16, $17, $11))
          socket_reset
          return
      time := cnt
      repeat until (cnt - time > timeout)
        if (packet_size := W5100.rxTCP(0, @data))
          data[packet_size]~
          return
      socket_reset
      return
    
    We'll see what happens...

    -Phil
Sign In or Register to comment.