Shop OBEX P1 Docs P2 Docs Learn Events
serial terminal - how to write to it to see debug results? — Parallax Forums

serial terminal - how to write to it to see debug results?

rikkirikki Posts: 53
edited 2016-06-04 08:20 in General Discussion
Hello,
I am a beginner, making very little progress.
I have a Propeller Mini and a Spinerette.
I am working in Propeller Tool.
I have spent time in the book "Programming and Customizing The Multicore Propeller".
I have opened and reviewed many examples fom the OBEX as well as the library packaged with the Propeller Tool, and I have searched this forum.

I see in the book examples that seem to be print statements to the serial terminal.
For example I see the instruction pst.
I find no explanation of pst in the book, nor in the Propeller Manual in the Prop Tool HELP, nor the quick reference sheet.
It isn't listed in the book's index or table of contents.

I see in the book statements such as pst.Str(String(" some text ")) , but if I include such a statement in my exploratory code, I get a compile error :

/home/rick/PropellerLibrary/rs/stateMachine.spin(72:5) : error : Expected an instruction or variable
Line:
pst: "output 16 is ON"
Offending Item: pst

As a total beginner, how do I include print statements to display debug info as I work?

A google search finds this link:
http://learn.parallax.com/support/reference/using-parallax-serial-terminal
The Serial Terminal, but this page explains only how to invoke the terminal, with no explanation at all how to write to it.

Thanks in advance for your attention and time.





Comments

  • Clock LoopClock Loop Posts: 2,069
    edited 2016-06-04 08:50
    You should copy all your code and paste it here so people can see how you are doing this.

    To print to the serial port you need to format your line like this, really you should have just replaced some text with output 16 is ON You forgot the parenthesis and the String formatter, you also added a colon : which shouldn't be there.

    your line with incorrect syntax
     pst: "output 16 is ON"
    
    your line with corrected syntax
     pst.str(string("output 16 is ON"))
    


    the pst "instruction" isn't actually an instruction, its a label for a file located in the propeller tool's code database.
    in this situation you have a OBJ area that has a line similar to this:
    OBJ
      pst  : "FullDuplexSerial"
    
    This is actually a reference to the file FullDuplexSerial.spin located here: C:\Program Files (x86)\Parallax Inc\Propeller Tool v1.3.2\Library\
    Propeller tool automatically searches that pathway for any objects specified in the OBJ block, even though you only provide the filename without the .obj or pathway.
    You can view the Propeller library by clicking File-->Open From-->Propeller Library
    That prompts you to choose a file from the library that was installed with propeller tool.
    If you choose FullDuplexSerial.spin you can view the code that pst.str invokes.
    Oh BTW, make sure you include this code at the very top of your program, it "initializes" the serial port.
    pst.Start(115_200)
    
    Many here do not have a copy of the book you are referencing so we cannot see the code you are running, which is why I suggest pasting your code here.
  • rikkirikki Posts: 53
    edited 2016-06-04 10:57
    Clock Loop,
    Thank you for your help.
    It's beginning to become clear to me now.

    I should have realized that "pst" is a reference to a separate source file.
    I have not yet began to follow the compiler's personality and messages very well.


    the code following returns an error:
    /home/rick/PropellerLibrary/rs/testcode.spin(16:18) : error : Expected ","
    Line:
    pst.Start(115_200)
    Offending Item: )


    OBJ
    pst : "FullDuplexSerial"


    VAR
    long state,nextstate


    PUB states

    ' initialize the serial terminal
    pst.Start(115_200)


    'view results
    if state == 0 AND ina[16]
    pst.str(string("output 16 is ON"))


  • Rather than "FullDuplexSerial", use "Parallax Serial Terminal". The latter is a simplified interface to FullDuplexSerial and the source code (in the Propeller Tool's library) documents the various calls.
  • rikkirikki Posts: 53
    edited 2016-06-04 15:06
    Thank you Mike Green, much appreciated. I'll give that a try.

    I think a sub-forum named "The Kiddie Pool" is called for, to receive questions from we clueless uninitiated types.
  • MicksterMickster Posts: 2,693
    edited 2016-06-04 20:45
    An alternative is ViewPort. Here is my DropBox link to V4.82

    There is a later version, 4.89 but is has issues.

    Edit: Forgot to mention that it allows you to watch variables and has many more cool features.
  • rikkirikki Posts: 53
    edited 2016-06-04 23:28
    Mickster wrote: »
    An alternative is ViewPort. Here is my DropBox link to V4.82

    There is a later version, 4.89 but is has issues.

    Edit: Forgot to mention that it allows you to watch variables and has many more cool features.

    Indeed! Thank you for that sir!
    It's a .zip file... not Windows I trust? If so has anyone tried it in Wine?



    Tell me please about PropBasic if you have a minute or two..

    .
  • Indeed! Thank you for that sir!
    It's a .zip file... not Windows I trust? If so has anyone tried it in Wine?

    Windows only, I have never used Wine, sorry.
    Tell me please about PropBasic if you have a minute or two..

    I regard PropBASIC as a Macro-PASM or a PASM-RAD (Rapid Application Development) tool.

    I am not fluent in PASM but I need my cog code to execute at full speed (20MIPS @80MHz).
    PropBASIC has a very easy to read/write BASIC syntax and translates directly to PASM code.
    You can further optimize the generated PASM code, by hand, although this has never been necessary for me.

    You have the option to mix cog-code (20MIPS) with LMM code (4-5MIPS), also.

    ViewPort supports PropBASIC as well as SPIN and there is some example PropBASIC code included in the .zip file that you downloaded from my DropBox.

    I believe that regular SPIN code executes at somewhere between 0.3 and 0.5 MIPS.

  • Clock LoopClock Loop Posts: 2,069
    edited 2016-10-03 22:10
    I told you the wrong initialization code, sorry.
    rikki wrote: »
    the code following returns an error:
    /home/rick/PropellerLibrary/rs/testcode.spin(16:18) : error : Expected ","
    Line:
    pst.Start(115_200)
    Offending Item: )


    OBJ
    pst : "FullDuplexSerial"


    VAR
    long state,nextstate


    PUB states

    ' initialize the serial terminal
    pst.Start(115_200)


    'view results
    if state == 0 AND ina[16]
    pst.str(string("output 16 is ON"))



    I mistakenly told you the wrong initialization code.

    I forgot to include the pins.

    Heres the syntax: start(rxpin, txpin, mode, baudrate)


    So your code would probably be:
    pst.Start(31, 30, %0000, 115200)
    

    A bit late on getting back to ya, wonder if you got past this.
  • Cluso99Cluso99 Posts: 18,069
    You should post your code between code tags..
    I have used "{" and "}" but you need to replace them with "[" and "]" to work!!
    {code}
    paste your code here
    {/code}

    Alternately, you can use PropTool File/Archive... to put all your code and objects into a zip file and attach that to your post.
Sign In or Register to comment.