Serial port freezes my MKRZERO

Hi guys!

First of all, I'm a noobie so if I made horrible mistakes in my code or idea of functionment, please forgive me :slight_smile:

I use a MKRZERO with a OLED screen to display informations on the case of my HTPC. I planned to send these infos from the PC running Kodi to the arduino to display everything.

I first used a Nano and it worked well with the serial monitor but it was power limited to use the OLED screen. I then changed to a MKRZERO but now, sending one string via the Serial port of the GUI causes the freeze of the board and GUI.

Here is the code:

#include <Arduino.h>
#include <U8g2lib.h>
#include <SPI.h>
#include <Wire.h>

U8G2_SSD1322_NHD_256X64_F_4W_HW_SPI u8g2(U8G2_R2, 12, 7, 6);
int t;

String Ser;
String C;
String L;
char *T = "1234567890123456789012345678901234567890123456789012345678901234567890";
char *A = "12345678901234567890123456789012345678901234567890123456789012345678901";
char *H = "12  34";
char *R = "0:35:42/2:10:50";

void setup(void) {
  u8g2.begin();
  Serial.begin(115200); // opens serial port, sets data rate to 9600 bps-
  t = 0;
  T = "1234567890123456789012345678901234567890123456789012345678901234567890";
  A = "12345678901234567890123456789012345678901234567890123456789012345678901";
  H = "12  34";
  R = "0:35:42/2:10:50";
}


void loop(void) {

  u8g2.firstPage();
  do {
    //informations
    u8g2.setFontPosBottom();
    u8g2.setFont(u8g2_font_helvR14_tf);
    u8g2.drawUTF8(0, 30, T); //titre
    u8g2.setFont(u8g2_font_helvB10_tf);
    u8g2.drawUTF8(0, 50, A); //auteur

    //heure
    u8g2.setFont(u8g2_font_helvB08_tn);
    u8g2.setFontPosTop();
    u8g2.drawUTF8(226, 0, H);
    if (t < 3) {
      u8g2.drawUTF8(234, 0, "     ");
    } else {
      u8g2.drawUTF8(234, 0, "  :  ");
    }

    //barre avancement
    u8g2.drawBox(0, 63, 170, 1);
    u8g2.drawBox(0, 60, 100, 3);
    //texte avancement
    u8g2.setFont(u8g2_font_5x8_tn);
    u8g2.setFontPosBottom();
    u8g2.drawUTF8(180, 64, R);

  } while ( u8g2.nextPage() );
  //Clignotement ":"
  t += 1;
  if (t > 5) {
    t = 0;
  }
  while (Serial.available()) {
    Ser = Serial.readString(); // read the incoming data as string
    L = Ser.substring(1);
    C = Ser.substring(0, 1);
    if (C == "T") {
      strcpy (T, L.c_str());
    } else if (C == "A") {
      strcpy (A, L.c_str());
    } else if (C == "H") {
      strcpy (H, L.c_str());
    } else if (C == "R") {
      strcpy (R, L.c_str());
    }
  }
  delay(50);
}

Any idea?
Thanks in advance,
Nicolas