消息关闭
    暂无新消息!
01-02 08:01:08.820 1653-1653/com.tech.xxx.mh D/dalvikvm: Trying to load lib /data/app-lib/com.tech.xxx.mh-2/libserial_port.so 0x41a98dd8
01-02 08:01:08.820 1653-1653/com.tech.xxx.mh D/dalvikvm: Added shared lib /data/app-lib/com.tech.xxx.mh-2/libserial_port.so 0x41a98dd8
01-02 08:01:08.820 1653-1653/com.tech.xxx.mh D/dalvikvm: No JNI_OnLoad found in /data/app-lib/com.tech.xxx.mh-2/libserial_port.so 0x41a98dd8, skipping init
01-02 08:01:08.870 1653-1653/com.tech.xxx.mh D/serial_port: Opening serial port /dev/ttyS2
01-02 08:01:08.900 1653-1653/com.tech.xxx.mh D/serial_port: open() fd = -1
01-02 08:01:08.900 1653-1653/com.tech.xxx.mh E/serial_port: Cannot open port
01-02 08:01:08.900 1653-1653/com.tech.xxx.mh E/SerialPort: native open returns null
01-02 08:01:08.900 1653-1653/com.tech.xxx.mh E/tag: 开启错误
                                                             java.io.IOException
                                                                 at com.tech.xxx.serialport.SerialPort.<init>(SerialPort.java:66)
                                                                 at com.tech.xxx.mh.LockActivity$1.onClick(LockActivity.java:40)
                                                                 at android.view.View.performClick(View.java:4438)
                                                                 at android.view.View$PerformClick.run(View.java:18422)
                                                                 at android.os.Handler.handleCallback(Handler.java:733)
                                                                 at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                 at android.os.Looper.loop(Looper.java:136)
                                                                 at android.app.ActivityThread.main(ActivityThread.java:5017)
                                                                 at java.lang.reflect.Method.invokeNative(Native Method)
                                                                 at java.lang.reflect.Method.invoke(Method.java:515)
                                                                 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
                                                                 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
                                                                 at dalvik.system.NativeStart.main(Native Method)

2个回答

︿ 1
try{
                    SerialPort sp=new SerialPort(new File("/dev/ttyS2"),115200);
                    FileOutputStream mOutputStream=(FileOutputStream) sp.getOutputStream();

                    mOutputStream.write(new String("0x31").getBytes());
                    mOutputStream.write('\n');
                } catch (Exception e){
                    Log.e("tag", "开启错误", e);
                }