Shop OBEX P1 Docs P2 Docs Learn Events
Issue with the Baudrate of "Serial Parallax Terminal" library — Parallax Forums

Issue with the Baudrate of "Serial Parallax Terminal" library

JChrisJChris Posts: 58
edited 2017-02-23 18:22 in Propeller 1
Hi,

I use a propeller C3 and an Ethernet Module (USR-K3)
I have an issue with the display on screen of Terminal and I don't understand why.
When I put the Baudrate of USR-K3 at 115200 (default) I obtain this (picture : "Baudrate 115200") and when I set the baudrate of my device to 9600, I get this (picture : "Baudrate 9600")

My code is the following for Baudrate at 115200
CON
  _clkmode = xtal1 + pll16x
  _xinfreq = 5_000_000


  USR_Rx = 0
  USR_Tx = 2
  USR_Rst = 4                     
  USR_Baud_115200 = 115200
  USR_Baud_9600 = 9600 


  CR = 13
  LF = 10

  temps_attente = 2000

VAR

  long char, Stack[200]
  byte AT_Reponse[150], cog

OBJ

  USR : "FullDuplexSerial"
  pst : "Parallax Serial Terminal"


PUB main

  pst.Start(115200)

  cog := USR.Start(USR_Rx, USR_Tx, 0, USR_Baud_115200)


  USR_Config

  waitcnt(clkfreq*5+cnt) 

  cogstop(cog)

  mac

PUB USR_Config

  pst.str(String("Start setting" ,9))
  pst.Str(String(CR))

  waitcnt(clkfreq/10+cnt)

  USR.Str(String("+++"))                                'Enter in AT command mode

  Rx_USR(temps_attente)

  pst.Str(String(13))  
  pst.str(String("Response 0: ",9))
  pst.Str(@AT_Reponse)
  pst.Str(String(13))

  USR.Str(String("a"))

  Rx_USR(temps_attente)

  pst.Str(String(13))  
  pst.str(String("Response 1: ",9))
  pst.Str(@AT_Reponse)
  pst.Str(String(13))

  waitcnt(clkfreq+cnt)

  USR.Str(String("AT+UART1=115200,8,1,NONE,NFC",CR))         'Set Baudrate at 115200

  Rx_USR(1000)

  pst.Str(String(13))  
  pst.str(String("Response 2: ",9))
  pst.Str(@AT_Reponse)
  pst.Str(String(13))

  waitcnt(clkfreq+cnt)

  USR.Str(String("AT+Z",CR))                                'Reset the device

  Rx_USR(1000)

  pst.Str(String(13))  
  pst.str(String("La réponse à ta requete est la suivante 3: ",9))
  pst.Str(@AT_Reponse)
  pst.Str(String(13))


PUB mac

  USR.Start(USR_Rx, USR_Tx, 0, USR_Baud_115200)

  pst.str(String("debut de la config" ,9))
  pst.Str(String(CR))

  waitcnt(clkfreq/10+cnt)

  USR.Str(String("+++"))                                                                             'Enter in AT command mode

  Rx_USR(temps_attente)

  pst.Str(String(13))  
  pst.str(String("La réponse à ta requete est la suivante 4: ",9))
  pst.Str(@AT_Reponse)
  pst.Str(String(13))

  USR.Str(String("a"))

  Rx_USR(temps_attente)

  pst.Str(String(13))  
  pst.str(String("La réponse à ta requete est la suivante 5: ",9))
  pst.Str(@AT_Reponse)
  pst.Str(String(13))

  waitcnt(clkfreq+cnt)
  
  USR.Str(String("AT+MAC",CR))                                                                         'Get MAC address of the device

  Rx_USR(1000)

  pst.Str(String(13))  
  pst.str(String("La réponse à ta requete est la suivante 6: ",9))
  pst.Str(@AT_Reponse)
  pst.Str(String(13))


Pub Rx_USR(timeout) | ptr  

    ptr := 0

'    USR.RxFlush
    repeat
      char := USR.RxTime(timeout) 
      pst.dec(char)
      AT_Reponse[ptr++] := char 
    while (char <> -1)

    AT_Reponse[--ptr] := 0
  


My code is the following for Baudrate at 9600
CON
  _clkmode = xtal1 + pll16x
  _xinfreq = 5_000_000


  USR_Rx = 0
  USR_Tx = 2
  USR_Rst = 4                     
  USR_Baud_115200 = 115200
  USR_Baud_9600 = 9600 


  CR = 13
  LF = 10

  temps_attente = 2000

VAR

  long char, Stack[200]
  byte AT_Reponse[150], cog

OBJ

  USR : "FullDuplexSerial"
  pst : "Parallax Serial Terminal"


PUB main

  pst.Start(115200)

  cog := USR.Start(USR_Rx, USR_Tx, 0, USR_Baud_9600)


  USR_Config

  waitcnt(clkfreq*5+cnt) 

  cogstop(cog)

  mac

