Shop OBEX P1 Docs P2 Docs Learn Events
Trouble getting W5200 connected , Solved , DHCP+Netbios+Basic Auth+Multisocketserver - Page 5 — Parallax Forums

Trouble getting W5200 connected , Solved , DHCP+Netbios+Basic Auth+Multisocketserver

123578

Comments

  • Igor_RastIgor_Rast Posts: 357
    edited 2012-10-18 07:56
    I'll do that .Let you know how it works as soon as i get it working again

    Still got the problem with my simpleide . trying to make it works , nothings seems to work , think its gonna be a full system restore. to try again . but ill have to backup all my files . taking the necessary time again.
    Ill keep you posted
  • Igor_RastIgor_Rast Posts: 357
    edited 2012-10-19 15:21
    Mike , I have to say , the DHCP demo works fine , 100 % of the time

    But cant say that about the multisocketserver + DHCP . you havent updated the dhcp.spin file yet ?
    im still fighting the simpleide problem
  • Mike GMike G Posts: 2,702
    edited 2012-10-19 15:53
    But cant say that about the multisocketserver + DHCP . you havent updated the dhcp.spin file yet ?
    I don't want folks reading this to get the wrong idea. DHCP and multi-socket has always worked in my environment. And yes DHCP has been updated to use the router IP as the gateway.

    EDIT: [foot in mouth] I forgot to commit the DHCP changes. Please get the latest.

    The issue was figuring out why your environment was not behaving as expected. You're network is a bit slower which was causing timeouts. To compound the issue, reinstating the connections was also too fast for your network. I refactored the Socket.Available method so it was easier to configure the two different timeouts. Then I simply guessed on a timeout period that would work for you. I'll probably expose the timeout periods so the properties are user configurable rather than setting a constant.

    I do appreciate your help in resolving this issue.
  • Mike GMike G Posts: 2,702
    edited 2012-10-19 17:48
    I added two setter methods to Sockets.spin.
    PUB SetTimeout(value)
      _timeout := value
    
    PUB SetTransactionTimeout(value)
      _trans_timeout := value
    


    SetTimeout = timeout waiting for a response to an initial request
    SetTransactionTimeout = timeout period during data transfer

    You can do nothing and use the defaults or set thresholds. Defaults are in the CON block of Sockets.spin.
  • Igor_RastIgor_Rast Posts: 357
    edited 2012-10-22 08:04
    Hi Mike, I have taken some time with the simpleide which is now solved back , the code was messed up hanging the program. that,s history now

    about the DHCP + multisocket .
    I went to tear down the hole code to a minimum that gets the temp & lv from the sensor , and post it in the graph . the HTML5graph demo

    So I made a new projectfile and started with the minimus for the code , using the HTML5graph.spin from the code reprosetory

    now the programms runs correctlt mostly

    but sometimes abou 25-50% of the time . When getting the ip settings .
    in the DHCP i think ,. All hell breaks loos . just like wtc was mentioning in the beginning , I also had this problem before. but it was solved before by you .
    with the last update it started again . to do the randow characters .the serial terminal gets all sorts of random karackters sended too it .

    resetting it may not always work ,
    any ideaś

    and Mike Ill love to contribute to your project and solving the current issues. no worry about that. Im getting my stuff working to :P

    here is the project as is , the teared down one .works sometimes , other times hell breaks loos
    this is also the case with the dhcp demo In my environment that is
    opop.zip
  • Mike GMike G Posts: 2,702
    edited 2012-10-22 13:29
    I'll take a look when I get home. However, the DHCP object will return an error if something goes wrong. If you ignore the error and move on - well - you can get unexpected results.
  • Igor_RastIgor_Rast Posts: 357
    edited 2012-10-22 13:43
    Mike G wrote: »
    I'll take a look when I get home. However, the DHCP object will return an error if something goes wrong. If you ignore the error and move on - well - you can get unexpected results.

    I don't understand what you mean by if something goes wrong , and I ignore it , whats being ignored then ?
  • twctwc Posts: 107
    edited 2012-10-22 17:08
    My setup doesn't 'crash' (i.e. repeat serial garbage) now, but I think I've seen it can be 'crashed' by stressors like running a new program when a previous one didn't complete normally. Almost seems like W5200 or router is in some partial state, confuses the program. Kind of brings up the issue of nRESET. It seems to work left floating, but... Depending if/how nRESET is wired up that means hitting the Prop reset switch doesn't necessarily nRESET the W5200 so it and the stuff it's connected to would continue to do their thing (ex: fill a buffer) until... To complicate matters, on my Prop Demo Board setup it seems the USB interface backfeeds enough power to the Wiz820io to keep the W5200 at least partially alive (the RAM buffers are 'non-volatile' even with the board power switch off!). And I don't recall seeing the software reset command being issued. Just wondering if the software is perfectly hardened against ambiguous initial state.
  • Igor_RastIgor_Rast Posts: 357
    edited 2012-10-22 17:48
    twc wrote: »
    Almost seems like W5200 or router is in some partial state, confuses the program. Kind of brings up the issue of nRESET.
    the nreset is what i also had in mind , usualy i runed a dira to hold the pin up ( its connected to the prop ) . but I now use a wire to make sure the pin is high , just to be sure , but that doesnt seem to solve it
    twc wrote: »
    To complicate matters, on my Prop Demo Board setup it seems the USB interface backfeeds enough power to the Wiz820io to keep the W5200 at least partially alive
    I never thout of this, could be why it doesnt fully reset . ill go try and tweak a few more to figure out.
  • Mike GMike G Posts: 2,702
    edited 2012-10-22 19:16
    Yes, your download crashes my system too. I'm not sure why.

    You can grab the latest code. Only comments were updated though.
  • Mike GMike G Posts: 2,702
    edited 2012-10-23 04:44
    I figured out the problem.

    In Socket.spin set the TRANS_TIMEOUT to 3000. It is currently set to 10,000 which is way to high.
    TRANS_TIMEOUT     = 3000   
    

    I must have commits the 10,000 at some point without testing.

    I also updated the dchp logic in Html5Graph so dhcp will retry if it times out.
    DHCP_ATTEMPTS = 5 
    ...
     PUB Main | i, page, dnsServer
    
      i := 0
    
      pst.Start(115_200)
      pause(500)
      
      pst.str(string("Initialize W5200", CR))
      wiz.Start(3, 0, 1, 2) 
      wiz.SetMac($00, $08, $DC, $16, $F8, $01)
    
      pst.str(string("Getting network paramters", CR))
      dhcp.Init(@buff, 7)
      pst.str(string("Requesting IP....."))
    
      repeat until dhcp.DoDhcp
        if(++i > DHCP_ATTEMPTS)
          quit
    
      if(dhcp.GetErrorCode > 0  OR i > DHCP_ATTEMPTS)
        pst.char(CR) 
        pst.str(string(CR, "DHCP Attempts: "))
        pst.dec(i)
        pst.str(string(CR, "Error Code: "))
        pst.dec(dhcp.GetErrorCode)
        pst.char(CR)
        pst.str(dhcp.GetErrorMessage)
        pst.char(CR)
        return
      else
        PrintIp(dhcp.GetIp)
    
  • Igor_RastIgor_Rast Posts: 357
    edited 2012-10-23 08:03
    Hi Mike , Thanks for the quick fix .

    as it seems the random characters are not hanging the prop anymore , and it does connect to the net

    however .
    I have spent some time wiresharking to be sure

    When it comes to the time that the prop doesn,t get a Offer back the first time it send out the discovery .

    It doesnt, hang ,
    It seems like the prop does it right , an second discovery is send back out again , and this time it does get the package and even broadcasts back to the modem , after that the modem relpys with the DHCP-ACK. like normaly

    Anyway ,
    On the serial terminal side . when it get stuck the first time I see the error code popping up , attempt number is error .
    attempt number 2 seems to be carryied out fine . if i look at what I see in wirehark
    but the prop got hanging there , never loading the mulitsocket and showing the ip stats, quik fix ??

    55.jpg
    369 x 296 - 22K
  • Mike GMike G Posts: 2,702
    edited 2012-10-23 09:14
    Get the latest Dhcp.spin. I added better error handling to Dhcp.DoDhcp. I tested the process by unplugging the network cable then plugging it in again while the dhcp processes looped. Give it a shot and let me know.

    Also, I have a new PASM driver that will do 20Mhz Up / 10Mhz down.
  • Igor_RastIgor_Rast Posts: 357
    edited 2012-10-23 09:32
    Mike G wrote: »
    Get the latest Dhcp.spin. I added better error handling to Dhcp.DoDhcp. I tested the process by unplugging the network cable then plugging it in again while the dhcp processes looped. Give it a shot and let me know.

    Also, I have a new PASM driver that will do 20Mhz Up / 10Mhz down.

    Mike . I have to give it to you . The code now looks ROCK SOLID ,. i have tryied it 50 + times , gets an ip set every time on both my 2 network routers ,
    It seems now that when it doesn t connect and its sending the second discoverr out , it nevver stets error attempt 1 in the serial terminal
    but gets the ip set nicely with the second try , Knowing its the second because it takes longer , and I can see it in wireshark
    anyway . that Aint bothering it from working 100 % of the time ,
    Niceeeee Work Mikeee

    any change to look at the loginn screen with the HTML5graph +dhcp demo jet
  • Igor_RastIgor_Rast Posts: 357
    edited 2012-10-23 13:33
    Mike , Question

    When I remove the Propstick from the controller , and turn it on
    nothing happens ,
    I can see only 1 of the 2 lights going on ,
    with the propstick connected i get 2 lights on , and the terminal works
    Simply removing the start statment isn,t going to work for me ?


    I can remove the propstick after the ip gets sets and it runs normaly , but if i never plug it in i hangs or somthing , cant figure out anything is happening
  • Mike GMike G Posts: 2,702
    edited 2012-10-23 14:16
    Are you asking how to identify the device on your network?
  • Igor_RastIgor_Rast Posts: 357
    edited 2012-10-23 14:27
    identify i can by it hostname , if thats what you mean .

    I mean when I disconnect the usb-propstick from the controller (propeller + wiznet+ eeprom + sensor )
    it never connects to the network ,
    offcourse I cant see the procces in the serial terminal because i disconneted the cable .
    but I can see that only 1 of the light is on , in place of 2 lights when the usb-propstick is connected and everythig working fine
  • Mike GMike G Posts: 2,702
    edited 2012-10-23 15:49
    but I can see that only 1 of the light is on , in place of 2 lights when the usb-propstick is connected and everythig working fine

    Sounds like not enough current.
  • Igor_RastIgor_Rast Posts: 357
    edited 2012-10-23 17:16
    Mike G wrote: »
    Sounds like not enough current.

    Didn,t think of that . Unfortanitly my multimeter just stoped working just now ,

    Making may day < NOT
    ill keep you posted
  • Igor_RastIgor_Rast Posts: 357
    edited 2012-10-23 20:31
    Ok Mike , So I went to Plan B

    had the parts around so I build a new power suply

    a 12vac (10va)----rectifierbride-- cap2200uf-- 6volt reg cap2200uf--3.3volt regu ----2 x cap1500uf-
    So it sould be able to supply enoug power to be sure its not the power getting drawn .
    IMG00632-20121024-0521.jpg


    But this didnt seem to solve the problem ,
    even worse , now when i remove the propstick its like i have to reprogram the prop disconnect it from usb and power a few times before it begins reacting again ,
    or stopping at all . im getting eeror number 6
    88888.jpg


    but at the wireshark side , I cant see anything happening , so there must be something else nog going right

    have you tried removing the usb-proptick with the html5graph loaded yourself and do a poweron/off reset
    1024 x 768 - 71K
    384 x 251 - 19K
  • Mike GMike G Posts: 2,702
    edited 2012-10-24 06:17
    I commented the PST debug statements, programmed the Prop, and Html5Graph ran fine. I can see the results in WireShark and the router.

    Is the Propeller continually restarting?
  • Igor_RastIgor_Rast Posts: 357
    edited 2012-10-24 07:21
    Mike G wrote: »
    I commented the PST debug statements, programmed the Prop, and Html5Graph ran fine. I can see the results in WireShark and the router.

    Is the Propeller continually restarting?

    he mike . I am trying to understand what is happening at my side ,
    i have taken a new copy of the html5 graphdemo , and put it allong with the other files in a new folder .

    loaded them to eeprom and ram , and it works again ,
    ( at the wiznet I can see 2 lights immeadiatly going on when the power goes on, )

    runs fine , van see it in wire shark too .

    But , when I remove the propsick ,all gets fucky again .
    when its powerd up only the left light light up , the right one never does.

    and in the wireshark I cant see anything happening, the terminal shows me nothing because its not connected

    when I connect the usb back without programming it again. ant then power it back up
    there is still only one light on , so the second light doesn't return to normal
    it gets stuck , when the serial is connected back I see it
    only when i reprogram the eerpom and ram it gets going again and both indicator lights go on blinking again

    just not sure what is happening here

    and no the propeller is not coniuesly restarting , its just hanging with the first step , not sending out any discovery rewuest
  • Mike GMike G Posts: 2,702
    edited 2012-10-24 07:32
    How do you know it is not resetting? I verified starting the PST without the USB causes my Prop to continually reset. As soon as I remove the PST, the system behaves as expected.

    Secondly, one only LED - the green one?. I can reproduce that effect by trying to power the WizNet from Vdd.
  • Igor_RastIgor_Rast Posts: 357
    edited 2012-10-24 08:24
    Mike G wrote: »
    How do you know it is not resetting? I verified starting the PST without the USB causes my Prop to continually reset. As soon as I remove the PST, the system behaves as expected.

    Secondly, one only LED - the green one?. I can reproduce that effect by trying to power the WizNet from Vdd.

    Mike , I agree with you , I dont know for sure if its not resetting all the time , As the serial terminal is not connected ,
    what doe you mean by remove the pst. do you remove all the statements starting wit pst. ?? or just the start.

    yes its the green light the now on ,
    stangly , when I first let the usb connected . letting it fetch its ip first . and getting set .
    than I start the webpage , everything runs fine
    if I remove the stick during this , everythings seems to keep working fine, so if the power was fed true the usb it sould turn off or reset when I remove it right ??
  • Mike GMike G Posts: 2,702
    edited 2012-10-24 08:56
    I did some very crude tests and found starting PST without the USB cable causes the Propeller Demo board to continually restart. I verified this behavior by blinking LED16 three time right before PST is initialized then blinking another LED17 three times after PST is initialized. The result is only LED16 blinks and it continues to blink three times repeatedly. That tells me the code never reaches the LED17 and the main initialization method is restarting over and over.

    I grabbed another Prop Demo board with no external circuit and it behaved the same. The next step, is to create simple app with PST only and see if the issue is reproducible. If it is not then there is some kind of conflict Hardware or Firmware.

    I'll take a closer look when I get home form work - time permitting.
  • Igor_RastIgor_Rast Posts: 357
    edited 2012-10-24 09:15
    he Mike , Glad to hear that you are able to reproduce the same conflict there , with multiple props .
    now I know that im not crazy :p

    anyway

    what do you mean by , simply app with PST..

    minimize the PST.spin file to only the commands beeing used . or create another object that toggles only the problem , ( not sure what that is now )
    Stil not getting why its beeing reset then. Ill keep an close eye on the thread and your work , Thanks


    I was thinking mike , its the same PST.spin file that was causing my previous problems when the simpleide just stoped responding ,
    and I ended up formatting my hole pc to be sure every other setup issue is ruled out . it turned out to be that pst.spin was missing in the folder . and only pst.dat was there.
    havent got a clue where the original pst.spin file went in the folder , so i just put a new copy in it
    when I putted it back the simpleide resumed the normal way of operation, and all seemed solved till today that is doing random tings
  • Mike GMike G Posts: 2,702
    edited 2012-10-24 13:43
    what do you mean by , simply app with PST..
    Simple PST app
    I was thinking mike , its the same PST.spin file that was causing my previous problems when the simpleide just stoped responding ,
    and I ended up formatting my hole pc to be sure every other setup issue is ruled out . it turned out to be that pst.spin was missing in the folder . and only pst.dat was there.
    havent got a clue where the original pst.spin file went in the folder , so i just put a new copy in it
    when I putted it back the simpleide resumed the normal way of operation, and all seemed solved till today that is doing random tings
    I have no idea. Need to test and figure out the problem.
  • Mike GMike G Posts: 2,702
    edited 2012-10-24 19:01
    I'm stymied on this one and a bit surprised that I have not run into this before. I'm using a Propeller Demo Board with nothing attached to the IO pins. If I load the code below into EEPROM and leave the USB cable connected the main method runs to completion. If I remove the USB cable and press reset, only Toggle(23, 10) is invoked; over and over. That tells me the Prop is resetting. If I comment pst.Start(115_200), the Main method will run to completion. I'm not sure what to think at this point. It feels like a hardware problem. FTDI??? FDS behaves similarly.
    CON
      _clkmode = xtal1 + pll16x     
      _xinfreq = 5_000_000
    
    VAR
    
    DAT
    
    OBJ
      pst           : "Parallax Serial Terminal"
      
    PUB Main
    
      Toggle(23, 10)
      
      pst.Start(115_200)
      
      Toggle(16, 10)
      
      pst.str(string("Initialize W5200", 13))
      
      Toggle(20, 6)
      
    
    PUB Toggle(pin, count)
      repeat count
        dira[pin]~~
          !outa[pin]
          waitcnt(80_000_000/8 + cnt)  
    

    My suggestion is to remove PST for your stand alone application. We might add a pause in a few places to let the objects start up.
  • Igor_RastIgor_Rast Posts: 357
    edited 2012-10-25 08:18
    Hi Mike ,
    I have been trying different thing now to get it workin.

    i figured out that if i do a hard reset on the nreset pin before the rest of the program runs , the wiznet reacts good every time
    and both lights are one from the begining . so that seem to be solved resettting the wiznet
    dira[8]~~  
      outa[8]~~
      waitcnt(clkfreq/2 +cnt)
      outa[8]~
      waitcnt(clkfreq/2 +cnt)
      outa[8]~~
    
    pin 8 is connected to the nReset


    i Will go with your approcht to get the wiznet on without the pst .
    so I went to comment out all the pst. commands in the object,

    I realized that if I only take away the start statment , the program gets stuck .
    never getting the ip set ando.
    So I went on removing the pst , and adding a led blink for me to know till were the code was working right .
    looking ate wireshark . I can see that its getting the ip set every time nicely

    But the Multisockt doesnt run like it sould , if I leave the pst statements in in
    Removing them all , doenst work either or I am doing something wrong or overlooking something

    with the blinky method I can to see that at the multisocket server it nerver passed the socket conneted command
    PUB MultiSocketServer | bytesToRead, i, page, j, x , bytesSent, ptr
        Toggle(9, 4)                                                  this one toggels right 
      bytesToRead := bytesSent := i := j := x := 0
      repeat
        {pst.str(string("TCP Service", CR))}
        CloseWait
        Toggle(10, 4)                                                  this one togg
        {repeat j from 0 to SOCKETS-1
          pst.str(string("Socket "))
          pst.dec(j)
          pst.str(string(" = "))
          pst.hex(wiz.GetSocketStatus(j), 2)
          pst.char(13)}
         
        repeat until sock[i].Connected
          i := ++i // SOCKETS        
    

    if I put the toggle like below , I can see that I keeps toggeling indefinitly
    repeat until sock[i].Connected
          i := ++i // SOCKETS        
            Toggle(10, 4)
    

    and if i remove it complety , it never passes that state .

    hope you can help me out

    with the pst commented out complety it looks like this
    PUB Main | i, page, dnsServer
      dira[9..15]~~ 
     
       
      dira[8]~~  
      outa[8]~~
      waitcnt(clkfreq/2 +cnt)
      outa[8]~
      waitcnt(clkfreq/2 +cnt)
      outa[8]~~  
    
      i := 0
      setpoint :=  i2cObject.ReadLong(i2cSCL, EEPROMAddr, $7981) 
      offset :=  i2cObject.ReadLong(i2cSCL, EEPROMAddr, $7977)    
    
       
      cognew(Tempcontrol,@stack1)
    
     { pst.Start(115_200)}
      pause(500)
    
     { pst.str(string("Initialize W5200", CR))}
      wiz.start(6, 5, 4, 7)
      wiz.SetMac($00, $08, $DC, $16, $F8, $01)
    
     { pst.str(string("Getting network paramters", CR))}
      dhcp.Init(@buff, 7)
     { pst.str(string("Requesting IP....."))}
    
      repeat until dhcp.DoDhcp
        if(++i > DHCP_ATTEMPTS)
          quit
    
      if(dhcp.GetErrorCode > 0  OR i > DHCP_ATTEMPTS)
      {  pst.char(CR) }
      {  pst.str(string(CR, "DHCP Attempts: "))}
      {  pst.dec(i)}
      {  pst.str(string(CR, "Error Code: "))}
      {  pst.dec(dhcp.GetErrorCode)}
      {  pst.char(CR)}
      {  pst.str(dhcp.GetErrorMessage)}
      {  pst.char(CR)}
        return
      else
        PrintIp(dhcp.GetIp)
    
      {pst.str(string("DNS..............."))}
      dnsServer := wiz.GetDns
      PrintIp(wiz.GetDns)
    
      {pst.str(string("DHCP Server......."))}
      printIp(wiz.GetDhcpServerIp)
    
      {pst.str(string("Router IP........."))}
      printIp(wiz.GetRouter)
      {pst.char(CR)}
    
    
    
      repeat
        {pst.str(string("Initialize Sockets",CR))}
        repeat i from 0 to SOCKETS-1
          sock[i].Init(i, TCP, 80)
               
        OpenListeners
        StartListners
            
        {pst.str(string("Start Socket server",CR))}
        \MultiSocketServer
        {pst.str(string("I blew up!"))}
        pause(5000)
    
    PUB Toggle(pin, count)
      repeat count
        dira[pin]~~
          !outa[pin]
          waitcnt(clkfreq + cnt)
      
    PUB OpenListeners | i
      {pst.str(string("Open",CR))}
      repeat i from 0 to SOCKETS-1  
        sock[i].Open
          
    PUB StartListners | i
      repeat i from 0 to SOCKETS-1
       { if(sock[i].Listen)
          pst.str(string("Listen "))
        else
          pst.str(string("Listener failed ",CR))
        pst.dec(i)
        pst.char(CR)}
    
    PUB CloseWait | i
      repeat i from 0 to SOCKETS-1
       
        if(sock[i].IsCloseWait) 
          sock[i].Disconnect
          sock[i].Close
          
        if(sock[i].IsClosed)  
          sock[i].Open
          sock[i].Listen
    
    PUB MultiSocketServer | bytesToRead, i, page, j, x , bytesSent, ptr
        Toggle(9, 4)
      bytesToRead := bytesSent := i := j := x := 0
      repeat
        {pst.str(string("TCP Service", CR))}
        CloseWait
        Toggle(10, 4)
        {repeat j from 0 to SOCKETS-1
          pst.str(string("Socket "))
          pst.dec(j)
          pst.str(string(" = "))
          pst.hex(wiz.GetSocketStatus(j), 2)
          pst.char(13)}
         
        repeat until sock[i].Connected
          i := ++i // SOCKETS
            
        
        {pst.str(string("Connected Socket "))
        pst.dec(i)
        pst.char(CR)}
        
        'Data in the buffer?
        repeat until bytesToRead := sock[i].Available
    
        'Check for a timeout
        if(bytesToRead < 0)
          {pst.str(string("Timeout",CR))}
          sock[i].Disconnect
          sock[i].Open
          sock[i].Listen
          bytesToRead~
          next
    
        Toggle(13, 4)
        {pst.str(string("Copy Rx Data",CR))}
      
        'Get the Rx buffer  
        sock[i].Receive(@buff, bytesToRead)
    
        {{ Process the Rx data}}
       { pst.char(CR)
        pst.str(string("Request:",CR))
        pst.str(@buff)
    
        pst.str(string("Send Response",CR))}
        page :=  ParseResource(@buff)
    
        Toggle(13, 4)    
        {pst.str(page)
        pst.char(CR)
        pst.str(string("Byte to send "))
        pst.dec(strsize(page))
        pst.char(CR)}
    
        bytesSent := 0
        ptr := page
        repeat until bytesSent == strsize(page)
          bytesSent += sock[i].Send(ptr, strsize(ptr))
          ptr := page + bytesSent
    
     
        Toggle(14, 4) 
        {pst.str(string("Bytes Sent "))
        pst.dec(bytesSent)
        pst.char(CR)
    
        pst.str(string("Disconnect socket "))
        pst.dec(i)
        pst.char(CR)}
    
        if(sock[i].Disconnect)
          sese       {pst.str(string("Disconnected", CR))}
        else
          {pst.str(string("Force Close", CR))}
        sock[i].Open
        sock[i].Listen
        sock[i].SetSocketIR($FF)
        
        i := ++i // SOCKETS
        bytesToRead~
        Toggle(15, 4)
        
    PUB sese
     waitcnt(clkfreq/10000 + cnt)    
     return
    PUB ParseResource(header) | ptr, value, i, done, j
      ptr := header
      i := 0
      done := false
    
      repeat until IsEndOfLine(byte[ptr])
        if(IsToken(byte[ptr]))
          byte[ptr] := 0
          resPtr[i++] := ++ptr
        else
          ++ptr
    
        if(ptr - header > 500)
          pst.str(string(CR, "+++++++++++++++[ERROR]++++++++++++++",CR))
          return @index
    
      resPtr[0] := header
      repeat j from 0 to i-1
        pst.str(string("ID"))
        pst.dec(j)
        pst.char($20)
        pst.str(resPtr[j])
        pst.char(CR)
    
      repeat j from 0 to i-1
        if(strcomp(resPtr[j], string("HTTP")))
          return @index
    
          
        if(strcomp(resPtr[j], string("xmltemp")))
          value := GetTemp
          Settemp(tempc3,@temperature)
          Setlv(lv3,@lvlv)
          Settemp(tempmax,@t_max)
          Settemp(tempmin,@t_min)
          Setlv(lvmax,@lv_max)
          Setlv(lvmin,@lv_min)
          Setlv(setpoint,@Set_p)
          Setlv(offset,@off_s)
          return @xml
    
        if(strcomp(resPtr[j], string("setpointplus")))
            setpointplus
            return 
        if(strcomp(resPtr[j], string("setpointmin")))
           setpointmin
            return  
        if(strcomp(resPtr[j], string("offsetplus")))
            offsetplus
             return 
        if(strcomp(resPtr[j], string("offsetmin")))
           offsetmin
            return  
                
    PUB setpointplus     
     if setpoint < 99
       Setpoint:= Setpoint + 1
     return
    
     
    PUB setpointmin     
    
     if setpoint > 1
       Setpoint:= Setpoint - 1
     return
    
    PUB offsetplus     
     if offset < 9
       offset:= offset + 1
     return
    
    PUB offsetmin     
     if offset > 1
       offset:= offset - 1
     return  
    PUB IsToken(value)
      return lookdown(value: "/", "?", "=", " ")
    
    PUB IsEndOfLine(value)
      return lookdown(value: CR, LF)
    
    PUB GetTemp
      seed := CNT 
      ?seed
      return seed & $0F + 1
      
    PUB Settemp(value,plaats) | t1
      t1 := value
      t1 := t1/100
      value -= t1 * 100
      if(t1 > 0 and t1 < 9)
        byte[plaats][0] := t1 + $30
      else
        ResetTemp
        return 
    
      t1 := value
      t1 := t1/10
      value -= t1 * 10
      if(t1 > 0 and t1 < 9) 
        byte[plaats][1] := t1 + $30
      else
        ResetTemp
        return
        
      t1 := value
      if(t1 > 0 and t1 < 9)  
        byte[plaats][3] := t1 + $30
      else
        ResetTemp
        return
        
    PUB SetLV(value,plaats) | t1                                              
      t1 := value
     
    
      t1 := value
      t1 := t1/10
      value -= t1 * 10
      'if(t1 > 0 and t1 < 9) 
        byte[plaats][0] := t1 + $30
      'else
        'ResetTemp
        'return
        
      t1 := value
      'if(t1 > 0 and t1 < 9)  
        byte[plaats][1] := t1 + $30
      'else
       ' ResetTemp
        'return
      
    
    PUB ResetTemp
      byte[12] := $30
      byte[13] := $30
      byte[14] := $30  
    
    
    
    
         
    PUB PrintIp(addr) | i
      repeat i from 0 to 3
        pst.dec(byte[addr][i])
        if(i < 3)
          pst.char($2E)
        else
          pst.char($0D)
      
    PRI pause(Duration)  
      waitcnt(((clkfreq / 1_000 * Duration - 3932) #> 381) + cnt)
      return
    

    but not working .
    I can see it connecting via wireshark and getting all setup correctly , but I cant connect to it
  • Mike GMike G Posts: 2,702
    edited 2012-10-25 09:33
    sock.Listen is commented in the StartListners method. No socket listener on the line.

    PUB StartListners | i
      repeat i from 0 to SOCKETS-1
    	sock[i].Listen
    
Sign In or Register to comment.