Controlling Automower

I can only guess, but it might be possible that the Automower gives feedback that has more than 5 Bytes and therefore I have the issue. In that case the script is not in sync anymore.

That's no reason to reset the Arduino. If you're unsure clear the serial buffer from time to time.

However I have a new issue with your code:

Why do you think this has anything to do with "my" code?
Your code formatting is still horrible. Please take the time to use the AutoFormatter in the IDE at least.

Although it should make a significant difference, change the code

#define BUFFERSIZE 40
uint8_t buffer[BUFFERSIZE];
uint8_t i = 0;
while (i < BUFFERSIZE) {
  if (client.available()) {
    uint8_t c = client.read();
    if (c == '/') break;
    buffer[i++] = c;
  }
}

to

#define BUFFERSIZE 40
uint8_t buffer[BUFFERSIZE];
uint8_t i = 0;
while (i < BUFFERSIZE) {
  if (client.available()) {
    uint8_t c = client.read();
    if (c == '/') break;
    buffer[i++] = c;
  }
}
if (i < BUFFERSIZE) buffer[i] = 0;

In digitalCommand() and analogCommand() you're still using the String class. Why?