PUB USR_Config

  pst.str(String("Start setting" ,9))
  pst.Str(String(CR))

  waitcnt(clkfreq/10+cnt)

  USR.Str(String("+++"))                                'Enter in AT command mode

  Rx_USR(temps_attente)

  pst.Str(String(13))  
  pst.str(String("Response 0: ",9))
  pst.Str(@AT_Reponse)
  pst.Str(String(13))

  USR.Str(String("a"))

  Rx_USR(temps_attente)

  pst.Str(String(13))  
  pst.str(String("Response 1: ",9))
  pst.Str(@AT_Reponse)
  pst.Str(String(13))

  waitcnt(clkfreq+cnt)

  USR.Str(String("AT+UART1=115200,8,1,NONE,NFC",CR))         'Set Baudrate at 9600

  Rx_USR(1000)

  pst.Str(String(13))  
  pst.str(String("Response 2: ",9))
  pst.Str(@AT_Reponse)
  pst.Str(String(13))

  waitcnt(clkfreq+cnt)

  USR.Str(String("AT+Z",CR))                                'Reset the device

  Rx_USR(1000)

  pst.Str(String(13))  
  pst.str(String("La réponse à ta requete est la suivante 3: ",9))
  pst.Str(@AT_Reponse)
  pst.Str(String(13))


PUB mac

  USR.Start(USR_Rx, USR_Tx, 0, USR_Baud_9600)

  pst.str(String("debut de la config" ,9))
  pst.Str(String(CR))

  waitcnt(clkfreq/10+cnt)

  USR.Str(String("+++"))                                                                             'Enter in AT command mode

  Rx_USR(temps_attente)

  pst.Str(String(13))  
  pst.str(String("La réponse à ta requete est la suivante 4: ",9))
  pst.Str(@AT_Reponse)
  pst.Str(String(13))

  USR.Str(String("a"))

  Rx_USR(temps_attente)

  pst.Str(String(13))  
  pst.str(String("La réponse à ta requete est la suivante 5: ",9))
  pst.Str(@AT_Reponse)
  pst.Str(String(13))

  waitcnt(clkfreq+cnt)
  
  USR.Str(String("AT+MAC",CR))                                                                         'Get MAC address of the device

  Rx_USR(1000)

  pst.Str(String(13))  
  pst.str(String("La réponse à ta requete est la suivante 6: ",9))
  pst.Str(@AT_Reponse)
  pst.Str(String(13))


Pub Rx_USR(timeout) | ptr  

    ptr := 0

'    USR.RxFlush
    repeat
      char := USR.RxTime(timeout) 
      pst.dec(char)
      AT_Reponse[ptr++] := char 
    while (char <> -1)

    AT_Reponse[--ptr] := 0
  

What is expected are the responses of the Baudrate 9600 image but this forces me to fix the baudrate to 9600 while I would like to set it to 115200 which is the default baudrate.

How do I get a good debugging with a baudrate set to 115200?

If someone has a clue, I would appreciate it.
1131 x 988 - 22K
1129 x 985 - 24K

Comments

  • lardomlardom Posts: 1,659
    edited 2017-02-23 20:03
    I ran both objects. In the second version there is a conflict with your baud rate:
    Your first line is:
    pst.Start(115200)
    
    But you also have:
    cog := USR.Start(USR_Rx, USR_Tx, 0, USR_Baud_9600)
    
    The baud rate has to match.
    I spoke too soon. They both run on my serial terminal.
  • Thx for your reply lardom.

    With both code, you get the same responses?
    If yes, do you know why I don't?
  • lardomlardom Posts: 1,659
    edited 2017-02-23 23:02
    I misunderstood your post but I took a look at one method that didn't seem to make sense. I commented the line that contained USR.RxTime since it didn't refer to anything that I could see. The constant timeout OTOH had a value of 2000 so I added the line char := timeout and I got something other than zero. I put in a string "hello" at different spots to see where it stopped.
    Pub Rx_USR(timeout) | ptr  
    
        ptr := 0
    
    '    USR.RxFlush
        repeat
     '     char := USR.RxTime(timeout)
          char :=  timeout
          pst.dec(char)
          AT_Reponse[ptr++] := char 
        while (char <> -1)
    
        AT_Reponse[--ptr] := 0
    
  • Please ignore everything I've said. I don't have a USR-K3 and I am embarrassed after studying char := USR.RxTime(timeout) and realizing that it is a valid 2 second delay!
  • JChrisJChris Posts: 58
    edited 2017-02-24 12:29
    Ok
    FYI : I put 2 second delay for testing but this works with 100ms but I have the same error with the baudrate 115200
  • The problem is that the program can't read from the serial port associated to the ethernet device fast enough to prevent the buffer overrun. I had the same problem with an ESP-01 module (the serial-only ESP8266). If the device doesn't use hardware flow control it transmits data at its maximum speed and if the serial buffer is filled faster that you are able to read from it you see data loss.

    You can try to increase the rx buffer size, I don't remember if the FullDuplexSerial code can be easily changed so I can't help on that matter right now, or as you have already tried decrease the serial port speed so your program can read the buffer fast enough.
  • Thx macca,

    it was the problem. I use now "FullDuplexSerialExtended" library that it has a larger buffer (256 bytes) whereas "FullDuplexSerial" library has 16 bytes

  • I use my own version of FDS that allows larger buffers and includes a few extra features (e.g., right-justified numeric output). My default buffer size is 128 bytes, but you can change it up to 512 (via a constant definition).
Sign In or Register to comment.