Shop OBEX P1 Docs P2 Docs Learn Events
how to get spin to check string input from serial terminal — Parallax Forums

how to get spin to check string input from serial terminal

Bulslayer85Bulslayer85 Posts: 34
edited 2012-04-23 10:43 in Propeller 1
how do i get spin code to check text i input in the serial terminal and do something or rather post a response based on what text i input.

Example: i type "how are you?" and robot responds with "I am fine" but only if i type that exact phrase.

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2012-04-23 09:34
    There are some objects in the Propeller Object Exchange that extend FullDuplexSerial or FullDuplexSerial4Port to include some input routines. One of them (StrIn) copies serial characters into an internal buffer until a delimiter (usually Return) is processed, then it returns the address of this internal buffer. To compare to an exact phrase, you'd do something like
    ' The input routine has returned the address in Addr.
    if strcomp(Addr,string("how are you?"))   ' Check for exact equality
       ' Do something if there's a match
    
  • Bulslayer85Bulslayer85 Posts: 34
    edited 2012-04-23 10:19
    ok, i found that the parallax serial terminal object has a StrIn function with (stringptr) but when i try to call that function in my code it compiles and says that it expects an expression term in the (). totally confused cause the actual PST code file compiles fine i just cant seem to refer to that function in a different code file.
  • Bulslayer85Bulslayer85 Posts: 34
    edited 2012-04-23 10:43
    Robotics class teacher helped me out so nvm, turns out i was supposed to assign a var to where stringptr was. so oops oh well. all works fine now
Sign In or Register to comment.