Shop OBEX P1 Docs P2 Docs Learn Events
ethernet telnet problems (blocking calls, buffers) — Parallax Forums

ethernet telnet problems (blocking calls, buffers)

SpinHeadSpinHead Posts: 28
edited 2008-06-02 00:07 in Propeller 1
Ok, I have played around with spin for a while and I am now testing ethernet, with the fullduplexserial I could read the whole buffer to get what was sent and checking to see if there was data didnt block anything, it seems it is not the case with the ethernet driver?

let me show you what I have that is the problem


I defined it as ser at first, changed to make it more clear as to what it is





  Num           : "Simple_Numbers"
  eth           : "api_telnet_serial"
  time          : "Timing"
  serial        : "FullDuplex"






  serial.start(serRXPin,serTXPin,serBaud)
  cog:=eth.start(i_cs,i_sck,i_si,i_so,i_int,xtalout,@eth_mac,@ip_addr)
  eth.listen(port)
  time.Pause1ms(1000)

repeat 'main
 if(StrSize(@myString)<7)
   readEthernet
   SetString( @myString, @dstString) 
 //do other stuff here while we wait for more data, 
 //readEthernet should return quickly if there is or is not data  <-- this is the problem, readethernet hangs until
                                                                                              // it actually gets data, instead of seeing of any is ready
 else 
  //we have data, verify it is valid and do stuff, 
 // then reset mystring & dststring to 0 or just reset to 0 if data is not valid



PUB readEthernet
[color=#990000] 
  if eth.rxcheck
        ch:=eth.rx ' get char //gets stuck here I think
[/color]
        if(ch>38 AND ch<127)
          AppendChar( @dstString, ch )
          eth.str(string("NEW CHAR:[noparse][[/noparse]"))//diagnostic stuff temporarily
          eth.tx(  ch)                          //
          eth.str(string("] - "))            //
          eth.str(@dstString)             // 
          eth.str(string(13,10))        //
        else
          case ch
            33 :
             SetString( @dstString, String("!"))
             eth.str(@dstString)//diagnostic stuff temporarily
  else
    eth.str(string("NO DATA,",13,10))//diagnostic stuff temporarily







I NEVER get a no data string and it pauses execution once I call that function and does not return until it sees data sent.... What am I doing wrong?
I want it to see if data is ready if so append it to my variable, if not, come back quickly so I can do other things

Once that is working, the method I am using misses data, if I use terminal and send a complete string of 1234567890 my buffer now looks like this 124680

Hope I made myself and my code more clear
Mike

Post Edited (SpinHead) : 6/1/2008 8:08:06 PM GMT

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-06-01 19:33
    I don't understand what you're doing. You need to explain your situation more clearly and more thoroughly. You're talking about ethernet, yet what you show is part of a program that seems to use FullDuplexSerial. FullDuplexSerial is indeed buffered (normally with a 16 byte buffer in each direction) and can handle Bauds up to roughly 230KBaud.
  • SpinHeadSpinHead Posts: 28
    edited 2008-06-01 20:10
    here is the telnet_api file I am using
  • Harrison.Harrison. Posts: 484
    edited 2008-06-02 00:07
    You need to call rxcheck instead of rx.

    Change the first few lines of your readEthernet method to:
    PUB readEthernet
      if (ch := \eth.rxcheck) > -1
        ...rest of your code goes here...
    
    



    Remember that rxcheck will return a character if one exists in the buffer. This means you need to actually store this returned value somewhere, otherwise you loose that character.

    I recommend putting a \ in front of all your tcp stack method calls so you can catch any aborts. This is for future functionality (the current beta release doesn't use aborts yet). The next release will have aborts, so 'catching' them now will give you the easiest upgrade path.

    Harrison
Sign In or Register to comment.