Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AndrOBD: Null pointer exception in SerialInputOutputManager on connecting a USB device #611

Open
fr3ts0n opened this issue Dec 15, 2024 · 3 comments

Comments

@fr3ts0n
Copy link

fr3ts0n commented Dec 15, 2024

Hi, I have a problem in AndrOBD causing a NullPointerException when connecting the selected USB device:
Used versions of lib: V3.8.1, V3.8.0
Last known good version: V3.3.0

It appears to happen within the instantiation of the SerialInputOutputManager.

Here is the call stack:

java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=6, result=-1, data=Intent {  }} to activity {com.fr3ts0n.ecu.gui.androbd/com.fr3ts0n.ecu.gui.androbd.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.hardware.usb.UsbEndpoint.getMaxPacketSize()' on a null object reference
	at android.app.ActivityThread.deliverResults(ActivityThread.java:5339)
	at android.app.ActivityThread.handleSendResult(ActivityThread.java:5378)
	at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:67)
	at android.app.servertransaction.ActivityTransactionItem.execute(ActivityTransactionItem.java:45)
	at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:138)
	at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2307)
	at android.os.Handler.dispatchMessage(Handler.java:106)
	at android.os.Looper.loopOnce(Looper.java:201)
	at android.os.Looper.loop(Looper.java:288)
	at android.app.ActivityThread.main(ActivityThread.java:7924)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.hardware.usb.UsbEndpoint.getMaxPacketSize()' on a null object reference
	at com.hoho.android.usbserial.util.SerialInputOutputManager.<init>(SerialInputOutputManager.java:73)
	at com.fr3ts0n.ecu.gui.androbd.UsbCommService.setDevice(UsbCommService.java:120)
	at com.fr3ts0n.ecu.gui.androbd.UsbCommService.connect(UsbCommService.java:127)
	at com.fr3ts0n.ecu.gui.androbd.MainActivity.onActivityResult(MainActivity.java:967)
	at android.app.Activity.dispatchActivityResult(Activity.java:8665)
	at android.app.ActivityThread.deliverResults(ActivityThread.java:5332)
	at android.app.ActivityThread.handleSendResult(ActivityThread.java:5378at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:67at android.app.servertransaction.ActivityTransactionItem.execute(ActivityTransactionItem.java:45at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:138at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2307at android.os.Handler.dispatchMessage(Handler.java:106at android.os.Looper.loopOnce(Looper.java:201at android.os.Looper.loop(Looper.java:288at android.app.ActivityThread.main(ActivityThread.java:7924at java.lang.reflect.Method.invoke(Native Methodat com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936

Do you have any idea if I have to change comething in the initialisation code from V3.3.0 to V3.8.0?

Thank you very much

@kai-morich
Copy link
Collaborator

as of v3.3.2 the mReadBuffer is initialized in the SerialInputOutputManager constructor. This only works if the UsbSerialPort is already opened. I will check if the initialization can be moved to a later function.

@fr3ts0n
Copy link
Author

fr3ts0n commented Jan 7, 2025

THX. I have changed the sequence. Seems to work. :))

@kai-morich
Copy link
Collaborator

fr3ts0n/AndrOBD@8750c9b

@kai-morich kai-morich changed the title AndrOBD: Null pointer exception on connecting a USB device AndrOBD: Null pointer exception in SerialInputOutputManager on connecting a USB device Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants