{"id":245,"date":"2020-06-15T17:26:20","date_gmt":"2020-06-15T09:26:20","guid":{"rendered":"http:\/\/122.152.205.50\/wordpress\/?p=245"},"modified":"2021-01-09T13:30:29","modified_gmt":"2021-01-09T05:30:29","slug":"%e8%ae%b0%e4%b8%80%e4%b8%aa%e4%b8%b2%e5%8f%a3%e9%80%9a%e8%ae%afso%e5%ba%93%e6%ba%90%e7%a0%81","status":"publish","type":"post","link":"http:\/\/xinyiworld.top\/wordpress_it\/?p=245","title":{"rendered":"\u8bb0\u4e00\u4e2a\u4e32\u53e3\u901a\u8bafSO\u5e93\u6e90\u7801"},"content":{"rendered":"\n<p><a href=\"https:\/\/github.com\/kongqw\/AndroidSerialPort\">https:\/\/github.com\/kongqw\/AndroidSerialPort<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/github.com\/dovginka\/SerialPortLibs\">https:\/\/github.com\/dovginka\/SerialPortLibs<\/a>&nbsp;\uff08\u4eb2\u6d4b\u53ef\u7528\uff09<\/p>\n\n\n\n<p>\u6211\u7a0d\u5fae\u4f5c\u4e86\u4e00\u4e0b\u5c01\u88c5\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public\u00a0void\u00a0open(View\u00a0view){\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Log.e(TAG,\u00a0\"open:\u00a0\");\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0if(serialIoManager\u00a0==\u00a0null){\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0try\u00a0{\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0SerialUtil\u00a0serialUtil\u00a0=\u00a0SerialUtil.INIT;\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0serialUtil.init(\"dev\/ttyS3\",115200,\u00a01);\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0serialIoManager\u00a0=\u00a0new\u00a0SerialIoManager(serialUtil,\u00a0true);\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0serialIoManager.setListener(this);\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Toast.makeText(this,\u00a0\"\u6253\u5f00\u4e32\u53e3\u6210\u529f\",\u00a0Toast.LENGTH_SHORT).show();\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\u00a0catch\u00a0(Exception\u00a0e)\u00a0{\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0e.printStackTrace();\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\n\u00a0\u00a0\u00a0\u00a0}\n\u00a0\u00a0\u00a0\u00a0\n\u00a0\u00a0\u00a0\u00a0public\u00a0void\u00a0close(View\u00a0view){\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Log.e(TAG,\u00a0\"close:\u00a0\"\u00a0);\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0if(serialIoManager\u00a0!=\u00a0null){\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0serialIoManager.stopMe();\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Toast.makeText(this,\u00a0\"\u5173\u95ed\u4e32\u53e3\u6210\u529f\",\u00a0Toast.LENGTH_SHORT).show();\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\n\u00a0\u00a0\u00a0\u00a0}\n\u00a0\u00a0\u00a0\u00a0\n\u00a0\u00a0\u00a0\u00a0public\u00a0void\u00a0send(View\u00a0view){\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0String\u00a0sendData\u00a0=\u00a0et_send_data.getText().toString();\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0if(!sendData.isEmpty()){\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0try\u00a0{\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0serialIoManager.syncWrite(sendData.getBytes(\"UTF-8\"));\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Toast.makeText(this,\u00a0\"\u53d1\u9001\u6570\u636e\u6210\u529f\",\u00a0Toast.LENGTH_SHORT).show();\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\u00a0catch\u00a0(UnsupportedEncodingException\u00a0e)\u00a0{\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0e.printStackTrace();\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\n\u00a0\u00a0\u00a0\u00a0}\n\u00a0\u00a0\u00a0\u00a0\n\u00a0\u00a0\u00a0\u00a0@Override\n\u00a0\u00a0\u00a0\u00a0public\u00a0void\u00a0responseData(final\u00a0byte[]\u00a0data)\u00a0{\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0runOnUiThread(new\u00a0Runnable()\u00a0{\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0@Override\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0public\u00a0void\u00a0run()\u00a0{\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0try\u00a0{\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0tv_rec.setText(new\u00a0String(data,\"UTF-8\"));\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\u00a0catch\u00a0(UnsupportedEncodingException\u00a0e)\u00a0{\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0e.printStackTrace();\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0});\n\u00a0\u00a0\u00a0\u00a0}\n\u00a0\u00a0\u00a0\u00a0\n\u00a0\u00a0\u00a0\u00a0@Override\n\u00a0\u00a0\u00a0\u00a0public\u00a0void\u00a0sendData(byte[]\u00a0data)\u00a0{\n\u00a0\u00a0\u00a0\u00a0\n\u00a0\u00a0\u00a0\u00a0}\n\u00a0\u00a0\u00a0\u00a0\n\u00a0\u00a0\u00a0\u00a0@Override\n\u00a0\u00a0\u00a0\u00a0public\u00a0void\u00a0onRunError(Exception\u00a0e)\u00a0{\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Log.e(TAG,\u00a0\"onRunError:\u00a0\");\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Toast.makeText(this,\u00a0\"\u5f02\u5e38\uff1a\"\u00a0+\u00a0e.getMessage(),\u00a0Toast.LENGTH_SHORT).show();\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0e.printStackTrace();\n\u00a0\u00a0\u00a0\u00a0}<\/code><\/pre>\n\n\n\n<p><br><\/p>\n<button class=\"simplefavorite-button\" data-postid=\"245\" data-siteid=\"1\" data-groupid=\"1\" data-favoritecount=\"0\" style=\"\">\u6536\u85cf <i class=\"sf-icon-star-empty\"><\/i><\/button>","protected":false},"excerpt":{"rendered":"<p>https:\/\/github.com\/kongqw\/AndroidSerialPort https: [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[13],"tags":[],"_links":{"self":[{"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/posts\/245"}],"collection":[{"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=245"}],"version-history":[{"count":2,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/posts\/245\/revisions"}],"predecessor-version":[{"id":247,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/posts\/245\/revisions\/247"}],"wp:attachment":[{"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=245"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=245"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=245"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}