logo

ch340g 芯片 在安卓上的使用问题 咨询

下载官方的apk demo, 插入ch340g的板子 系统会提示运行,这个时候后续 操作是正常的,包括打开、关闭和读写。 不正常的是:如果安卓重启,再次运行demo的时候,注意板子没有插入动作,这时候app就会报错,请问有什么办法可以解决这种情况呢? 谢谢。

这人很懒,什么都没留下

问题同上:官方demo,USB一直插在安卓上,打开APP,报错。查看日志为:

08-24 07:47:54.336: I/art(4208): Not late-enabling -Xcheck:jni (already on)
08-24 07:47:54.677: D/CH34xAndroidDriver(4208): String.format not match
08-24 07:47:54.677: D/CH34xAndroidDriver(4208): String.format not match
08-24 07:47:54.678: D/CH34xAndroidDriver(4208): String.format not match
08-24 07:47:54.678: D/CH34xAndroidDriver(4208): String.format not match
08-24 07:47:54.678: D/CH34xAndroidDriver(4208): String.format not match
08-24 07:47:54.678: D/CH34xAndroidDriver(4208): String.format not match
08-24 07:47:54.678: D/CH34xAndroidDriver(4208): String.format not match
08-24 07:47:54.681: D/AndroidRuntime(4208): Shutting down VM
08-24 07:47:54.688: E/AndroidRuntime(4208): FATAL EXCEPTION: main
08-24 07:47:54.688: E/AndroidRuntime(4208): Process: com.example.c6zdh, PID: 4208
08-24 07:47:54.688: E/AndroidRuntime(4208): java.lang.RuntimeException: Unable to create application com.example.c6zdh.MyAppLication: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.hardware.usb.UsbDeviceConnection.controlTransfer(int, int, int, int, byte[], int, int)' on a null object reference
08-24 07:47:54.688: E/AndroidRuntime(4208):  at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4521)
08-24 07:47:54.688: E/AndroidRuntime(4208):  at android.app.ActivityThread.access$1500(ActivityThread.java:144)
08-24 07:47:54.688: E/AndroidRuntime(4208):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1339)
08-24 07:47:54.688: E/AndroidRuntime(4208):  at android.os.Handler.dispatchMessage(Handler.java:102)
08-24 07:47:54.688: E/AndroidRuntime(4208):  at android.os.Looper.loop(Looper.java:135)
08-24 07:47:54.688: E/AndroidRuntime(4208):  at android.app.ActivityThread.main(ActivityThread.java:5221)
08-24 07:47:54.688: E/AndroidRuntime(4208):  at java.lang.reflect.Method.invoke(Native Method)
08-24 07:47:54.688: E/AndroidRuntime(4208):  at java.lang.reflect.Method.invoke(Method.java:372)
08-24 07:47:54.688: E/AndroidRuntime(4208):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
08-24 07:47:54.688: E/AndroidRuntime(4208):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
08-24 07:47:54.688: E/AndroidRuntime(4208): Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.hardware.usb.UsbDeviceConnection.controlTransfer(int, int, int, int, byte[], int, int)' on a null object reference
08-24 07:47:54.688: E/AndroidRuntime(4208):  at cn.wch.ch34xuartdriver.CH34xUARTDriver.a(Unknown Source)
08-24 07:47:54.688: E/AndroidRuntime(4208):  at cn.wch.ch34xuartdriver.CH34xUARTDriver.UartInit(Unknown Source)
08-24 07:47:54.688: E/AndroidRuntime(4208):  at com.example.c6zdh.MyAppLication.initUSB(MyAppLication.java:62)
08-24 07:47:54.688: E/AndroidRuntime(4208):  at com.example.c6zdh.MyAppLication.onCreate(MyAppLication.java:31)
08-24 07:47:54.688: E/AndroidRuntime(4208):  at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1011)
08-24 07:47:54.688: E/AndroidRuntime(4208):  at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4518)
08-24 07:47:54.688: E/AndroidRuntime(4208):  ... 9 more


                           

问题同上:官方demo,USB一直插在安卓上,打开APP,报错。查看日志为:

08-24 07:47:54.336: I/art(4208): Not late-enabling -Xcheck:jni (already on)
08-24 07:47:54.677: D/CH34xAndroidDriver(4208): String.format not match
08-24 07:47:54.677: D/CH34xAndroidDriver(4208): String.format not match
08-24 07:47:54.678: D/CH34xAndroidDriver(4208): String.format not match
08-24 07:47:54.678: D/CH34xAndroidDriver(4208): String.format not match
08-24 07:47:54.678: D/CH34xAndroidDriver(4208): String.format not match
08-24 07:47:54.678: D/CH34xAndroidDriver(4208): String.format not match
08-24 07:47:54.678: D/CH34xAndroidDriver(4208): String.format not match
08-24 07:47:54.681: D/AndroidRuntime(4208): Shutting down VM
08-24 07:47:54.688: E/AndroidRuntime(4208): FATAL EXCEPTION: main
08-24 07:47:54.688: E/AndroidRuntime(4208): Process: com.example.c6zdh, PID: 4208
08-24 07:47:54.688: E/AndroidRuntime(4208): java.lang.RuntimeException: Unable to create application com.example.c6zdh.MyAppLication: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.hardware.usb.UsbDeviceConnection.controlTransfer(int, int, int, int, byte[], int, int)' on a null object reference
08-24 07:47:54.688: E/AndroidRuntime(4208):  at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4521)
08-24 07:47:54.688: E/AndroidRuntime(4208):  at android.app.ActivityThread.access$1500(ActivityThread.java:144)
08-24 07:47:54.688: E/AndroidRuntime(4208):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1339)
08-24 07:47:54.688: E/AndroidRuntime(4208):  at android.os.Handler.dispatchMessage(Handler.java:102)
08-24 07:47:54.688: E/AndroidRuntime(4208):  at android.os.Looper.loop(Looper.java:135)
08-24 07:47:54.688: E/AndroidRuntime(4208):  at android.app.ActivityThread.main(ActivityThread.java:5221)
08-24 07:47:54.688: E/AndroidRuntime(4208):  at java.lang.reflect.Method.invoke(Native Method)
08-24 07:47:54.688: E/AndroidRuntime(4208):  at java.lang.reflect.Method.invoke(Method.java:372)
08-24 07:47:54.688: E/AndroidRuntime(4208):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
08-24 07:47:54.688: E/AndroidRuntime(4208):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
08-24 07:47:54.688: E/AndroidRuntime(4208): Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.hardware.usb.UsbDeviceConnection.controlTransfer(int, int, int, int, byte[], int, int)' on a null object reference
08-24 07:47:54.688: E/AndroidRuntime(4208):  at cn.wch.ch34xuartdriver.CH34xUARTDriver.a(Unknown Source)
08-24 07:47:54.688: E/AndroidRuntime(4208):  at cn.wch.ch34xuartdriver.CH34xUARTDriver.UartInit(Unknown Source)
08-24 07:47:54.688: E/AndroidRuntime(4208):  at com.example.c6zdh.MyAppLication.initUSB(MyAppLication.java:62)
08-24 07:47:54.688: E/AndroidRuntime(4208):  at com.example.c6zdh.MyAppLication.onCreate(MyAppLication.java:31)
08-24 07:47:54.688: E/AndroidRuntime(4208):  at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1011)
08-24 07:47:54.688: E/AndroidRuntime(4208):  at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4518)
08-24 07:47:54.688: E/AndroidRuntime(4208):  ... 9 more

                       

您好:

    尝试使用一下,如下链接中的APP,看下使用结果。

    CH341SER_ANDROID.ZIP下载页面-江苏沁恒股份有限公司

    http://www.wch.cn/download/CH341SER_ANDROID_ZIP.html



引用:

                           

问题同上:官方demo,USB一直插在安卓上,打开APP,报错。查看日志为:

