Processing freezing
in
Contributed Library Questions
•
11 months ago
Hey everyone, I hope that someone'll be able to help me with a problem I'm having.
Basically, I'm sending a series of numbers from my phone (accelerometer and button presses) to processing for packaging and interaction with Arduino via serial communications.
The problem is, whenever I start to send the packaged data which looks something like this: <0[0-180],0[0-180],0[0-1]>
Processing just freezes. No warnings, no indications of what caused the failure, it just stops doing anything. The sketch icon that appears when you run the program stays stuck in the task bar even when you close Processing fully, so something very strange is going on.
When I re-open Processing, it stays broken, so the only way I've found to bring it back to life is do a full restart of the system.
If anyone has any clue of what's going on or how to address it, that would be most appreciated.
Here's what code I have, should that help.
- import processing.serial.*;
- Serial myPort;
- import oscP5.*;
- import netP5.*;
- float y2;
- float z2;
- String yy;
- String zz;
- String ii = "00";
- String sending;
- OscP5 osc;
- void setup() {
- osc = new OscP5(this, 10000); //this line tells processing to listen for
- //info from processing.
- osc.plug(this, "tilting", "/tilt"); //This line says that whenever /tilt is
- //recieved from the phone, to activate the function "tilting"
- //which is listed below under void draw().
- osc.plug(this, "touching", "/touch");
- println(Serial.list());
- myPort = new Serial (this, Serial.list()[0], 9600, 'N', 8, 1.0);
- }
- void draw () {
- sending = "<"+yy+","+zz+","+ ii+">";
- myPort.write(sending);
- println (sending);
- delay(10);
- }
- void touching(int i) {
- ii = nf(i, 2);
- }
- void tilting(float x, float y, float z) {
- yy = nf(round(map (y, 0, 127, 0, 180)), 3);
- zz = nf(round(map (z, 0, 127, 0, 180)), 3);
- yy = '0' + yy;
- zz = '0' + zz;
- delay(10);
- }
1