Shop OBEX P1 Docs P2 Docs Learn Events
PINK SERIN weird problem. — Parallax Forums

PINK SERIN weird problem.

Roger PiersonRoger Pierson Posts: 62
edited 2006-11-07 22:14 in BASIC Stamp
Can anybody tell me why this works perfectly fine:

    SEROUT Pink_Out,Pink_Baud,[noparse][[/noparse]"!NB0RBM"]
    SERIN  Pink_IN,Pink_Baud,[noparse][[/noparse]DEC2 NBVAR,STR NBVAR2\7\CLS]




But this CAUSES a timeout:

    SEROUT Pink_Out,Pink_Baud,[noparse][[/noparse]"!NB0RBM"]
    SERIN  Pink_IN, Pink_Baud , 5, Bailout, [noparse][[/noparse]DEC2 NBVAR,STR NBVAR2\7\CLS]




Nothing changes except I try to add some error trapping by including a time to wait for data and a label to handle that event.

Every single time with the error trapping in I get a time out, and only when talking to the PINK. Without the error trapping the program completes just fine, unless the data was invalid (which is why I need to handle errors).

It doesn't matter what time I put in either, a wait time of 5000 still times out.

I am very, very confused.

Other than this little issue, the PINK modules have been great! I've got three Stamps talking back and forth via UDP and it's very cool.

Thanks in advance,