08-24 07:47:54.336: I/art(4208): Not late-enabling -Xcheck:jni (already on)
08-24 07:47:54.677: D/CH34xAndroidDriver(4208): String.format not match
08-24 07:47:54.677: D/CH34xAndroidDriver(4208): String.format not match
08-24 07:47:54.678: D/CH34xAndroidDriver(4208): String.format not match
08-24 07:47:54.678: D/CH34xAndroidDriver(4208): String.format not match
08-24 07:47:54.678: D/CH34xAndroidDriver(4208): String.format not match
08-24 07:47:54.678: D/CH34xAndroidDriver(4208): String.format not match
08-24 07:47:54.678: D/CH34xAndroidDriver(4208): String.format not match
08-24 07:47:54.681: D/AndroidRuntime(4208): Shutting down VM
08-24 07:47:54.688: E/AndroidRuntime(4208): FATAL EXCEPTION: main
08-24 07:47:54.688: E/AndroidRuntime(4208): Process: com.example.c6zdh, PID: 4208
08-24 07:47:54.688: E/AndroidRuntime(4208): java.lang.RuntimeException: Unable to create application com.example.c6zdh.MyAppLication: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.hardware.usb.UsbDeviceConnection.controlTransfer(int, int, int, int, byte[], int, int)' on a null object reference
08-24 07:47:54.688: E/AndroidRuntime(4208):  at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4521)
08-24 07:47:54.688: E/AndroidRuntime(4208):  at android.app.ActivityThread.access$1500(ActivityThread.java:144)
08-24 07:47:54.688: E/AndroidRuntime(4208):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1339)
08-24 07:47:54.688: E/AndroidRuntime(4208):  at android.os.Handler.dispatchMessage(Handler.java:102)
08-24 07:47:54.688: E/AndroidRuntime(4208):  at android.os.Looper.loop(Looper.java:135)
08-24 07:47:54.688: E/AndroidRuntime(4208):  at android.app.ActivityThread.main(ActivityThread.java:5221)
08-24 07:47:54.688: E/AndroidRuntime(4208):  at java.lang.reflect.Method.invoke(Native Method)
08-24 07:47:54.688: E/AndroidRuntime(4208):  at java.lang.reflect.Method.invoke(Method.java:372)
08-24 07:47:54.688: E/AndroidRuntime(4208):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
08-24 07:47:54.688: E/AndroidRuntime(4208):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
08-24 07:47:54.688: E/AndroidRuntime(4208): Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.hardware.usb.UsbDeviceConnection.controlTransfer(int, int, int, int, byte[], int, int)' on a null object reference
08-24 07:47:54.688: E/AndroidRuntime(4208):  at cn.wch.ch34xuartdriver.CH34xUARTDriver.a(Unknown Source)
08-24 07:47:54.688: E/AndroidRuntime(4208):  at cn.wch.ch34xuartdriver.CH34xUARTDriver.UartInit(Unknown Source)
08-24 07:47:54.688: E/AndroidRuntime(4208):  at com.example.c6zdh.MyAppLication.initUSB(MyAppLication.java:62)
08-24 07:47:54.688: E/AndroidRuntime(4208):  at com.example.c6zdh.MyAppLication.onCreate(MyAppLication.java:31)
08-24 07:47:54.688: E/AndroidRuntime(4208):  at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1011)
08-24 07:47:54.688: E/AndroidRuntime(4208):  at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4518)
08-24 07:47:54.688: E/AndroidRuntime(4208):  ... 9 more


                       

 

您好:

    尝试使用一下,如下链接中的APP,看下使用结果。

    CH341SER_ANDROID.ZIP下载页面-江苏沁恒股份有限公司

    http://www.wch.cn/download/CH341SER_ANDROID_ZIP.html


 

使用官方的APP,重新插拔USB,发现一直弹出未授权权限。

 


有没有更换过手机,如果一直不弹出权限,可能是当前系统没有使能 usb host 造成的。


有没有更换过手机,如果一直不弹出权限,可能是当前系统没有使能 usb host 造成的。

 

没更换过,我们使用的是友善之臂的4412的开发板,问题是和LZ提到的一样,重新开机后,USB必须要重新插拔一次才可以使用!

http://www.arm9.net/tiny4412.asp


有没有更换过手机,如果一直不弹出权限,可能是当前系统没有使能 usb host 造成的。

 

Android系统支持usb host,我是这么确认支持的,外接无线鼠标和键盘,都OK可以使用


                           


引用:

有没有更换过手机,如果一直不弹出权限,可能是当前系统没有使能 usb host 造成的。


 

Android系统支持usb host,我是这么确认支持的,外接无线鼠标和键盘,都OK可以使用

                       

您好:

    这样是只能确保支持OTG,也即USB主机功能,不能保证手机上的Host API support 功能打开,可以参考下列博客:http://blog.csdn.net/jazzsoldier/article/details/71097697



我按照教程查看微信截图_20171013150227.png

其中哪一条是可以证明的Host API support 功能打开,劳烦大神了


                           

我按照教程查看微信截图_20171013150227.png

其中哪一条是可以证明的Host API support 功能打开,劳烦大神了

                       

使用步骤一推荐的APK:USB主机诊断,或者按照步骤二的说明:进入/system/lib ,查看是否有驱动 libusbhost.so


只有登录才能回复,可以选择微信和github账号登录