Welcome! Log In Create A New Profile

Advanced

Execute gcode with softwareserial

Posted by s_safak 
Execute gcode with softwareserial
January 04, 2023 06:54AM
Hi,
I added a new gcode M3333 for communication with Nextion Display and I am using SoftwareSerial.

void GcodeSuite::M3333() {
    SoftwareSerial mySerial(PA10, PA9); // RX, TX
    mySerial.begin(9600);
    mySerial.print(parser.string_arg);
    mySerial.write(0xff);
    mySerial.write(0xff);
    mySerial.write(0xff);
    mySerial.listen();
    while(mySerial.available()>0) {
    char c = mySerial.read();
    //if(c != '\n')
    Serial.write(c);
  }
}

This code works properly For ex: M3333 page page1 or M3333 b0.val=10

But I am trying to send commands from the Nextion display to Marlin firmware. I was trying a few things but not working. Therefore I need a suggestion. If you can help me I would be glad.

Regards
Re: Execute gcode with softwareserial
January 04, 2023 07:34PM
What motherboard are you using?

You need to set SERIAL_PORT to the interface you are using and set BAUDRATE properly.
Re: Execute gcode with softwareserial
January 04, 2023 11:37PM
SERIAL_PORT in marlin are for devices that talk gcode

LCD_SERIAL_PORT is for serial lcds talking custom protocols

Marlin already support a nextion display

//
// 320x240 Nextion 2.8" serial TFT Resistive Touch Screen NX3224T028
//
//#define NEXTION_TFT

So look at all code that references NEXTION_TFT mostly in Marlin/src/lcd/extui/nextion

take a close look at ReadTFTCommand()

Marlin uses a real serial port and a interrupt service request... adapting it software serial will be difficult.

Edited 4 time(s). Last edit at 01/05/2023 01:08AM by Dust.
Re: Execute gcode with softwareserial
January 05, 2023 04:34AM
FYI - Marlin's driver for the NEXTION_TFT requires #define LCD_SERIAL_PORT xx be added to configuration.h.
Re: Execute gcode with softwareserial
January 05, 2023 04:46AM
I am using SKR pro 1.2 motherboard and I tested many of SERIAL_PORT configuration. Baudrate is 9600 and I am sure it is correct. Because I can send a command with SoftwareSerial. Do you have any suggestions which serial port is correct for the TFT port?
Re: Execute gcode with softwareserial
January 05, 2023 05:04AM
marlin expect SERIAL_PORT to talk gcode.. end of story.

attempting to use for for anything else will end badly.

All received data is sent to the gcode passer

use LCD_SERIAL_PORT

You have to look at the pin diagrams for your board or the schematic


The tft port uses hardware uart 1

Edited 1 time(s). Last edit at 01/05/2023 05:39AM by Dust.
Sorry, only registered users may post in this forum.

Click here to login