I run your code on a Mega.
- if stimulated via serial monitor, it works on a string of 'C's which are closer than 100 ms
- if stimulated with processing there was no reception, regardless of the character spacing
- it started to work after inserting a delay after the open, to give the processor time to reset
I guess you are triggering the bootloader by sending serial data in the reset phase,
like I did with the very first approach.
This is processing sketch I used
import processing.serial.*;
Serial port;
String inString = "nothing";
void setup() {
size(400, 400);
noStroke();
background(200);
printArray(Serial.list());
port = new Serial(this, "COM28", 115200);
port.bufferUntil('\n');
delay(2000);
}
int lastSend;
byte msg[] = { 'C' };
void draw() {
if (millis()-lastSend >= 100) {
lastSend = millis();
port.write(msg);
print('C');
}
}
void serialEvent(Serial p) {
inString = trim(p.readString());
println(inString);
}