Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serial2 stopped working #66

Open
hayderismael opened this issue Jun 20, 2024 · 1 comment
Open

Serial2 stopped working #66

hayderismael opened this issue Jun 20, 2024 · 1 comment

Comments

@hayderismael
Copy link

hayderismael commented Jun 20, 2024

Hello,

I appreciate that you put so much effort into making Nextion easy to use with your library. It is elegant.

I have used EasyNex myNex(Serial2) with ESP32 for the last two years, and it used to work perfectly. Nevertheless, It stopped yesterday when I tried it again.

Here is an example of how I used to use it: The Nextion first restarted with ESP32 and then went to page home.

This code used to work very well till yesterday.

I tried:
1- Use another ESP32 board ; not work. I still read what I print via the serial monitor.
2- I re-upload the code to an old ESP32, which worked before I flushed it and uploaded the code again. The MCU did not communicate after reuploading the code.
3- I used another Nextion display, it did not work.
4- Use the default Serial pins

EasyNex myNex(Serial);
It worked.

5- I used Arduino boards, Mega and Giga R1 WiFi with EasyNex myNex(Serial2) . It worked perfectly.

#include "EasyNextionLibrary.h" // Include EasyNextionLibrary
EasyNex myNex(Serial2);         //  Pin 16 = RXD2, Pin 17= TXD2
void setup() {
Serial.begin(115200);
delay(100);
Serial.println("Begin...");
delay(1000);
myNex.begin(115200);    // UART 2);   // Start with nextion bauds for serial communication.
Serial.println("reset1...");
myNex.writeStr("rest"); 
delay(1000); // wait till Nextion is restarted
myNex.writeStr("page home");  // Go to page home.
}

void loop() {
  //Put your main code here, to run repeatedly:
    Serial.println("loop...");
    delay(1000);
}

Then I used hardware serial between the EasyNex myNex(Serial2) as follows and it worked with all boards and displays.

#include <EasyNextionLibrary.h>
// Define the RX and TX pins for Serial 2
#define RXD2 16
#define TXD2 17
HardwareSerial mySerial(2);  // Initialize Serial 2
EasyNex myNex(mySerial);     // Pass the HardwareSerial object to EasyNex


void setup() {

  Serial.begin(115200);
  Serial.println("Begin...");
  delay(1000);
  mySerial.begin(115200, SERIAL_8N1, RXD2, TXD2);
  // Initialize the EasyNex object
  myNex.begin(115200);
  //myNex.begin(115200);    // UART 2);   // Start with nextion bauds for serial communication.
  Serial.println("reset1...");
  myNex.writeStr("rest");  
Serial.println("we go home...");
delay(1000); // wait till Nextion is restarted
  myNex.writeStr("page home"); 
  delay(100);
}

void loop() {
  Serial.println("loop...");
  delay(1000);
}

Would you please advise if something is wrong and why it doesn't work as it does in the fashion way?

Thanks for any help.

@Oleg-Perevyshin
Copy link

I confirm!
I also have something strange going on with the ports...
The application crashes and does not work.

ESP Exception Decoder
Sketch: DisplayBridge FQBN: esp32:esp32:esp32

Guru Meditation Error: Core  1 panic'ed (InstrFetchProhibited). Exception was unhandled.

Core  1 register dump:
PC      : 0x00000000  PS      : 0x00060630  A0      : 0x800d48f6  A1      : 0x3ffb21f0  
A2      : 0x3ffc14ec  A3      : 0x00000000  A4      : 0x00000001  A5      : 0x10624dd3  
A6      : 0x3ffbdbac  A7      : 0xb33fffff  A8      : 0x800d45b4  A9      : 0x000000fc  
A10     : 0x00000000  A11     : 0x00000000  A12     : 0x3ffb9090  A13     : 0x00000000  
A14     : 0x00000000  A15     : 0x00000000  SAR     : 0x0000000a  EXCCAUSE: 0x00000014  
EXCVADDR: 0x00000000  LBEG    : 0x40085d08  LEND    : 0x40085d12  LCOUNT  : 0x00000000  


Backtrace: 0xfffffffd:0x3ffb21f0 0x400d48f3:0x3ffb2210 0x400d4549:0x3ffb2230 0x400d432d:0x3ffb2250 0x400d77d8:0x3ffb2270 0x4008ab5a:0x3ffb2290

ELF file SHA256: bf5315c43f487f2e

Rebooting...

PC: 0x00000000
EXCVADDR: 0x00000000

Decoding stack results
0x400d48f3: EasyNex::readCommand() at c:\Users\perevyshin_oe\Documents\Arduino\libraries\Easy_Nextion_Library\src\readCustomCommands.cpp:61
0x400d4549: EasyNex::NextionListen() at c:\Users\perevyshin_oe\Documents\Arduino\libraries\Easy_Nextion_Library\src\EasyNextionLibrary.cpp:331
0x400d432d: loop() at E:\RockingStand\DisplayBridge\DisplayBridge.ino:95
0x400d77d8: loopTask(void*) at C:\Users\perevyshin_oe\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.4\cores\esp32\main.cpp:74
0x4008ab5a: vPortTaskWrapper at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/FreeRTOS-Kernel/portable/xtensa\port.c:162

The code is simple

#include <HardwareSerial.h>
#include <EasyNextionLibrary.h> /* https://github.com/Seithan/EasyNextionLibrary */
#include <Arduino_JSON.h>       /* https://github.com/arduino-libraries/Arduino_JSON */

#define DEBUG_RX 3
#define DEBUG_TX 1
HardwareSerial Serial_Debug(0);

#define BASE_RX 26
#define BASE_TX 25
HardwareSerial Serial_Base(1);

#define DISPLAY_RX 16
#define DISPLAY_TX 17
HardwareSerial Serial_Display(2);
EasyNex serial_display(Serial_Display);

template<typename T>
void DEBUG_PRINT(const String &argument, const T &value) {
  if (Serial_Debug) {
    Serial_Debug.print(argument);
    Serial_Debug.print(": ");
    Serial_Debug.println(value);
  }
}


void setup() {
  delay(100);

  Serial_Debug.begin(115200);
  while (!Serial_Debug) {}
  DEBUG_PRINT("DEBUG", "Init Debug Module");
  delay(250);

  Serial_Base.begin(115200, SERIAL_8N1, BASE_RX, BASE_TX);
  while (!Serial_Base) {}
  DEBUG_PRINT("DEBUG", "Base UATR Started");
  delay(250);

  Serial_Display.begin(115200, SERIAL_8N1, DISPLAY_RX, DISPLAY_TX);
  while (!Serial_Display) {}
  DEBUG_PRINT("DEBUG", "Display UATR Started");
  delay(250);

  send_to_display("page Boot");
  delay(4250);
  send_to_base("SYS", "Display Started", "");
}


void loop() {
  serial_display.NextionListen();
}

Debug Serial:

DEBUG: Init Debug Module
DEBUG: Base UATR Started
DEBUG: Display UATR Started
DEBUG: send_to_display: Command:  page Boot
DEBUG: send_to_base: Header:  SYS | Argument: Display Started | Value: 

After that the app crashes.
If you disconnect the wires from the display, the app works.
I noticed that it crashes when the display sends anything to the ESP32.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants