referenced PApplet with Serial.write() results in NullPointerExc.
in
Integration and Hardware
•
2 years ago
Hello!
I wrote a little app to play with the accelerometer Data from the EZ430 watch ( http://processors.wiki.ti.com/index.php/EZ430-Chronos?DCMP=Chronos&HQS=Other+OT+chronoswiki)
I wrote it with java in eclipse. My class to read the acc data works when i start it on its own (create a static main() with a new PApplet()).
However, when i try to use the class from another PApplet (where my game is at) and reference this Applet, like 95% of the time i try Serial.write() results in
java.lang.NullPointerException
at processing.serial.Serial.write(Unknown Source)
at comm.ChronosConnector$1.run(ChronosConnector.java:96)
Strangely now and then some data could be read (but only like 5%).
I guess this has something todo with Thread issues. Unfortunately i don't know how to fix this. Right now im using an extra Thread to read/write the Serial data.
Anyone got an idea how to fix this?
btw: I'm using another Serial device, too (A Polar WearLink Belt), which works fine with exactly the same structure (Extra class with extra thread to read data). However, not serial.write() but serial.bufferUntil() is used to get the data there.
Thank you,
greetings
gekko42
I wrote a little app to play with the accelerometer Data from the EZ430 watch ( http://processors.wiki.ti.com/index.php/EZ430-Chronos?DCMP=Chronos&HQS=Other+OT+chronoswiki)
I wrote it with java in eclipse. My class to read the acc data works when i start it on its own (create a static main() with a new PApplet()).
However, when i try to use the class from another PApplet (where my game is at) and reference this Applet, like 95% of the time i try Serial.write() results in
java.lang.NullPointerException
at processing.serial.Serial.write(Unknown Source)
at comm.ChronosConnector$1.run(ChronosConnector.java:96)
Strangely now and then some data could be read (but only like 5%).
I guess this has something todo with Thread issues. Unfortunately i don't know how to fix this. Right now im using an extra Thread to read/write the Serial data.
Anyone got an idea how to fix this?
btw: I'm using another Serial device, too (A Polar WearLink Belt), which works fine with exactly the same structure (Extra class with extra thread to read data). However, not serial.write() but serial.bufferUntil() is used to get the data there.
Thank you,
greetings
gekko42
1