I can’t. In this example I want to read 8 bytes which contain 2 integers. Why should I read the whole chunk of serialbuffer into an array by readBytes() ?
I found an workaround on Arduino side - I just added a waiting loop:
while (Serial.available() < sizeof(objectsize)) { delay(1); }
On processing side I send the first chunk then Arduino answers. So it’s a kind of ping pong and not just sending and reading without any syncronization.
How would you write the else if statement for the classes?