Problem with serial port. Upgrade Monterey from Catalina

Hello everybody!
I upgraded my Mac OS from Catalina to Monterey.
Since I have did that my program stops itself around 30 secondes.
Do I have to download a special library?
Do you have the same problem?

In this program click once and move mouse up and down, the the program send datas to a serial port

import processing.serial.*;    
Serial DueSerialNativeUSBport141201; // The receive data port
Serial DueSerialSendUSBport141201; // The sending data port
 
int v1 =0;
int v2 =400;
int x;

int  counterV1;
int  oldv1;
//Record and repeat movement

int num = 20*4;
int numberSec = 4;

float mx[] = new float[num]; // Future
float my[] = new float[num]; // Future

float rx[] = new float[num];
float ry[] = new float[num];

int beginTime,endTime,TimeMiddleElapsed,LastTimeMiddleElapsed,Timer,Timer2,LastTimeElapsed;

int actualSec,lastSec, lastLastSec;

public void settings() {
  size(600, 600, P3D);
} 

 
void setup() {

//  noStroke();
  fill(255, 0, 0, 50); 
  println("Start Drawing!");
  frameRate(45);
  v1=counterV1=height/2;
//  size(800,600);
  // Open serial port
  printArray(Serial.list());
  DueSerialSendUSBport141201 = new Serial(this, Serial.list()[0], 9600);
 // DueSerialNativeUSBport141201 = new Serial(this, Serial.list()[1], 9600);
 
  // Read bytes into a buffer until you get a linefeed (ASCII 10):
 // DueSerialNativeUSBport141201.bufferUntil('\n');
 
  //draw with smooth edges:
  //smooth();
  background(255);
}
 
