Touch Designer to Arduino Serial Communication

Hi! I’m trying to parse multiple live-time changing variables from TD to Arduino through serial. I currently have 2 channels (in null 4) and the data from these 2 channels are to be sent to Arduino. I found a similar thread (TouchDesigner to Arduino serial communication? - #10 by germz) but there seems to be a warning that pops out for serial node in TD.

CHOP Execute sends data to serial2 on value change. Serial2 sends it to Arduino.
Screenshot 2023-09-30 at 3.00.24 PM

Warning message, I’ve changed Roll/Callback to One per byte but it makes no difference

Here is the code for CHOP Execute:

# me - this DAT
# 
# channel - the Channel object which has changed
# sampleIndex - the index of the changed sample
# val - the numeric value of the changed sample
# prev - the previous sample value
# 
# Make sure the corresponding toggle is enabled in the CHOP Execute DAT.

def onOffToOn(channel, sampleIndex, val, prev):
	return

def whileOn(channel, sampleIndex, val, prev):
	return

def onOnToOff(channel, sampleIndex, val, prev):
	return

def whileOff(channel, sampleIndex, val, prev):
	return

def onValueChange(channel, sampleIndex, val, prev):
	
	motorVal1 = str(math.floor(op('null4')['chan1']))
	motorVal2 = str(math.floor(op('null4')['chan2']))
	
	print(motorVal1)
	
	op('serial1').send(motorVal1 + " " + motorVal2, terminator="\n")
	
	return

Here is the code on Arduino side:

int len = 0;
char buffer[40];

void setup() {
  Serial.begin(9600);
  while (!Serial) {
    ;
  }

  pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {

  if (Serial.available() > 0) {
    Serial.println("begin");
    int inByte = Serial.read();
    buffer[len++] = inByte;

    if (inByte == '\n') {
      int motorVal1, motorVal2;
      Serial.println(inByte);
      buffer[len++] = 0;
      len = 0;
      int n = sscanf(buffer, "%d, %d", &motorVal1, &motorVal2);

      Serial.print("n=");
      Serial.print(n);
      Serial.println();
    }
  }
}

I’m a beginning in both so any help is appreciated! Thank you!