I was read all comments on this question, but all codes was share so verbosing. After that, i create a code with simple functions and less of line. in this case, i think this code workwill working fine
if you set baudrate under 115200, must be add delay() for saving message to char array
void loop() {
char data[255];
uint8_t k = 0;
while (Serial.available()) {
data[k] = Serial.read();
k++;
}
for (int i = 0; i < k; i++) {
Serial.print(data[i]);
data [i] = '\0';
}
//delay(50);
}