Processing Forum
error, disabling serialEvent() for /dev/ttyUSB0
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at processing.serial.Serial.serialEvent(Unknown Source)
at gnu.io.RXTXPort.sendEvent(RXTXPort.java:732)
at gnu.io.RXTXPort.eventLoop(Native Method)
at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1575)
Caused by: java.lang.NullPointerException
at PID_FrontEnd_v02.serialEvent(PID_FrontEnd_v02.java:436)
... 8 more
//take the string the arduino sends us and parse it
void serialEvent(Serial myPort)
{
String read = myPort.readStringUntil(10);
if(outputFileName!="") output.print(str(millis())+ " "+read);
String[] s = split(read, " ");
if (s.length ==8)
{
Setpoint = float(s[1]); // * pull the information
Input = float(s[2]); // we need out of the
Output = float(s[3]); // string and put it
//SPLabel.setValue(s[1]); // where it's needed
//InLabel.setValue(s[2]); //
//OutLabel.setValue(trim(s[3])); //
//PLabel.setValue(trim(s[4])); //
//ILabel.setValue(trim(s[5])); //
//DLabel.setValue(trim(s[6])); //
//AMCurrent.setValue(trim(s[7])); //
if(justSent) // * if this is the first read
{ // since we sent values to
//SPField.setText(trim(s[1])); // the arduino, take the
//InField.setText(trim(s[2])); // current values and put
//OutField.setText(trim(s[3])); // them into the input fields
//PField.setText(trim(s[4])); //
//IField.setText(trim(s[5])); //
//DField.setText(trim(s[6])); //
mode = trim(s[7]); //
//AMLabel.setValue(mode); //
justSent=false; //
} //
if(!madeContact) madeContact=true;
}
}