Welcome! Log In Create A New Profile

Advanced

Marlin 2.0.x - Multi serial on AVR ( and other )

Posted by Black_Wolf 
Marlin 2.0.x - Multi serial on AVR ( and other )
April 13, 2018 11:12AM
Hello all.
Is it plan to enabled this feature on AVR soon ?
Is it also possible to add multi baudrate.

I use a RobotDyn Mega with WiFi on a Ramps 1.4 and a serial TFT on my printer, and Linux on my computer. I have some problems with 250000 baud on serial usb, but for the TFT, the only way to make it work is to set it at 250000.
So I use Serial1 at 250000, and WiFi at 115200 on Serial3 with some changes on the code like this.
// HAL/HAL_AVR/HAL_AVR.h
#define NUM_SERIAL 1

#ifdef USBCON
  #if ENABLED(BLUETOOTH)
    #define MYSERIAL0 bluetoothSerial
  #else
    #define MYSERIAL0 Serial
  #endif
#else
  #define MYSERIAL0 customizedSerial
  #ifdef SERIAL_PORT_2
     #undef NUM_SERIAL
    #ifdef SERIAL_PORT_3
      #define NUM_SERIAL 3
      #define MYSERIAL1 customizedSerial1
      #define MYSERIAL2 customizedSerial2
    #else
      #define NUM_SERIAL 2
      #define MYSERIAL1 customizedSerial1
    #endif
  #else
    #ifdef SERIAL_PORT_3
      #undef NUM_SERIAL
      #define NUM_SERIAL 2
      #define MYSERIAL1 customizedSerial1
    #endif
  #endif
#endif

// Marlin.cpp
  #if NUM_SERIAL > 0
    MYSERIAL0.begin(BAUDRATE);
    #if NUM_SERIAL == 2
      #ifdef BAUDRATE2
        MYSERIAL1.begin(BAUDRATE2);
      #else
        MYSERIAL1.begin(BAUDRATE);
      #endif
    #endif
    #if NUM_SERIAL == 3
      #ifdef BAUDRATE2
	MYSERIAL1.begin(BAUDRATE2);
      #else
	MYSERIAL1.begin(BAUDRATE);
      #endif
      #ifdef BAUDRATE3
	MYSERIAL2.begin(BAUDRATE3);
      #else
	MYSERIAL2.begin(BAUDRATE);
      #endif
    #endif
  #endif

Not working for now because MarlinSerial don't support multi instance but I'm looking to scratch it.
Sorry, only registered users may post in this forum.

Click here to login