USB Error With pl203

JSGoFast

New Member
Licensed User
Longtime User
Hi i have been using a pl2303 serial adapter to connect to a device and retrieve data. When i request data at a constant rate after a short time my program will crash with the message unfortunately the program has stopped. Most of the code I wrote myself except for the PL2303 initialization stuff for the adapter i took from agraham's PL2303 USB Demo (great work By the way). To try and eliminate the possibility i screwed something up with the usb setup i tried using the demo and changing as little as possible but i still get the same results. I output a one byte command to the device requesting the current data. When ever the expected amount of bytes are received the get current data command is output again. The device responds with 68 bytes and communicates at 38400 baud, only TX, RX and ground are wired to the device. I am using it on a asus transformer prime with android 4.0.3 and USB Library version 0.93. Below is the unfiltered log output from the demo i modified. I am still new to basic4android so any help figuring out this error would be greatly appreciated.

init
threadid=12: thread exiting with uncaught exception (group=0x40a661f8)
RxDataEvent total bytes = 5576
FATAL EXCEPTION: Thread-595
java.lang.NullPointerException
at android.hardware.usb.UsbRequest.dequeue(UsbRequest.java:155)
at android.hardware.usb.UsbDeviceConnection.requestWait(UsbDeviceConnection.java:156)
at anywheresoftware.b4a.objects.usb.UsbDeviceConnectionWrapper$Reader.run(UsbDeviceConnectionWrapper.java:146)
at java.lang.Thread.run(Thread.java:856)
Force finishing activity anywheresoftware.b4a.agraham.usbpl2303/.main
RxDataEvent total bytes = 5640
 
Last edited:

JSGoFast

New Member
Licensed User
Longtime User
Thanks for the help in the demo I moved Continuelistening from being called in the NewData event to being called right after request.Queue and it appears to have fixed my crashing issue. I was doing the same thing in my code since i could not find much information on how to correctly use Continuelistening.

To figure out what is causing the error do you have to look through the library jar file? I'm trying to determine how i could locate the cause of an error like this on my own, if I come across something like this again.
 
Upvote 0
Top