android - 错误 : You do not have read/write permission to the serial port

标签 android serial-port

我有示例应用程序可以从 here 的串口读取.

我已将设备设置为 ttyUSB1(usbserial) 并将波特率设置为 9600

但是当我点击控制台时,我得到了错误:您没有串行端口的读/写权限

我的日志是

  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 - 错误 : You do not have read/write permission to the serial port,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25443779/

相关文章:

C语言,串口阅读器

Android 应用程序使用大量 RAM 的原因以及如何减少

Android 在 Sqlite 中按 Id 选择行?

当串行设备的路径改变时,C 程序停止

java - 将使用Processing.org制作的应用程序迁移到Eclipse

python - MacPython : programmatically finding all serial ports

C# Winform 在 SerialPort.Close 上卡住

android - 引用属性枚举值

java - 如何动态添加可绘制对象到 TextView

android - 使用 android 访问 picasa