Hello there,
I have backup my os catalina.
And now i have this trouble
Error, disabling serialEvent() for /dev/cu.usbserial-0001
null
I have installed an uart driver but without effect.
What could I do?
I’m just so sad
import processing.serial.*;
Serial DueSerialNativeUSBport141201; // The serial port
int v1 =0;
int v2 =400;
int v3,v4,v5 =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() {
LastTimeMiddleElapsed=1980;
LastTimeElapsed=4000-20;
// noStroke();
fill(255, 0, 0, 50);
println("Start Drawing!");
frameRate(45);
v1=counterV1=height/2;
// size(800,600);
// Open serial port
printArray(Serial.list());
DueSerialNativeUSBport141201 = new Serial(this, Serial.list()[2], 1000000);
// Read bytes into a buffer until you get a linefeed (ASCII 10):
DueSerialNativeUSBport141201.bufferUntil('\n');
//draw with smooth edges:
//smooth();
noLoop();
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;
}
}
// 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[0], 0, 4000, 0, 400);
v3 = (int) map (values[0], 0, 4000, 0, 400);
v4 = (int) map (values[0], 0, 4000, 0, 400);
v5 = (int) map (values[0], 0, 4000, 0, 400);
v2 = values[1]/10;
// print (oldv1); println (v1); println (v2);
// println (counterV1);
}
}
void samplingMovement() {
Timer= millis()%2000;
Timer2 = millis()%4000;
// print (" Timer "); print (Timer);
// print (" Timer2 "); println ( Timer2);
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 && Timer<=2000 && Timer2>=2000 ) //frameCount<=20*4+0
{
rx[i] = x;
// v1= (int) map (mouseY, 0, height, 0, 400);
ry[i] = v1;
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]);
}
}
int middleTime = millis();
int TimeMiddleElapsed = middleTime -beginTime;
if ( TimeMiddleElapsed >=1970 && TimeMiddleElapsed <=2030 || (frameCount >=30*4+1 && frameCount <=30*4+1)) {
LastTimeMiddleElapsed=TimeMiddleElapsed;
print (frameCount); print (" TimeMiddleElapsed "); println ( TimeMiddleElapsed);
}
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
}
}