please help with serial and point
in
Core Library Questions
•
10 months ago
hello.
Im trying to draw points according to incomming doubles, which are converted to floats, using point(x,y).
Ive checked content of the vals[] ,xin,yin,zin and they seemes to contain the values sent from arduino.
Trying to plot points either give me no points or the below error. (below the code)
Would appreicate any help. Regards
Part of processing code:
- void serialEvent(Serial p) {
inString = p.readString();
lengde=inString.length();
inString=inString.substring(0, lengde-1);
float[] vals = float(splitTokens(inString,","));
xin=vals[0];
yin=vals[1];
zin=vals[2];
point(192.0+teller,xin);
teller++;
if (teller==800) {teller=192;}
}
Part of Arduino code. The x,y,z are double datatypes.
- //Output the caculations
Serial.print(x);
Serial.print(",");
Serial.print(y);
Serial.print(",");
Serial.println(z);
delay(10);
.......
Stable Library
=========================================
Native lib Version = RXTX-2.1-7
Java lib Version = RXTX-2.1-7
[0] "COM1"
[1] "COM4"
error, disabling serialEvent() for //./COM4
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
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.ArrayIndexOutOfBoundsException: 1
at trial2.serialEvent(trial2.java:75)
... 8 more
java.lang.NullPointerException
at processing.mode.java.runner.Runner.findException(Runner.java:682)
at processing.mode.java.runner.Runner.reportException(Runner.java:627)
at processing.mode.java.runner.Runner.exception(Runner.java:570)
at processing.mode.java.runner.EventThread.exceptionEvent(EventThread.java:367)
at processing.mode.java.runner.EventThread.handleEvent(EventThread.java:255)
at processing.mode.java.runner.EventThread.run(EventThread.java:89)
=========================================
Native lib Version = RXTX-2.1-7
Java lib Version = RXTX-2.1-7
[0] "COM1"
[1] "COM4"
error, disabling serialEvent() for //./COM4
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
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.ArrayIndexOutOfBoundsException: 1
at trial2.serialEvent(trial2.java:75)
... 8 more
java.lang.NullPointerException
at processing.mode.java.runner.Runner.findException(Runner.java:682)
at processing.mode.java.runner.Runner.reportException(Runner.java:627)
at processing.mode.java.runner.Runner.exception(Runner.java:570)
at processing.mode.java.runner.EventThread.exceptionEvent(EventThread.java:367)
at processing.mode.java.runner.EventThread.handleEvent(EventThread.java:255)
at processing.mode.java.runner.EventThread.run(EventThread.java:89)
1