Shop OBEX P1 Docs P2 Docs Learn Events
Help with serial test program — Parallax Forums

Help with serial test program

MacGeek117MacGeek117 Posts: 747
edited 2007-04-16 18:23 in Propeller 1
I've posted the program I'm having a problem with.
Every time I compile it, the Tool says "Blocknest stack overflow." I don't know what that means. Could I have some help?
RoboGeek

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"I reject your reality and subsitute my own!"

Adam Savage, Mythbusters
www.parallax.com
www.goldmine-elec.com
www.expresspcb.com
www.startrek.com

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-04-13 17:08
    It's not the most meaningful error message, but it probably indicates that your program's statement nesting is too deep for the compiler to handle. In other words, you have too many IF/CASE statements within each other. You have several options. You can take some of the innermost case statements and move them to another method (PRI). Alternatively, you could reverse some of the logic or do things like the password checking in a loop like:
    PRI checkPassword(value)
       term.str(string("Enter passcode: "))
       repeat while byte[noparse][[/noparse]value]
          if term.getc == byte[noparse][[/noparse]value++]
             term.out("*")
          else
             return false
       pause(1000)
       term.str(string("Passcode correct."))
       return true
    


    and you'd call this with 'if checkPassword(string("bugg"))'
  • MacGeek117MacGeek117 Posts: 747
    edited 2007-04-13 19:47
    Thank you! It works perfectly!
    Robogeek

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "I reject your reality and subsitute my own!"

    Adam Savage, Mythbusters
    www.parallax.com
    www.goldmine-elec.com
    www.expresspcb.com
    www.startrek.com
    ·
  • MacGeek117MacGeek117 Posts: 747
    edited 2007-04-13 20:44
    How would I be able to read a message sent from the computer? ie., more than one byte.
    RoboGeek

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "I reject your reality and subsitute my own!"

    Adam Savage, Mythbusters
    www.parallax.com
    www.goldmine-elec.com
    www.expresspcb.com
    www.startrek.com
    ·
  • Paul BakerPaul Baker Posts: 6,351
    edited 2007-04-13 20:54
    http://forums.parallax.com/showthread.php?p=624624

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
  • Mike GreenMike Green Posts: 23,101
    edited 2007-04-13 21:03
    RoboGeek,
    Typically, a program will save input characters in a buffer up to some delimiter, often the Return key, then the program can analyze the contents.
    PRI readLine(bufPtr, bufSize) | c
    ' bufPtr is the address of a buffer (byte array)
    ' bufSize is the length of the buffer minus one
        repeat
            c := term.getc
            if c == 13 or bufSize == 0
                byte[noparse][[/noparse]bufPtr++] := 0
                return
            byte[noparse][[/noparse]bufPtr++] := c
            term.out(c)
            bufSize--
    
    
  • MacGeek117MacGeek117 Posts: 747
    edited 2007-04-14 18:54
    Sorry, asked the wrong question. How would I program my Prop to compare the string it receives to those stored in the DAT section?
    RoboGeek

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "I reject your reality and subsitute my own!"

    Adam Savage, Mythbusters
    www.parallax.com
    www.goldmine-elec.com
    www.expresspcb.com
    www.startrek.com
    ·
  • Mike GreenMike Green Posts: 23,101
    edited 2007-04-14 20:07
    Look at the Spin command STRCOMP. This compares two zero-terminated strings and has the value TRUE of both are identical, FALSE otherwise.
    In your DAT section, just be sure to follow the string itself with a zero byte and be sure to use an input routine that does the same.
  • MacGeek117MacGeek117 Posts: 747
    edited 2007-04-15 01:01
    I'm still having problems with the program. If I have the answer in the dat section, HyperTerminal displays some garbage after the answer. If I
    have the answer like answer 3, it displays this: Program space not available at this time.
    To view program space, open current program and press F8.10


    I don't know what is going on.
    RoboGeek


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "I reject your reality and subsitute my own!"

    Adam Savage, Mythbusters
    www.parallax.com
    www.goldmine-elec.com
    www.expresspcb.com
    www.startrek.com
  • Mike GreenMike Green Posts: 23,101
    edited 2007-04-15 03:31
    The answers have to be zero-terminated too. For example:

    answer1 byte "I am fine.",0
    answer2 byte "Version 0.9",0
    answer3 byte 0
  • MacGeek117MacGeek117 Posts: 747
    edited 2007-04-15 03:56
    It still displays 10 after the answer.
    RoboGeek

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "I reject your reality and subsitute my own!"

    Adam Savage, Mythbusters
    www.parallax.com
    www.goldmine-elec.com
    www.expresspcb.com
    www.startrek.com
    ·
  • Mike GreenMike Green Posts: 23,101
    edited 2007-04-15 04:55
    I don't know what you mean by that (that it displays "10").
    That tells me nothing about what sequence of inputs you presented to the program and what output it provided.
    I can't tell what parts of the program executed and in what order without that so it's hard to tell what failed.
  • MacGeek117MacGeek117 Posts: 747
    edited 2007-04-16 01:58
    I'm sorry about the confusion. I need to put constants in place of the numbers.· What I want to have happen is I will press the 'Home' button on the keyboard and then I can ask a question, then it answers it. What happens now is it answers the question, but right after the answer there is a 10. ie. I ask it how are you?, it answers I am fine.10 There is not supposed to be a 10.

    Hope this clarifies things.

    RoboGeek


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "I reject your reality and subsitute my own!"

    Adam Savage, Mythbusters
    www.parallax.com
    www.goldmine-elec.com
    www.expresspcb.com
    www.startrek.com
    ·
  • Mike GreenMike Green Posts: 23,101
    edited 2007-04-16 02:11
    The 10 is the decimal value of Line Feed. In your case statement, you have an "other" clause which displays the decimal value of the received character. Your terminal program is (appropriately) inserting a line feed after the return (13) character and that's what's getting displayed.
  • MacGeek117MacGeek117 Posts: 747
    edited 2007-04-16 18:07
    Other than taking out that section of code, how do I stop it?
    RoboGeek

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "I reject your reality and subsitute my own!"

    Adam Savage, Mythbusters
    www.parallax.com
    www.goldmine-elec.com
    www.expresspcb.com
    www.startrek.com


    Post Edited (RoboGeek) : 4/16/2007 6:14:23 PM GMT
  • Mike GreenMike Green Posts: 23,101
    edited 2007-04-16 18:20
    I'd mostly suggest changing the settings of your terminal program so it doesn't automatically send a linefeed (10) after a return (13).

    If you can't do that, add a choice to the case statement "10:" and either follow that with "term.out(10)" or nothing depending on which you want.
  • MacGeek117MacGeek117 Posts: 747
    edited 2007-04-16 18:23
    Thank you! It works. Now on to have fun with it. I love the Forums!
    RoboGeek

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "I reject your reality and subsitute my own!"

    Adam Savage, Mythbusters
    www.parallax.com
    www.goldmine-elec.com
    www.expresspcb.com
    www.startrek.com
    ·
Sign In or Register to comment.