Reading old messages in UART1 (changing baudrate, buffer flush...)

mr1000
Posts: 23
Joined: Fri Jan 12, 2018 9:05 am

Reading old messages in UART1 (changing baudrate, buffer flush...)

Postby mr1000 » Tue Oct 23, 2018 9:38 am

Hi there.
My idf version is v3.0-dev-1597-g2ddee729.

I use the UART's like this:
-UART0: communicate with other uC.
-UART1: communicate with a GSM
-UART2: print debug messages

I'm using the function of loboris example for PPPos and GSM, to send and receive to module via UART. (https://github.com/loboris/ESP32-PPPOS-EXAMPLE)
https://pastebin.com/2UEg7Vmg

I have to change baudrate of module GSM or else I'm receiving FCS drops when downloading (viewtopic.php?f=17&t=1496&start=30#p29823)

So here's my sequence when it goes correctly (always first time it executes):

Code: Select all

//Starting UART1 at 115200
AT COMMAND: [AT..]
AT RESPONSE: [..OK..]
AT COMMAND: [ATE0..]
AT RESPONSE: [..OK..]
AT COMMAND: [AT+IPR="19200"..]
AT RESPONSE: [..OK..]
//Changing UART1 baudrate to 19200 after AT+IPR="19200" executes ok
AT COMMAND: [AT+CFUN=1.]
AT RESPONSE: [..OK..]
AT COMMAND: [AT+CSQ..]
AT RESPONSE: [..+CSQ: 11,99....OK..]
AT COMMAND: [AT+CPIN?..]
AT RESPONSE: [..+CPIN: READY....OK..]
Skip command: [AT+CPIN="1234"..]
AT COMMAND: [AT+CREG?..]
AT RESPONSE: [..+CREG: 0,1....OK..]
AT COMMAND: [AT+CGDCONT=1,"IP","myApnUrl"..]
AT RESPONSE: [..OK..]
AT COMMAND: [AT+CGDATA="PPP",1..]
AT RESPONSE: [..CONNECT 14400000..]
status_cb: Connected
   ipaddr    = 10.156.191.53
   gateway   = 10.64.64.64
   netmask   = 255.255.255.255
   ip6addr   = ::
The problem occurs when I want to reset the module. I reset the module by setting it's RESET signal low and then HIGH.
Then I try to do the sequence again, and sometimes I'm getting messages from UART like they're duplicated or like old data messages.
And when an error like this happens, it keeps happening until I reset the power

For example:

Code: Select all

AT COMMAND: [AT..]
AT RESPONSE: [....OK...]
AT COMMAND: [ATE0..]
AT BAD RESPONSE: [......RDY..]
GSM: Wrong response [1], restarting...
Skip command: [AT..]
AT COMMAND: [ATE0..]
AT BAD RESPONSE: [AT...O]
GSM: Wrong response [2], restarting...
Skip command: [AT..]
AT COMMAND: [ATE0..]
AT BAD RESPONSE: [K..ATE]
GSM: Wrong response [3], restarting...
Skip command: [AT..]
AT COMMAND: [ATE0..]
AT RESPONSE: [0...OK]
AT COMMAND: [AT+IPR="19200"..]
AT RESPONSE: [....OK]
AT COMMAND: [AT+CFUN=1.]
AT RESPONSE: [....OK]
AT COMMAND: [AT+CSQ..]
AT BAD RESPONSE: [....OK....OK....OK...]
or for example in this one, the first AT is reading the response of a past "AT+CGDATA="PPP"

Code: Select all

GSM: Resetting GSM module...
//RESET pin low
GSM: Reset module done
//RESET pin high

GSM: start AT conf sequence
AT COMMAND: [AT..]
AT BAD RESPONSE: [CT 144000]
GSM: Wrong response [1], restarting...
AT COMMAND: [AT..]
AT BAD RESPONSE: [00.......]
GSM: Wrong response [2], restarting...
AT COMMAND: [AT..]
AT RESPONSE: [g.AT...OK]
AT COMMAND: [ATE0..]
AT BAD RESPONSE: [..AT.]
GSM: Wrong response [1], restarting...
Skip command: [AT..]
AT COMMAND: [ATE0..]
AT BAD RESPONSE: [AT...O]
GSM: Wrong response [2], restarting...
Skip command: [AT..]
AT COMMAND: [ATE0..]
AT BAD RESPONSE: [K..ATE]
GSM: Wrong response [3], restarting...
Skip command: [AT..]
AT COMMAND: [ATE0..]
AT RESPONSE: [0...OK]
AT COMMAND: [AT+IPR="19200"..]
AT RESPONSE: [....OK]
AT COMMAND: [AT+CFUN=1.]
AT RESPONSE: [....OK]
AT COMMAND: [AT+CSQ..]
AT BAD RESPONSE: [....OK....OK....OK...]
GSM: Wrong response [1], restarting...
Is uart_flush() not working? (it's being called before sending an AT command)
Also tried to delete uart driver and install it again with new baudrate, instead of using uart_get_baudrate(), but same result.
Also noticed that a esp_restart() don't solve the problem

WiFive
Posts: 2966
Joined: Tue Dec 01, 2015 7:35 am

Re: Reading old messages in UART1 (changing baudrate, buffer flush...)

Postby WiFive » Tue Oct 23, 2018 10:43 am

There is many commits to uart driver since your version https://github.com/espressif/esp-idf/co ... ver/uart.c

mr1000
Posts: 23
Joined: Fri Jan 12, 2018 9:05 am

Re: Reading old messages in UART1 (changing baudrate, buffer flush...)

Postby mr1000 » Tue Oct 23, 2018 11:08 am

WiFive wrote:There is many commits to uart driver since your version https://github.com/espressif/esp-idf/co ... ver/uart.c
Thanks, could I just update uart.c and uart.h, or I would have to update whole esp-idf? If so, which version do you recommend, v3.0.5?


EDIT:
Just trying v3.0.5 and it works okay for now.
(https://github.com/espressif/esp-idf/re ... tag/v3.0.5)

Who is online

Users browsing this forum: boarchuz and 29 guests