在新平台串口的初始化中出现Could not open serial port /dev/ttyMT2,不能打开 /dev/ttyMT2的串口节点,异常如下:
java.io.IOException: Could not open serial port /dev/ttyMT2
at android.hardware.SerialManager.openSerialPort(SerialManager.java:77)
at com.example.serial.SerialPortManager.openSerialPort(SerialPortManager.java:51)
at com.example.carservice.DataService.initSerialPort(DataService.java:256)
at com.example.carservice.DataService.onStartCommand(DataService.java:231)
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3213)
at android.app.ActivityThread.-wrap17(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1590)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:5737)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:852)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:742)
此异常由于 /dev/ttyMT2节点没有授予应用读写权限,需要驱动层赋予应用串口节点的读写权限。