Break up data in Processing
in
Core Library Questions
•
2 years ago
Dear all interested readers.
Let's say that I want to send the next lines to a serial device. I want to send each line at a time. So, not all at once.
I need to break these lines up with the ; sings.
example:
;IN;ZZ1;PA;
SP4;
ZO100,18000;
PU;
PA0,0,-508;
SF127;
PD0,0,-10;
SF25;
PD0,0,254;
SF84;
PD5080,0,254;
PD5080,5080,254;
PD0,5080,254;
PD0,0,254;
SF127;
PA0,0,-508;PU;
I allready have this script:
/// code:
// The serial port:
Serial myPort;
float pX;
float pY;
String pT = ";";
void setup()
{
size(210, 297); // Size should be the first statement
stroke(255); // Set line drawing color to white
// Get the serial port working
import processing.serial.*;
// List all the available serial ports:
println(Serial.list());
// The first serial port should be COM1. So so I open Serial.list()[0]:
myPort = new Serial(this, Serial.list()[0], 9600);
String plotSetup = "IP;RO90;SC210,0,0,297;OW;";
println(plotSetup);
myPort.write(plotSetup);
}
// Draw a circle at the location of the mouse x 200
void draw() {
background(204);
String pdHere = "PA"+mouseX/2+","+mouseY/2+";PD;";
println(pdHere);
myPort.write(pdHere);
String inBuffer = myPort.readString();
println(inBuffer);
}
Does someone know how to do this? I will save the text on the start of this forum as a .txt file.
Thanks in advance,
Joshua Koomen
Let's say that I want to send the next lines to a serial device. I want to send each line at a time. So, not all at once.
I need to break these lines up with the ; sings.
example:
;IN;ZZ1;PA;
SP4;
ZO100,18000;
PU;
PA0,0,-508;
SF127;
PD0,0,-10;
SF25;
PD0,0,254;
SF84;
PD5080,0,254;
PD5080,5080,254;
PD0,5080,254;
PD0,0,254;
SF127;
PA0,0,-508;PU;
I allready have this script:
/// code:
// The serial port:
Serial myPort;
float pX;
float pY;
String pT = ";";
void setup()
{
size(210, 297); // Size should be the first statement
stroke(255); // Set line drawing color to white
// Get the serial port working
import processing.serial.*;
// List all the available serial ports:
println(Serial.list());
// The first serial port should be COM1. So so I open Serial.list()[0]:
myPort = new Serial(this, Serial.list()[0], 9600);
String plotSetup = "IP;RO90;SC210,0,0,297;OW;";
println(plotSetup);
myPort.write(plotSetup);
}
// Draw a circle at the location of the mouse x 200
void draw() {
background(204);
String pdHere = "PA"+mouseX/2+","+mouseY/2+";PD;";
println(pdHere);
myPort.write(pdHere);
String inBuffer = myPort.readString();
println(inBuffer);
}
Does someone know how to do this? I will save the text on the start of this forum as a .txt file.
Thanks in advance,
Joshua Koomen
1