{"id":11909,"date":"2023-03-17T14:04:31","date_gmt":"2023-03-17T06:04:31","guid":{"rendered":"https:\/\/www.linuxcool.com\/qsjjcktxntlc"},"modified":"2023-03-17T14:04:31","modified_gmt":"2023-03-17T06:04:31","slug":"qsjjcktxntlc","status":"publish","type":"post","link":"https:\/\/www.linuxcool.com\/qsjjcktxntlc","title":{"rendered":"\u8f7b\u677e\u89e3\u51b3\u4e32\u53e3\u901a\u4fe1\u96be\u9898\uff0cLinux\u4e32\u53e3\u6d4b\u8bd5\u547d\u4ee4\u52a9\u4f60\u4e00\u81c2\u4e4b\u529b\uff01"},"content":{"rendered":"<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\u968f\u7740\u6280\u672f\u7684\u4e0d\u65ad\u53d1\u5c55\uff0c\u4e32\u53e3\u901a\u4fe1\u5728\u5de5\u4e1a\u81ea\u52a8\u5316\u3001\u7269\u8054\u7f51\u3001\u667a\u80fd\u5bb6\u5c45\u7b49\u9886\u57df\u5f97\u5230\u4e86\u5e7f\u6cdb\u5e94\u7528\u3002\u4f46\u662f\uff0c\u5728\u8fdb\u884c\u4e32\u53e3\u901a\u4fe1\u65f6\uff0c\u7ecf\u5e38\u4f1a\u9047\u5230\u5404\u79cd\u95ee\u9898linux makefile\uff0c\u5982\u4e32\u53e3\u8bbe\u7f6e\u9519\u8bef\u3001\u6570\u636e\u4f20\u8f93\u5f02\u5e38\u7b49\u3002\u8fd9\u65f6\uff0c\u6211\u4eec\u5c31\u9700\u8981\u4e00\u6b3e\u5f3a\u5927\u7684\u5de5\u5177\u6765\u5e2e\u52a9\u6211\u4eec\u8fdb\u884c\u8c03\u8bd5\u548c\u6d4b\u8bd5\u3002\u672c\u6587\u5c06\u4ecb\u7ecd\u4e00\u6b3e<a style='color:#0000CC' href='https:\/\/www.linuxprobe.com\/' target='_blank' rel=\"noopener\">Linux<\/a>\u4e32\u53e3\u6d4b\u8bd5<a style='color:#0000CC' href='https:\/\/www.linuxcool.com\/' target='_blank' rel=\"noopener\">\u547d\u4ee4<\/a>\uff0c\u8ba9\u4f60\u8f7b\u677e\u89e3\u51b3\u4e32\u53e3\u901a\u4fe1\u96be\u9898\u3002<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>1.\u786e\u8ba4\u4e32\u53e3\u8bbe\u5907<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\u5728\u4f7f\u7528Linux\u4e32\u53e3\u6d4b\u8bd5\u547d\u4ee4\u4e4b\u524d\uff0c\u9700\u8981\u5148\u786e\u8ba4\u7535\u8111\u4e0a\u7684\u4e32\u53e3\u8bbe\u5907\u540d\u79f0\u3002\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u67e5\u770b\uff1a<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\n<pre>\n$ dmesg | grep tty\n<\/pre>\n<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>2.\u8bbe\u7f6e\u4e32\u53e3\u53c2\u6570<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\u5728\u8fdb\u884c\u4e32\u53e3\u901a\u4fe1\u524d\uff0c\u9700\u8981\u8bbe\u7f6e\u597d\u76f8\u5e94\u7684\u53c2\u6570\uff0c\u5305\u62ec\u6ce2\u7279\u7387\u3001\u6570\u636e\u4f4d\u3001\u6821\u9a8c\u4f4d\u548c\u505c\u6b62\u4f4d\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u8fdb\u884c\u8bbe\u7f6e\uff1a<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\n<pre>\n$ stty -F\/dev\/ttyS0 115200 cs8 -parenb -cstopb\n<\/pre>\n<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\u5176\u4e2d<strong>linux\u4e32\u53e3\u6d4b\u8bd5\u547d\u4ee4<\/strong>\uff0c&ldquo;-F&rdquo;\u8868\u793a\u6253\u5f00\u6307\u5b9a\u7684\u8bbe\u5907\uff0c&ldquo;115200&rdquo;\u8868\u793a\u6ce2\u7279\u7387\u4e3a115200linux\u662f\u4ec0\u4e48\uff0c&ldquo;cs8&rdquo;\u8868\u793a\u6570\u636e\u4f4d\u4e3a8\uff0c&ldquo;-parenb&rdquo;\u8868\u793a\u4e0d\u4f7f\u7528\u5947\u5076\u6821\u9a8c<strong>linux\u4e32\u53e3\u6d4b\u8bd5\u547d\u4ee4<\/strong>\uff0c&ldquo;-cstopb&rdquo;\u8868\u793a\u505c\u6b62\u4f4d\u4e3a1\u3002<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>3.\u53d1\u9001\u6570\u636e<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u53ef\u4ee5\u5411\u4e32\u53e3\u53d1\u9001\u6570\u636e\uff1a<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\n<pre>\n$ echo &quot;hello&quot;&gt;\/dev\/ttyS0\n<\/pre>\n<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\u5176\u4e2d\uff0c&ldquo;hello&rdquo;\u4e3a\u9700\u8981\u53d1\u9001\u7684\u6570\u636e\u3002<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>4.\u63a5\u6536\u6570\u636e<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u53ef\u4ee5\u4ece\u4e32\u53e3\u63a5\u6536\u6570\u636e\uff1a<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\n<pre>\n$ cat \/dev\/ttyS0\n<\/pre>\n<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>5.\u76d1\u542c\u4e32\u53e3<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u53ef\u4ee5\u5b9e\u65f6\u76d1\u542c\u4e32\u53e3\uff0c\u5e76\u5c06\u63a5\u6536\u5230\u7684\u6570\u636e\u8f93\u51fa\u5230\u7ec8\u7aef\uff1a<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\n<pre>\n$ minicom -D\/dev\/ttyS0\n<\/pre>\n<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>6.\u6d4b\u8bd5\u4e32\u53e3\u8fde\u63a5<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u53ef\u4ee5\u6d4b\u8bd5\u4e24\u4e2a\u8bbe\u5907\u4e4b\u95f4\u662f\u5426\u6210\u529f\u5efa\u7acb\u4e86\u8fde\u63a5\uff1a<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\n<pre>\n$ echo &quot;hello&quot;&gt;\/dev\/ttyS0 &amp; cat \/dev\/ttyS0\n<\/pre>\n<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\u5176\u4e2d\uff0c&ldquo;&amp;&rdquo;\u8868\u793a\u540c\u65f6\u6267\u884c\u4e24\u4e2a\u547d\u4ee4\u3002<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>7.\u5206\u6790\u4f20\u8f93\u6570\u636e<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u53ef\u4ee5\u5206\u6790\u4f20\u8f93\u8fc7\u7a0b\u4e2d\u7684\u6570\u636e\uff1a<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\n<pre>\n$ stty -F\/dev\/ttyS0 -a| grep speed\n$ hexdump -C\/dev\/ttyS0 | grep &quot;55 aa&quot;\n<\/pre>\n<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\u7b2c\u4e00\u4e2a\u547d\u4ee4\u7528\u4e8e\u67e5\u770b\u4f20\u8f93\u901f\u5ea6\u7b49\u53c2\u6570\uff0c\u7b2c\u4e8c\u4e2a\u547d\u4ee4\u7528\u4e8e\u67e5\u770b\u4f20\u8f93\u8fc7\u7a0b\u4e2d\u7684\u5341\u516d\u8fdb\u5236\u6570\u636e\u3002<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>8.\u4f7f\u7528Python\u8fdb\u884c\u6d4b\u8bd5<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\u9664\u4e86\u4ee5\u4e0a\u547d\u4ee4\u5916\uff0c\u8fd8\u53ef\u4ee5\u4f7f\u7528Python\u8fdb\u884c\u4e32\u53e3\u6d4b\u8bd5\u3002\u8fd9\u91cc\u63d0\u4f9b\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\u4ee3\u7801\uff1a<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\n<pre>python\nimport serial\nser = serial.Serial('\/dev\/ttyS0', 115200, timeout=1)\nser.write(b'hello')\ndata = ser.read(10)\nprint(data)\nser.close()\n<\/pre>\n<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>9.\u603b\u7ed3<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\u672c\u6587\u4ecb\u7ecd\u4e86Linux\u4e0b\u5e38\u7528\u7684\u4e32\u53e3\u6d4b\u8bd5\u547d\u4ee4\uff0c\u5e76\u901a\u8fc7\u793a\u4f8b\u4ee3\u7801\u6f14\u793a\u4e86\u5982\u4f55\u4f7f\u7528Python\u8fdb\u884c\u6d4b\u8bd5\u3002\u638c\u63e1\u8fd9\u4e9b\u6280\u5de7\u540e\uff0c\u5728\u8fdb\u884c\u4e32\u53e3\u901a\u4fe1\u65f6\u5c31\u80fd\u66f4\u52a0\u9ad8\u6548\u5730\u8c03\u8bd5\u548c\u6d4b\u8bd5\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4f46\u662f\uff0c\u5728\u8fdb\u884c\u4e32\u53e3\u901a\u4fe1\u65f6\uff0c\u7ecf\u5e38\u4f1a\u9047\u5230\u5404\u79cd\u95ee\u9898\uff0c\u5982\u4e32\u53e3\u8bbe\u7f6e\u9519\u8bef\u3001\u6570\u636e\u4f20\u8f93\u5f02\u5e38\u7b49\u3002\u672c\u6587\u5c06\u4ecb\u7ecd\u4e00\u6b3eLinux\u4e32\u53e3\u6d4b\u8bd5\u547d\u4ee4\uff0c\u8ba9\u4f60\u8f7b\u677e\u89e3\u51b3\u4e32\u53e3\u901a\u4fe1\u96be\u9898\u3002\u5728\u4f7f\u7528Linux\u4e32\u53e3\u6d4b\u8bd5\u547d\u4ee4\u4e4b\u524d\uff0c\u9700\u8981\u5148\u786e\u8ba4\u7535\u8111\u4e0a\u7684\u4e32\u53e3\u8bbe\u5907\u540d\u79f0\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u53ef\u4ee5\u4ece\u4e32\u53e3\u63a5\u6536\u6570\u636e\uff1a\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u53ef\u4ee5\u5206\u6790\u4f20\u8f93\u8fc7\u7a0b\u4e2d\u7684\u6570\u636e\uff1a\u9664\u4e86\u4ee5\u4e0a\u547d\u4ee4\u5916\uff0c\u8fd8\u53ef\u4ee5\u4f7f\u7528Python\u8fdb\u884c\u4e32\u53e3\u6d4b\u8bd5\u3002\u638c\u63e1\u8fd9\u4e9b\u6280\u5de7\u540e\uff0c\u5728\u8fdb\u884c\u4e32\u53e3\u901a\u4fe1\u65f6\u5c31\u80fd\u66f4\u52a0\u9ad8\u6548\u5730\u8c03\u8bd5\u548c\u6d4b\u8bd5\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[264,23,437,435,436],"class_list":["post-11909","post","type-post","status-publish","format-standard","hentry","category-knowledge","tag-d-9","tag-lxt","tag-pck","tag-cktx","tag-tx"],"_links":{"self":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts\/11909","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/comments?post=11909"}],"version-history":[{"count":0,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts\/11909\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/media?parent=11909"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/categories?post=11909"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/tags?post=11909"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}