felHR85 / UsbSerial

Usb serial controller for Android
MIT License
1.82k stars 597 forks source link

UsbSerialDevice Null Pointer #58

Open rledford opened 8 years ago

rledford commented 8 years ago

java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.nio.ByteBuffer.isDirect()' on a null object reference at android.hardware.usb.UsbRequest.dequeue(UsbRequest.java:156) at android.hardware.usb.UsbDeviceConnection.requestWait(UsbDeviceConnection.java:230) at com.felhr.usbserial.UsbSerialDevice$WorkerThread.run(UsbSerialDevice.java:213)

Line 213: UsbRequest request = UsbSerialDevice.this.connection.requestWait();

May need to null check UsbSerialDevice.this.connection != null before requestWait() is called.

This happens every once in a while if a UsbSerial device (Arduino in my case) is detached while running. I'm using the UsbSerialDevice.UsbReadCallback for reading so I could work around this issue by directly reading the interface but the callback is more convenient for my event driven applicaiton.

felHR85 commented 8 years ago

Hi @eXsolacyst This looks related to #40 I coded a solution in a branch called bug_40 Could you give it a try?

rledford commented 8 years ago

Will give it a try as soon as I can and let you know how it goes. Apologies for opening a new issue for something that's already been brought to your attention. Thanks for the awesome library btw. I really appreciate your work.

Ryan L On Jul 5, 2016 9:48 AM, "Felipe Herranz" notifications@github.com wrote:

Hi @eXsolacyst https://github.com/eXsolacyst This looks related to #40 https://github.com/felHR85/UsbSerial/issues/40 I coded a solution in a branch called bug_40 Could you give it a try?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/felHR85/UsbSerial/issues/58#issuecomment-230500204, or mute the thread https://github.com/notifications/unsubscribe/AKeL2L2tNnW5x9zVXDtZVlesHQrrTK6gks5qSm6sgaJpZM4JE8jP .