Roger

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Roger Pierson
Senior Electronics Technicain
DTI Assoicates

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-11-04 21:13
    Roger,
    ·
    ·· My guess is your Timeout Value is too small…That’s only 5 mS to respond.· It is probably timing out before the module can respond with the data.· Try a larger value.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • Roger PiersonRoger Pierson Posts: 62
    edited 2006-11-04 21:26
    Chris,

    It doesn't matter what value I put in, it always times out. I once put 4000 in just to see if it would work and it still times out.

    Thanks,

    Roger

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Roger Pierson
    Senior Electronics Technicain
    DTI Assoicates
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-11-05 01:21
    Roger,
    ·
    ·· I will see if I can test this before Monday…If not, I will test it Monday and see what I get.· In your timeout routine, are you debugging the values to see if you still got what you expected, even though the routine timed-out?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • Roger PiersonRoger Pierson Posts: 62
    edited 2006-11-06 14:40
    No, I didn't think of that. I assumed since it timed out I was getting nothing. I'll check that out.

    I would be interested to know what you come up with if you test this.

    Thanks,

    Roger

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Roger Pierson
    Senior Electronics Technicain
    DTI Assoicates
  • Roger PiersonRoger Pierson Posts: 62
    edited 2006-11-06 15:52
    OK, the data isn't being recieved if the SERIN times out. It is also interesting to note that when reading the stauts byte, there are no problems, SERIN works normally. Reading any other variable causes the problem.

    If anyone cares to test this out, here is the test code I am using. It sets the test up by writing data to the UDP message content variable and to web variable 21. Then it reads each of these twice, once using error trapping and once without. Then it reads the status byte, just to prove that it works.

    Also, I'll attach the file.

    ' PINK_Test2.bs2
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    
    NBSTATUS    VAR Byte
    NBUDP1      VAR Byte
    NBUDP2      VAR Byte
    
    NBVAR       VAR Word
    NBVAR2      VAR Byte(8)
    NetStat     VAR NBSTATUS.BIT0
    NewPost     VAR NBSTATUS.BIT1
    EmailReady  VAR NBSTATUS.BIT2
    EmailError  VAR NBSTATUS.BIT3
    NewUDP      VAR NBSTATUS.BIT5
    Pink_IN         PIN 11                         ' Pink RS232 Rcv
    Pink_Out        PIN 12                         ' Pink RS232 Xmit
    Pink_Baud CON   396
    DEBUG CLS
    
    '***** SET UDP MESSAGE AND VARIABLE 21 TO SET UP THIS TEST. **********
    '******UDP is set to 2134.5, VAR21 is set to 2 ***********************
    
    DEBUG "***[noparse][[/noparse] Setting Up UDP & VAR 21 For Test To Follow ]***",CR
    
    SEROUT Pink_Out,Pink_Baud,[noparse][[/noparse]"!NB0WBM:2134.5",CLS]
    SEROUT Pink_Out,Pink_Baud,[noparse][[/noparse]"!NB0W21:2",CLS]
    
    DEBUG CR,"***[noparse][[/noparse] Test Prep Complete! Begin Tests ]***",CR,CR
    
    
    
    
    '********************* Get UDP With Error Trap ***********************
    DEBUG "***[noparse][[/noparse] Getting UDP Message - with Error Trap ]***",CR,CR
    
    SEROUT Pink_Out,396,[noparse][[/noparse]"!NB0RBM"]
    SERIN  Pink_IN,396,4000,skipUDP,[noparse][[/noparse]DEC2 NBUDP1,STR NBUDP2\7\CLS]
    
    Con1:
    DEBUG "First Two Characters: ",DEC2 NBUDP1,CR
    DEBUG "The Rest: ",STR NBUDP2,CR
    
    PAUSE 50
    
    
    '********************* Get UDP With NO Error Trap **********************
    DEBUG CR,CR,"***[noparse][[/noparse] Getting UDP Message - NO Error Trap ]***",CR,CR
    
    SEROUT Pink_Out,396,[noparse][[/noparse]"!NB0RBM"]
    SERIN  Pink_IN,396,[noparse][[/noparse]DEC2 NBUDP1,STR NBUDP2\7\CLS]
    
    DEBUG "First Two Characters: ",DEC2 NBUDP1,CR
    DEBUG "The Rest: ",STR NBUDP2,CR
    
    PAUSE 50
    
    
    '******************Read Variable With Error Trap ********************
    DEBUG CR,"***[noparse][[/noparse] Getting PINK Variable 21 - With Error Trap ]***",CR,CR
    
      SEROUT Pink_Out,Pink_Baud,[noparse][[/noparse]"!NB0R21"]
      SERIN  Pink_IN,Pink_Baud, 4000,SkipVar,[noparse][[/noparse]DEC1 NBVAR]
    
    Con3:
      DEBUG "Variable Data: ", DEC1 NBVAR,CR
    
    PAUSE 50
    
    
    '*****************Read Variable With NO Error Trap ******************
    DEBUG CR,"***[noparse][[/noparse] Getting PINK Variable 21 - With NO Error Trap ]***",CR,CR
    
      SEROUT Pink_Out,Pink_Baud,[noparse][[/noparse]"!NB0R21"]
      SERIN  Pink_IN,Pink_Baud,[noparse][[/noparse]DEC1 NBVAR]
    
      DEBUG "Variable Data: ", DEC1 NBVAR,CR
    
    
    
      '************** Status With Error Trap ALWAYS works ********************
    DEBUG CR,"***[noparse][[/noparse] Getting PINK Status - With Error Trap ]***",CR
    DEBUG "***[noparse][[/noparse] This always works. ]**********************",CR,CR
    
      SEROUT Pink_Out,Pink_Baud,[noparse][[/noparse]"!NB0ST"]                     'Poll for Status
      SERIN  Pink_IN,Pink_Baud,4000,skipStatus,[noparse][[/noparse]NBSTATUS]
    
    Con2:
      DEBUG "Status Byte: ",BIN NBStatus,CR,CR
      DEBUG "Status Breakdown:",CR,? NetStat,? NewPost,? EmailReady,? EmailError,? NewUDP
    
    
    
    END
    
    skipUDP:
    DEBUG "UDP Timed out!",CR
    GOTO con1
    
    skipStatus:
    DEBUG "Status Times out!",CR
    GOTO con2
    
    SkipVar:
    DEBUG "Variable 21 timed out!",CR
    GOTO con3
    
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Roger Pierson
    Senior Electronics Technicain
    DTI Assoicates
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-11-06 16:13
    Roger,
    ·
    ·· What could happen is that you could be getting some of the data in your list…If that was the case it could still timeout, but some of the variables would contain the expected data.· Let us know.


    EDIT: Looks like while revising my message you already tried this.· I will try your code myself and post my results back later today.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support


    Post Edited (Chris Savage (Parallax)) : 11/6/2006 4:17:07 PM GMT
  • Roger PiersonRoger Pierson Posts: 62
    edited 2006-11-06 16:24
    Thanks Chris.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Roger Pierson
    Senior Electronics Technicain
    DTI Assoicates
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-11-07 00:48
    Roger,
    ·
    ·· I didn’t have time to analyze your code today but I did change the pins and baud rate to match mine, and the thing I noticed is that yes the Timeout test fails, but then it hangs at the other.· Which means for me it’s not working either way.· I think the better way to test this will be for me to create an example tomorrow and go from there.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • Roger PiersonRoger Pierson Posts: 62
    edited 2006-11-07 15:02
    The first part of the code writes the required data to the appropriate variables, but in case that is not happening for you then here is what the test code I posted is looking for:

    The first SERIN is looking for a UDP message that begins with two digits followed by any type of value (7 bytes long). The second SERIN is looking for a one digit value in web variable 21. The third SERIN is the status byte, which I have no trouble with.

    I really appreciate your help with this!

    Thanks,

    Roger

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Roger Pierson
    Senior Electronics Technicain
    DTI Assoicates
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-11-07 15:32
    Roger,
    ·
    ·· When in doubt, start with something simpler.· In my case I think I will use a simple variable read and add the timeout code during a subsequent read in a demo similar to yours.· I will attach it and you can try that one.· I should have something posted soon.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-11-07 22:14
    Roger,
    ·
    ·· As promised I got a chance to try using the timeout feature of SERIN with the PINK Module.· I always start with a simple example, especially when dealing with someone else’s code.· This way I know what results to expect.· See the attached files.· The first gets a variable from the PINK Module and displays it on the DEBUG screen.· This is right from our documentation.· The only thing different is that I am using the default baud rate of 9600.· The second example adds a timeout to the SERIN command.· Regardless of what values I specify there is no timeout occurring.· Because of this I would recommend breaking down the order of events and the expected data and try to figure out what is happening based on that.· The fact that I couldn’t get either of your examples to work means the expected data is dependant on some other event I cannot easily duplicate.· What ever that is may be the source of your problems.· I hope this helps.· Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
Sign In or Register to comment.