|
最近在写android的一个硬件驱动遇到问题
我写了android的apk测试程序,编译成.so的c库,以及硬件驱动,基本情况是apk加载so,通过JNI调用so中的方法,so中方法去访问/dev/下的硬件,访问硬件主要是read方法,驱动中的read函数设计为如果当前没数据则会睡眠
问题在于运行apk测试程序,打开设备正常,调用read时,也能进入睡眠,但是数据到达后,apk程序错误,出错为binder 1858:1864 transaction failed 29189 size 52-0,android的logcat日志为
04-25 04:45:01.989 W/dalvikvm( 2047): threadid=17: thread exiting with uncaught exception (group=0x4000fe68)
04-25 04:45:01.989 E/AndroidRuntime( 2047): Uncaught handler: thread Thread-10 exiting due to uncaught exception
04-25 04:45:02.009 E/AndroidRuntime( 2047): android.view.ViewRoot$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
04-25 04:45:02.009 E/AndroidRuntime( 2047): at android.view.ViewRoot.checkThread(ViewRoot.java:2354)
04-25 04:45:02.009 E/AndroidRuntime( 2047): at android.view.ViewRoot.invalidateChild(ViewRoot.java:507)
04-25 04:45:02.009 E/AndroidRuntime( 2047): at android.view.ViewRoot.invalidateChildInParent(ViewRoot.java:525)
04-25 04:45:02.009 E/AndroidRuntime( 2047): at android.view.ViewGroup.invalidateChild(ViewGroup.java:2283)
04-25 04:45:02.009 E/AndroidRuntime( 2047): at android.view.View.invalidate(View.java:4317)
04-25 04:45:02.009 E/AndroidRuntime( 2047): at android.widget.TextView.checkForRelayout(TextView.java:4449)
04-25 04:45:02.009 E/AndroidRuntime( 2047): at android.widget.TextView.setText(TextView.java:2506)
04-25 04:45:02.009 E/AndroidRuntime( 2047): at android.widget.TextView.setText(TextView.java:2376)
04-25 04:45:02.009 E/AndroidRuntime( 2047): at android.widget.TextView.setText(TextView.java:2352)
04-25 04:45:02.009 E/AndroidRuntime( 2047): at com.tobacco.test.bs.BarcodeScannerTest$1$1.run(BarcodeScannerTest.java:51)
04-25 04:45:02.009 E/AndroidRuntime( 2047): at java.lang.Thread.run(Thread.java:1058)
04-25 04:45:02.019 I/Process ( 1858): Sending signal. PID: 2047 SIG: 3
04-25 04:45:02.024 I/dalvikvm( 2047): threadid=7: reacting to signal 3
04-25 04:45:02.064 I/dalvikvm( 2047): Wrote stack trace to '/data/anr/traces.txt'
04-25 04:45:02.219 W/InputManagerService( 1858): Ignoring focus gain of: android.view.inputmethod.InputMethodManager$1@437d0040
04-25 04:45:11.419 I/Process ( 2047): Sending signal. PID: 2047 SIG: 9
04-25 04:45:11.429 I/ActivityManager( 1858): Process com.tobacco.test.bs (pid 2047) has died.
但驱动程序中read函数在copy_to_user前能打印出获得的数据。
我写了一个c程序来单独测试驱动,没问题,能从硬件得到数据
我又改so的方法,不访问硬件,直接返回一个字符串,apk调用so也是没有问题。
求解答~
另外,有谁知道android下的C库里使用printf的话,会输出到android下哪个日志文件中?
|
|