void draw() {
  
    if  (actualSec>lastSec){
  lastLastSec=lastSec;
  lastSec=actualSec; 
    }  
    actualSec = second();  // Values from 0 - 59
 // print ( lastLastSec); print ( "last" ); print ( lastSec );  print ( "actual" ); println ( actualSec ); 
  samplingMovement();
   if (oldv1<v1 && v1!= oldv1 ){
    counterV1++;
   
  }
  // Draw circles
  fill(#ff0000);
  ellipse(x, v1+height/2, 10, 10);
  fill(#00ff00);
  ellipse(x, oldv1-10, 5, 5);
 
  // Update x position
  x++; 
  // Refresh screen
  if (x > 300) {
    background(255);
    x = 0;
  }
   int j = int(frameCount%(20*4));
  
 String DueSerialSendUSBport141201Data  ="<" 
 
    +  v2+"," + ry[j] + ">"; //    cohesionCounterHigh // +orderCohesion+ ">";LevelCohesionToSend ","+ int (map ( LowLevelCohesionToSend, 0, 1, 0, 100))+ 

  println(frameCount + ": " +  " DueSerialSendUSBport141201Data " + ( DueSerialSendUSBport141201Data ));
  DueSerialSendUSBport141201.write(DueSerialSendUSBport141201Data); // Send data to Teensy. only the movement 
 
}
 
// serialEvent  method is run automatically by the Processing applet
// whenever the buffer reaches the byte value set in the bufferUntil()
// method in the setup():
void serialEvent(Serial DueSerialNativeUSBport101) { // receive 2 datas splited with ,
 
  // read the serial buffer:
  String myString = DueSerialNativeUSBport101.readStringUntil('\n');
 
  // if you got any bytes other than the linefeed:
  myString = trim(myString);
 
  // split the string at the commas
  // and convert the sections into integers:
  int values[] = int(split(myString, ','));
 
  if (values.length > 0) {// v1 de 0 a 4000
       oldv1=v1;
    v1 = (int) map (values[0], 0, 4000, 0, 400);
 
    v2 = (int) map (values[1], 0, 4000, 0, 400);
    print (v1); print (" v1 ");  println (v1);    

   print (v2); print (" v2 ");  println (v2);    

  // println (counterV1);
   
}
}
void samplingMovement() {

   
    int i = int(frameCount%(20*4));
    if(frameCount>=0 && frameCount<=20*4+0 )
    {
    if(frameCount<=1) { // record 4 secondes
     int timeElapsed= endTime-beginTime; 
     print (" timeElapsed"); println (timeElapsed);
     beginTime=millis();
     background(0);
     
      } 
 //   else    background(0);
    if(frameCount>0  )    //frameCount<=20*4+0
    {
    rx[i] = x;
  //  ry[i] = v1;
    v2= (int) map (mouseY, 0, height, 0, 400);
   ry[i] = v2;
    mx[i] = rx[i];
    my[i] = ry[i];
    fill(255, 0, 0, 50); 
    circle(rx[i], ry[i], 10); 
 //   print (frameCount); print (" ry "); print (i); print ("  "); println (ry[i]);
  
    }    
   }
 
    if(frameCount>=20*4+1 ) // begin to replay
    {
       int TimeBack = millis(); 
    int TimeBackElapsed = TimeBack -beginTime;
     print (frameCount); print ("  TimeMiddleElapsed "); println ( TimeBackElapsed);
    circle(x+300, my[i], 10); 
  //  print (frameCount); print (" ry' "); print (i); print ("  "); println (ry[i]);
    print (frameCount); print (" ry "); print (i); print ("  "); print (ry[i]);
    print (" my "); print (i); print ("  "); println (my[i]);
    } 
  
    if(frameCount>=2*20*4 && frameCount<=2*20*4+0  ) // && Timer2>=4000-20 end  of replay // && actualSec>lastSec to synchronise with a second trigger
    {
      
    endTime=millis();
    int timeElapsed= endTime-beginTime; 
    LastTimeElapsed= timeElapsed;
     print (" LastTimeElapsed"); println (LastTimeElapsed);
    Timer=0;
    Timer2=0;
    background(255);
    
       // frameCount = -1; // Resets frameCount. -1 will run setup() again!

    frameCount = 81; // Restart only recorded loop
  //  frameCount = 0; // Restart from beginning
    }
    
//    if (mousePressed==true && Timer<=20) {
     if (mousePressed==true && frameCount>=0
     ) {
    frameCount = 1; // Restart main loop better than frameCount = 0
     } 
   
     
     
}

Hi,
without the serial stream to test it i may be wrong
but i wonder if it can be a serial buffer problem?:
serial is set to 9600 baud which can barely achieve 900 octet/second when unidirectionnal
and framerate is set to 45, so it allow max 20 char serial write by loop, i think you re already near that limit and your connection is bidirectionnal , it looks to much data for this connection to me

can you set your teensy and serial to 57600 or up?
or may be trying a slower framerate?

Hi th75,
Unfortunately it is not a problem of serial buffer.
In my actual program i send data to 115000 bauds.
It works perfectly with catalina.
The problem is just when i add the line

DueSerialSendUSBport141201.write(DueSerialSendUSBport141201Data);

I have downloaded Processing for puce M1.
I think the problem is with Java. I think i have to download the last version and put it in Processing, but i don’t know How I have to do that!

(may be try the intel version of processing too, for some libraries it looks more stable and rosetta does a good job)

otherwise not much idea here, jumping to m1 then updating to ventura, i had to reinstall drivers for cheap arduino/esp board using ch340 usb
but i guess you receive the data correctly? so connection is not involved
did you had a look at “console.app” when it crash to see if there is some log there?
i ve a bunch of processing/arduino sketch on m1 without problems so far, both monterey and ventura, processing 3.5.4 and 4.2, i use the vsync library but it use the default serial library so i guess the problem is not there

sorry no more ideas, i will go back to the simple serial write example to see if it’s related to serial only

Hi,
I have checked by plugging my usb serial (not by using a virtual port as bluetooht port, because it worked like that with catalina) and finally, it work!
Thanks for your answers!