O osasigbinedion Member Licensed User Longtime User Apr 21, 2015 #1 I get this error an average of 5 minutes after succesfully sending commands and receiving responses over usb. 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 anywheresoftware.b4a.objects.usb.UsbDeviceConnectionWrapper$Reader.run(UsbDeviceConnectionWrapper.java:146) at java.lang.Thread.run(Thread.java:818) In the new data sub I call continue Listening after releasing requests...any clue on what could be happening. I also see that the latest USB library is v0.97 and I have no clue where to find it.
I get this error an average of 5 minutes after succesfully sending commands and receiving responses over usb. 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 anywheresoftware.b4a.objects.usb.UsbDeviceConnectionWrapper$Reader.run(UsbDeviceConnectionWrapper.java:146) at java.lang.Thread.run(Thread.java:818) In the new data sub I call continue Listening after releasing requests...any clue on what could be happening. I also see that the latest USB library is v0.97 and I have no clue where to find it.
Erel B4X founder Staff member Licensed User Longtime User Apr 21, 2015 #2 It seems like a bug in the internal USB implementation. Attached is an updated library that catches this error. Make sure to copy it to the internal libraries folder. Attachments USB.zip USB.zip 16 KB · Views: 430 Upvote 0
It seems like a bug in the internal USB implementation. Attached is an updated library that catches this error. Make sure to copy it to the internal libraries folder.
O osasigbinedion Member Licensed User Longtime User Apr 22, 2015 #3 Thank you Erel. It seems to work with no crashing Upvote 0
O osasigbinedion Member Licensed User Longtime User Apr 29, 2015 #4 This library catches the error and doesn't pass it up. So I am stuck waiting on the NewData event which won't happen because the usb stream is broken. I would like this exception to be passed up so I can handle it and gracefully attempt a disconnect/reconnect sequence. Upvote 0
This library catches the error and doesn't pass it up. So I am stuck waiting on the NewData event which won't happen because the usb stream is broken. I would like this exception to be passed up so I can handle it and gracefully attempt a disconnect/reconnect sequence.
Erel B4X founder Staff member Licensed User Longtime User Apr 30, 2015 #5 It is not so simple to pass the error. Have you considered using a timer as a timeout mechanism? If NewData was not raised for x seconds reopen the connection. Upvote 0
It is not so simple to pass the error. Have you considered using a timer as a timeout mechanism? If NewData was not raised for x seconds reopen the connection.
O osasigbinedion Member Licensed User Longtime User Apr 30, 2015 #6 I actually did that yesterday after posting this up. Thanks Erel Upvote 0