uninterrupted transmission of large amounts of data via the serial interface

uninterrupted transmission of large amounts of data via the serial interface. I try to transfer a string (5x3x100 = 1500 characters). But sometimes the Transmission ends in the middel of the String. And the String is transmitted in 2 or more parts. I want to send the String in one Transmission.

My code:

//INCLUDES
//-----------------------------
#include "Tlc5940.h"

//DEFINMES
//-----------------------------
#define CHANNELS 16

//Variablen
//-----------------------------
  //Daten
  int offset;
  
  //TLC5940
  int data[NUM_TLCS * CHANNELS];
  int value;
  
  //Serial
  char inputBuffer[4];         // a string to hold incoming data
  int dataPointer;
  int inputBufferPointer;
  boolean transmissionCompleted = false;  // whether the string is complete

//INITIALISIERUNGEN
//-----------------------------
void setup()
{
  Tlc.init();
  Serial.begin(57600);
}

//HAUPTPROGRAMM
//-----------------------------
void loop()
{
  //Set to TLC5940
  //Tlc.clear();
  if( transmissionCompleted ){
    for( int currentDevice = 0; currentDevice < 3; currentDevice++ ){
      for( int channel = 0; channel < CHANNELS * NUM_TLCS; channel++ ){
        Tlc.set(channel, data[channel]); 
      }
    }
    Tlc.update();
    transmissionCompleted = false;
  }
}

void serialEvent() {
  while (Serial.available()) {
    // get the new byte:
    char receivedChar = (char)Serial.read();
    
    //suche nach Trennzeichen
    if( receivedChar == ',' ||  receivedChar == '\n' ) {
      char * PointerOfInputBuffer = inputBuffer;      //inputBufferPointer auf gefundene Zahl erzeugen
      data[dataPointer] = atoi(PointerOfInputBuffer); //Zahl in Form von String in Integer umwandeln
      inputBuffer[0] = 0;                             //Buffer löschen
      inputBuffer[1] = 0;                             //Buffer löschen
      inputBuffer[2] = 0;                             //Buffer löschen
      inputBuffer[3] = 0;                             //Buffer löschen
      dataPointer++;                          
      inputBufferPointer = 0;
    }
    //kein trennzeichen gefunden 
    else {
      inputBuffer[inputBufferPointer] = receivedChar;
      inputBufferPointer++;
    }
    
    //restliche werte 0 setzen
    for( int i = dataPointer; i < (NUM_TLCS * CHANNELS); i++ ) data[i] = 0;

    if (receivedChar == '\n') {
      transmissionCompleted = true;
      
      String output;
    output += "<UPDATE>";
    for(int i = 0; i < CHANNELS * NUM_TLCS; i++){
      char buff[12];
      output += itoa(data[i],buff,10);
      output += ",";
    }
    output += "</UPDATE>";
    Serial.print(output);
    Serial.write(3);
      
      dataPointer = 0;
    } 
  }
}

The String is generated and send here:

String output;
    output += "<UPDATE>";
    for(int i = 0; i < CHANNELS * NUM_TLCS; i++){
      char buff[12];
      output += itoa(data[i],buff,10);
      output += ",";
    }
    output += "</UPDATE>";
    Serial.print(output);
    Serial.write(3);

How can I solve this problem?

How can I solve this problem?

Don't use String

how should I send the data?

One byte at a time. I don't see what using String achieves.

uninterrupted transmission

Depending on your definition of "uninterrupted", the answer ranges from "not possible" to "piece of cake".

I am receiving the data for the arduino in a java software using an rxtx libary. sometimes the transmission is devided. that's what i mean with interruped.

I don't see why the data has to be transmitted by a single call to Serial.print. You've got over one and a half milliseconds between characters.

I am receiving the data for the arduino in a java software using an rxtx libary.

So? Put an end-of-record marker on the end of the stream of data sent, and read data until that marker has arrived.

There is no way, using a 64 byte buffer, to send 1500 characters "at once". Not that it makes sense to even try.

solved

Thanks for sharing your solution.

I used the idea from PaulS