我有示例应用程序可从here的串行端口读取。
我已将设备设置为ttyUSB1(usbserial)
并将波特率设置为9600
。
但是当我单击控制台时,我得到Error: You do not have read/write permission to the serial port
我的logcat是
08-22 15:01:25.210: W/System.err(14524): java.io.IOException: Error running exec(). Command:
[/system/bin/su] Working Directory: null Environment: null
08-22 15:01:25.210: W/System.err(14524): at
java.lang.ProcessManager.exec(ProcessManager.java:211)
08-22 15:01:25.211: W/System.err(14524): at java.lang.Runtime.exec(Runtime.java:168)
08-22 15:01:25.211: W/System.err(14524): at java.lang.Runtime.exec(Runtime.java:241)
08-22 15:01:25.212: W/System.err(14524): at java.lang.Runtime.exec(Runtime.java:184)
08-22 15:01:25.212: W/System.err(14524): at android_serialport_api.SerialPort.<init>
(SerialPort.java:47)
08-22 15:01:25.212: W/System.err(14524): at
android_serialport_api.sample.Application.getSerialPort(Application.java:46)
08-22 15:01:25.213: W/System.err(14524): at
android_serialport_api.sample.SerialPortActivity.onCreate(SerialPortActivity.java:78)
08-22 15:01:25.213: W/System.err(14524): at
android_serialport_api.sample.Sending01010101Activity.onCreate(Sending01010101Activity.java:31)
08-22 15:01:25.214: W/System.err(14524): at
android.app.Activity.performCreate(Activity.java:5020)
08-22 15:01:25.214: W/System.err(14524): at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
08-22 15:01:25.214: W/System.err(14524): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
08-22 15:01:25.214: W/System.err(14524): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2211)
08-22 15:01:25.215: W/System.err(14524): at
android.app.ActivityThread.access$600(ActivityThread.java:149)
08-22 15:01:25.215: W/System.err(14524): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1300)
08-22 15:01:25.215: W/System.err(14524): at
android.os.Handler.dispatchMessage(Handler.java:99)
08-22 15:01:25.216: W/System.err(14524): at android.os.Looper.loop(Looper.java:153)
08-22 15:01:25.216: W/System.err(14524): at
android.app.ActivityThread.main(ActivityThread.java:4987)
08-22 15:01:25.216: W/System.err(14524): at java.lang.reflect.Method.invokeNative(Native
Method)
08-22 15:01:25.216: W/System.err(14524): at java.lang.reflect.Method.invoke(Method.java:511)
08-22 15:01:25.217: W/System.err(14524): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:821)
08-22 15:01:25.217: W/System.err(14524): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)
08-22 15:01:25.217: W/System.err(14524): at dalvik.system.NativeStart.main(Native Method)
08-22 15:01:25.217: W/System.err(14524): Caused by: java.io.IOException: No such file or
directory
08-22 15:01:25.218: W/System.err(14524): at java.lang.ProcessManager.exec(Native Method)
08-22 15:01:25.219: W/System.err(14524): at
java.lang.ProcessManager.exec(ProcessManager.java:209)
08-22 15:01:25.219: W/System.err(14524): ... 21 more
我该如何解决。
请帮助解决此问题。
最佳答案
如果您使用的是串行端口应用程序,请转到文件SerialPort.java
换行:
su = Runtime.getRuntime().exec("/system/bin/su");
至
su = Runtime.getRuntime().exec("/system/xbin/su");
关于android - 错误:您没有对串行端口的读/写权限,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/25443779/