Hi there,
I am attempting to get the frontend working for the PID library and I've hit something of a snag. I am getting the following error when I run the program in Processing:
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
The graphical display comes up but no data is passed to or received from the arduino. Nothing comes up on the graph or in the data fields to the left.
I was able to eliminate the error by removing the setValue() and setText() commands in serialEvent(). If I comment out those lines, like this:
//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;
}
}
Again, the graphical window comes up, but some data starts coming from the arduino (the led starts blinking), and it begins drawing the setpoint, input, and output lines. The data fields to the left do not show anything. However, I can change the setpoint, "Send to Arduino" and the green line will reflect the change.
I've read around a bit about this error, but I still don't understand what's going on.
Do you have any thoughts?
BTW I'm running on Ubuntu, if that makes any difference.
EDIT: I just tried this on a windows laptop and it worked with no errors. It must be specific to Linux or Ubuntu versions of processing.
EDIT2: This thread is the closest I've come to a similar error, but its from 2007, and they don't have a solution:
http://processing.org/discourse/yabb2/YaBB.pl?num=1183525352