Shop OBEX P1 Docs P2 Docs Learn Events
Another dumb question - Parallax Serial Terminal — Parallax Forums

Another dumb question - Parallax Serial Terminal

NurbitNurbit Posts: 53
edited 2012-04-24 15:14 in Propeller 1
Hi again everyone.

I'm trying to have a play with the PST object but am doing something very wrong.

Here is my code


CON

_clkmode = xtal1 + pll16x ' Crystal and PLL settings.
_xinfreq = 5_000_000 ' 5 MHz crystal (5 MHz x 16 = 80 MHz).

OBJ

pst : "Parallax Serial Terminal" ' Serial communication object

VAR

long name
PUB go

pst.Start(115200) ' Start the Parallax Serial Terminal cog

''
Replace the code below with your test code

pst.Str(String("My Kakky Hello Code"))
pst.Chars(pst#NL, 2)
pst.Str(String("Please enter your name:- "))
pst.StrIn(name)
pst.Str(String(pst#NL,"Hello "))
pst.Str(String(name))
pst.Str(String(", Pleased to meet you."))

Can anyone tell me why I'm so stupid and what I'm doing wrong?
Is there a site anywhere with a tutorial on the PST object? I'm trying to decipher it's functions from the object itself but obviously not doing a good job :(

Thanks in advance

Comments

  • SRLMSRLM Posts: 5,045
    edited 2012-04-24 14:35
    The compiler directive "String" creates a string in memory. I think you second to last line should be:
    pst.Str(name)
    

    Also, in the future please make sure to use the [ code ] tags instead of just pasting the code into your post.
  • NurbitNurbit Posts: 53
    edited 2012-04-24 14:45
    Thanks SRLM, I'll give that a try.
    I'll make sure I add the tags in future
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-04-24 14:49
    You need enough room to hold the characters. Bytes are used to hold character strings.

    Use this:
    VAR
    
      byte name[32]
    

    The you also need to use the address of the string.
    pst.Str(String("Please enter your name:- ")) 
      pst.StrIn([B]@[/B]name) 
      pst.Str(String(pst#NL,"Hello ")) 
      pst.str([B]@[/B]name)
    
  • NurbitNurbit Posts: 53
    edited 2012-04-24 15:14
    Thanks Duane
    I've put the prop away for tonight but I'll add your changes in the morning

    That's exactly the sort of info someone like me needs :)
Sign In or Register to comment.