Skip to content

P3D crash with serialEvent #5398

@MazeArt

Description

@MazeArt

Hey Guys,
I am trying to draw a 3d object based on readings of a gyroscope sensor.
I get a Fatal Error :

#A fatal error has been detected by the Java Runtime Environment:
#SIGSEGV (0xb) at pc=0x00007fff7ac58e31, pid=27319, tid=0x0000000000012a03`
#
#JRE version: Java(TM) SE Runtime Environment (8.0_144-b01) (build 1.8.0_144-b01)
#Java VM: Java HotSpot(
#TM) 64-Bit Server VM (25.144-b01 mixed mode bsd-amd64 compressed oops)
# Problematic frame:
# C  [libGL.dylib+0xe31]  glClearColor+0xd
#
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /Users/Delia/hs_err_pid27319.log
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
Could not run the sketch (Target VM failed to initialize).
For more information, read revisions.txt and Help → Troubleshooting.

This is the Code :

//https://forum.processing.org/one/topic/rotate-cube-sensor.html 

import processing.serial.*;     // import the Processing serial library
Serial myPort;                  // The serial port

float bgcolor;            // Background color
float fgcolor;            // Fill color
float xpos, ypos;            // Starting position of the ball

void setup() {
  frameRate(30);
  size(640,480, P3D);
  background(0);
  lights();
  // List all the available serial ports
 // println(Serial.list());
  myPort = new Serial(this, "/dev/cu.usbmodem1421", 38400);

  // read bytes into a buffer until you get a linefeed (ASCII 10):
  myPort.bufferUntil('\n');
  
  // draw with smooth edges:
  smooth();
}

void draw() {
}

void serialEvent(Serial myPort) { 
  background(0);
  noStroke();
  pushMatrix();
  translate(width/2, height/2);
  
  // read the serial buffer:
  String myString = myPort.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:
    float sensors[] = float(split(myString, ','));
//println("roll: " + sensors[0] + " pitch: " + sensors[1] + " yaw: " + sensors[2] + "\t");
    // print out the values you got:
    for (int sensorNum = 0; sensorNum < sensors.length; sensorNum++) {
      print("Sensor " + sensorNum + ": " + sensors[sensorNum] + "\t");
     if (sensorNum == 0) {
       println("Roll");
       //rotateX(sensors[0]);

     }
     if (sensorNum == 1) {
       println("Pitch");
       //rotateY(sensors[1]);

     }
     if (sensorNum == 2) {
       println("Yaw");
       //rotateZ(sensors[2]);
     }
     
    }
    // add a linefeed after all the sensor values are printed:
    println();
    box(100);
    popMatrix();
    if (sensors.length > 1) {
      rotateX(sensors[0]);
      rotateY(sensors[1]);
      rotateZ(sensors[2]);
    }
    // send a byte to ask for more data:
    myPort.write("A");
  }

##Environment

  • Processing version: 3.3.6
  • Operating System and OS version: OS Sierra 10.12.6
    *Macbook Pro Retina, 15-inch, Mid 2014;
    *Graphics Card : NVIDIA GeForce GT 750M 2048 MB
    Intel Iris Pro 1536 MB

Any help would be greatly appreciated, thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions