unhex problem under controlP5
in
Contributed Library Questions
•
1 year ago
Now, I use controlP5 button to send and read data from USB. I need to convert the data(hex) I received to decimal.
But when I use unhex, it has error.
the error message is:
四月 11, 2012 10:15:34 下午 controlP5.ControlBroadcaster printMethodError
严重: An error occured while forwarding a Controller value
to a method in your program. Please check your code for any
possible errors that might occur in this method .
e.g. check for casting errors, possible nullpointers, array overflows ... .
method: Local_Temp
exception: java.lang.reflect.InvocationTargetException
However, if I use unhex like is : unhex("ab23"); it works.
My code is showing below:
public void Local_Temp(){
port.write("ATS1F?\r\n");
delay(500);
while (port.available() > 0) {
String temp = port.readString();
if (temp != null) {
String x[]=split(temp,"\n");
// myTextarea.setText(x[1]);
String tem= x[1];
println(tem);
int i = unhex(tem);
myTextarea.setText(i);
}
}
}
1