Shop OBEX P1 Docs P2 Docs Learn Events
Parallax Serial Terminal skips first writes — Parallax Forums

Parallax Serial Terminal skips first writes

ErlendErlend Posts: 612
edited 2013-03-18 09:55 in General Discussion
Consequently the Parallax Serial Terminal - which I use (PC window) for debugging - keeps skipping the first one or two lines. I've tried to put in a delay after the pst.start, but it does not help. I picked a demo from obex, but it is the same thing:
OBJ
  pst   :       "Parallax Serial Terminal"

PUB Main | value, base, width, offset
  pst.Start(115_200)                                                            'Set Parallax Serial Terminal to 115200 baud


  '-------- Demo 1 --------
  pst.Str(@DemoHeader)                                                          'Print header; uses string in DAT section.
  pst.Chars("-", strsize(@DemoHeader))                                          'Use Chars method to output hyphens "-"
  pst.Str(String(pst#NL, pst#NL, "*** Number Feedback Example ***"))
  repeat
    pst.Chars(pst#NL, 3)                                                        'Output multiple new lines
    pst.Str(String("Enter a decimal value: "))                                  'Prompt user to enter a number; uses immediate string.
    value := pst.DecIn                                                          'Get number (in decimal).
    pst.Str(String(pst#NL, "Your value is..."))                                 'Announce output
    pst.Str(String(pst#NL, " (Decimal):"))                                      'In decimal
    pst.PositionX(16)                                                           'Move cursor to column 16
    pst.Dec(value)
    pst.Str(String(pst#NL, " (Hexadecimal):", pst#PX, 16))                      'In hexadecimal.  We used PX control code to
    pst.Hex(value, 8)                                                           '  move cursor (alternative to PositionX method).
    pst.Str(String(pst#NL, " (Binary):"))                                       'In binary.
    pst.MoveRight(6)                                                            'Used MoveRight to move cursor (alternative
    pst.Bin(value, 32)                                                          '  to features used above).
    pst.Str(String(pst#NL, pst#NL, "Try again? (Y/N):"))                        'Prompt to repeat
    value := pst.CharIn
  while (value == "Y") or (value == "y")                                        'Loop back if desired

Yes, baudrate is set correctly. I've tried stop & restart of the pst, but it doesen't help either. No fun with a bugg debugger!

Comments

  • Mike GMike G Posts: 2,702
    edited 2013-03-17 06:53
    There is no CON block that defines the clock speed. The snippet in post #1 does not compile due to a missing label.
    CON
            _clkmode = xtal1 + pll16x                                               
            _xinfreq = 5_000_000
    

    This functions as expected on my setup
    CON
            _clkmode = xtal1 + pll16x                                               
            _xinfreq = 5_000_000
    
    DAT
      demoHeader byte  "This is a test", 13, 0
              
    OBJ
      pst   :       "Parallax Serial Terminal"
    
    PUB Main | value, base, width, offset
      pst.Start(115_200)                                                            'Set Parallax Serial Terminal to 115200 baud
    
    
      '-------- Demo 1 --------
      pst.Str(@DemoHeader)                                                          'Print header; uses string in DAT section.
      pst.Chars("-", strsize(@DemoHeader))                                          'Use Chars method to output hyphens "-"
      pst.Str(String(pst#NL, pst#NL, "*** Number Feedback Example ***"))
      repeat
        pst.Chars(pst#NL, 3)                                                        'Output multiple new lines
        pst.Str(String("Enter a decimal value: "))                                  'Prompt user to enter a number; uses immediate string.
        value := pst.DecIn                                                          'Get number (in decimal).
        pst.Str(String(pst#NL, "Your value is..."))                                 'Announce output
        pst.Str(String(pst#NL, " (Decimal):"))                                      'In decimal
        pst.PositionX(16)                                                           'Move cursor to column 16
        pst.Dec(value)
        pst.Str(String(pst#NL, " (Hexadecimal):", pst#PX, 16))                      'In hexadecimal.  We used PX control code to
        pst.Hex(value, 8)                                                           '  move cursor (alternative to PositionX method).
        pst.Str(String(pst#NL, " (Binary):"))                                       'In binary.
        pst.MoveRight(6)                                                            'Used MoveRight to move cursor (alternative
        pst.Bin(value, 32)                                                          '  to features used above).
        pst.Str(String(pst#NL, pst#NL, "Try again? (Y/N):"))                        'Prompt to repeat
        value := pst.CharIn
      while (value == "Y") or (value == "y") 
    
  • ErlendErlend Posts: 612
    edited 2013-03-17 10:53
    Mike,
    I've tried this code too - the pst demo - what happens is that there is no text appearing - until I enter a value <enter>. After that it behaves in accordance with the code. Beats me.

    Erlend
  • Mike GMike G Posts: 2,702
    edited 2013-03-17 12:02
    It works fine on my setup. Seems kind of weird that it's the first set of chars and works from data entry on...

    You know, PST must be enabled to display serial data, right? By default, when the PST losses focus, it closes the serial port. The act of entering data in the PST window gives focus (selects) to the PST which enables the serial port again. Make sure PST is selected after right after running the SPIN code. Otherwise load the code in EEPROM.
  • ErlendErlend Posts: 612
    edited 2013-03-17 12:49
    I have used pst for years without trouble. Now I thought thare was something wrong with my code (sending clear screen code or something), but when the same thing happened with your code...? Same behaviour with eeprom load. And I am really quick to enable the pst window. Could it be something with com channel conflict?
  • jmgjmg Posts: 15,173
    edited 2013-03-17 13:00
    Erlend wrote: »
    I have used pst for years without trouble. Now I thought thare was something wrong with my code (sending clear screen code or something), but when the same thing happened with your code...? Same behaviour with eeprom load. And I am really quick to enable the pst window. Could it be something with com channel conflict?

    What do other terminals do ? What does PST do when looped back ?
    Have you checked the first char is 'legal' ?
    Most common cause of what you describe, if it does not appear on loop-back, is somehow a timer init fail skewing the first bit time.
  • ErlendErlend Posts: 612
    edited 2013-03-17 13:29
    My LCD is dead - I have no other terminals. Looped back? you mean echo on? - it workes fine. The strange thing it all works after the first silence. I tried to put in a long pause after pst.start - before sending text to it. There are no illegal characters, and it is not only doing this from my program, but others picked from obex too.
    It is increadibly frustrating to be stopped finding the bugs in my code, just because the debugger does'n work!
  • Mike GMike G Posts: 2,702
    edited 2013-03-17 13:48
    I highly doubt this problem is PST. The code works fine on my system and many other systems. This issue is specific to your system or setup.
  • John AbshierJohn Abshier Posts: 1,116
    edited 2013-03-17 14:38
    This code worked fine for me.
    OBJ
      pst   :       "Parallax Serial Terminal"
    
    CON
            _clkmode = xtal1 + pll16x                                               
            _xinfreq = 5_000_000
    
    DAT
      demoHeader byte  "This is a test", 13, 0
              
    PUB Main | value, base, width, offset
      pst.Start(115_200)                                                            'Set Parallax Serial Terminal to 115200 baud
      waitcnt(clkfreq * 3 + cnt)
    
      '-------- Demo 1 --------
      pst.Str(@DemoHeader)                                                          'Print header; uses string in DAT section.
      pst.Chars("-", strsize(@DemoHeader))                                          'Use Chars method to output hyphens "-"
      pst.Str(String(pst#NL, pst#NL, "*** Number Feedback Example ***"))
      repeat
        pst.Chars(pst#NL, 3)                                                        'Output multiple new lines
        pst.Str(String("Enter a decimal value: "))                                  'Prompt user to enter a number; uses immediate string.
        value := pst.DecIn                                                          'Get number (in decimal).
        pst.Str(String(pst#NL, "Your value is..."))                                 'Announce output
        pst.Str(String(pst#NL, " (Decimal):"))                                      'In decimal
        pst.PositionX(16)                                                           'Move cursor to column 16
        pst.Dec(value)
        pst.Str(String(pst#NL, " (Hexadecimal):", pst#PX, 16))                      'In hexadecimal.  We used PX control code to
        pst.Hex(value, 8)                                                           '  move cursor (alternative to PositionX method).
        pst.Str(String(pst#NL, " (Binary):"))                                       'In binary.
        pst.MoveRight(6)                                                            'Used MoveRight to move cursor (alternative
        pst.Bin(value, 32)                                                          '  to features used above).
        pst.Str(String(pst#NL, pst#NL, "Try again? (Y/N):"))                        'Prompt to repeat[code]
    
    value := pst.CharIn
    while (value == "Y") or (value == "y") 'Loop back if desired[/code]

    It produced this output
    This is a test
    ---------------
    
    *** Number Feedback Example ***
    
    
    Enter a decimal value:
    Your value is...
     (Decimal):     255
     (Hexadecimal): 000000FF
     (Binary):      00000000000000000000000011111111
    
    Try again? (Y/N):
    

    John Abshier
  • ErlendErlend Posts: 612
    edited 2013-03-17 15:18
    I'll move over to my laptop and see if that helps. I suspect some kind of com port conflict. Anyone know how I can override the automatic choice that Propeller Tool and pst makes - both use com 3 ?

    Erlend
  • RDL2004RDL2004 Posts: 2,554
    edited 2013-03-17 15:35
    In Device Manager> Ports (Com and LPT) find the device, right click it and select Properties, then click "Advanced".
    If you can change the Com port it will be in there.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2013-03-17 18:37
    Each time you connect a new FTDI device to your PC it creates a new com port for it. The com port stays the same for the particular FTDI chip unless you use a utility to change it.
  • frank freedmanfrank freedman Posts: 1,983
    edited 2013-03-17 19:38
    I have had the same behavior on my (windows w/ Proptool 1.32) machine. Generally manifested by the first few lines of expected terminal output missing.

    Two things I have noticed and done:
    1. after the startup of the FDX, put a 2-4 second delay; looks like that got mentioned a couple posts back. Not sure if that has really made much difference for what I have been doing. Guess it depends how long the cog used takes to initialize and be ready for I/O functions.
    2. after clearing the terminal and putting it to ready, I reset the prop and then I get all the expected output. I think there is just that much of a switchover delay between the download from the tool and the startup and make ready of the PST device. Seems I did not have this under BST on my linux box, but I could be wrong there as due to some issues using the terminal under linux, I have been using windows for a few weeks.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2013-03-17 20:04
    What always works for me:
    1. Put a CLS (char(0)) at the beginning of the program. No delay is needed.
    2. When loading a program, type -- in rapid succession -- F10 (or F11), F12, CR.

    -Phil
  • ErlendErlend Posts: 612
    edited 2013-03-18 09:55
    Fixed. Device manager had set the COM 3 to 9600 baud. I did two things; changed to COM16 and set it to 115200. Now it works. Probably no need to change COM #, but now it works : )
    I thought the COM was flexible wrt baud speed, thuogh.

    Happy: debugging my code contiues!

    EDIT
    ====
    No, now it does not work again. Back to frustrations.:frown:

    EDIT2
    Resignation == putting this line in at first whenever I need pst: value := pst.DecIn -but it is no fun for the brain. I hate patch kind of fixes.

    Erlend
Sign In or Register to comment.