Pages: [1]   Go Down
Author Topic: DUE and nightly build 1.5.6 beta  (Read 551 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 37
Arduino is fun
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

i can compile, upload my project,
and when i start terminal it stops after the first output line
and i see error
Code:
Exception in thread "EventThread COM12" java.lang.NullPointerException
at processing.app.Serial.serialEvent(Serial.java:176)
at jssc.SerialPort$EventThread.run(SerialPort.java:1096)
back to 1.5.5 r2 ?fix? OK
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It happens to me, too, with Arduino Uno or Mega, in Windows 7 and 8.1 64 bits, just by opening the Serial Monitor.

As the exception indicates, the problem is in the Serial.serialEvent method, when reading the serial port. So if you look at the code in the GitHub repo:

Code:
public synchronized void serialEvent(SerialPortEvent serialEvent) {
    if (serialEvent.isRXCHAR()) {
      try {
        byte[] buf = port.readBytes();
        if (buf.length > 0) {
...
      

as port.readBytes() may return null.

I've tested this outside Arduino IDE, running a simple Java sample with the JSSC library, 2.8.0, and I had the same problem.

An easy solution could be just checking that buf is not null:

Code:
public synchronized void serialEvent(SerialPortEvent serialEvent) {
    if (serialEvent.isRXCHAR()) {
      try {
        byte[] buf = port.readBytes();
        if (buf!=null && buf.length > 0) {
...
      

Shall I open an Issue on GitHub with this?

Edit: I opened issue #1885, and it's already fixed now! So try the new nightly build, the NPE should not appear anymore.

Jose
« Last Edit: February 21, 2014, 06:31:20 am by jperedadnr » Logged

Pages: [1]   Go Up
Jump to: