{"id":42152,"date":"2023-09-30T14:54:37","date_gmt":"2023-09-30T06:54:37","guid":{"rendered":"\/\/www.viralrail.com\/?p=42152"},"modified":"2023-09-30T15:01:38","modified_gmt":"2023-09-30T07:01:38","slug":"zklcksfky","status":"publish","type":"post","link":"\/\/www.viralrail.com\/blog\/42152.html","title":{"rendered":"\u67e5\u770bLinux\u4e32\u53e3\u662f\u5426\u53ef\u7528"},"content":{"rendered":"
\u5728Linux\u7cfb\u7edf\u4e2d\uff0c\u4e32\u53e3\u662f\u4e00\u79cd\u5e38\u89c1\u7684\u6570\u636e\u4f20\u8f93\u63a5\u53e3\uff0c\u5b83\u53ef\u4ee5\u7528\u6765\u8fde\u63a5\u7535\u8111\u548c\u5176\u4ed6\u5916\u90e8\u8bbe\u5907\uff0c\u5b9e\u73b0\u5916\u90e8\u8bbe\u5907\u548c\u7535\u8111\u4e4b\u95f4\u7684\u6570\u636e\u4f20\u8f93\u3002\u672c\u6587\u5c06\u4ecb\u7ecd\u5982\u4f55\u67e5\u770bLinux\u7cfb\u7edf\u4e2d\u7684\u4e32\u53e3\u662f\u5426\u53ef\u7528\uff0c\u4ee5\u53ca\u5982\u4f55\u4f7f\u7528\u4e32\u53e3\u8fdb\u884c\u6570\u636e\u4f20\u8f93\u3002<\/p>\n
\u9996\u5148\uff0c\u6211\u4eec\u9700\u8981\u786e\u5b9aLinux\u7cfb\u7edf\u4e2d\u7684\u4e32\u53e3\u662f\u5426\u53ef\u7528\u3002\u5728Linux\u7cfb\u7edf\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528dmesg\u547d\u4ee4\u67e5\u770b\u4e32\u53e3\u662f\u5426\u53ef\u7528\uff0c\u8fd9\u4e2a\u547d\u4ee4\u53ef\u4ee5\u67e5\u770b\u7cfb\u7edf\u542f\u52a8\u65f6\u7684\u4fe1\u606f\uff0c\u5176\u4e2d\u5305\u62ec\u4e32\u53e3\u7684\u4fe1\u606f\u3002<\/p>\n
\u8981\u67e5\u770bLinux\u7cfb\u7edf\u4e2d\u7684\u4e32\u53e3\u662f\u5426\u53ef\u7528\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n
dmesg | grep tty<\/code><\/pre>\n \u8fd9\u6761\u547d\u4ee4\u4f1a\u8f93\u51fa\u7cfb\u7edf\u542f\u52a8\u65f6\u7684\u4e32\u53e3\u4fe1\u606f\uff0c\u5982\u679c\u6ca1\u6709\u8f93\u51fa\uff0c\u5219\u8868\u793aLinux\u7cfb\u7edf\u4e2d\u7684\u4e32\u53e3\u4e0d\u53ef\u7528\u3002<\/p>\n
\u67e5\u770b\u4e32\u53e3\u8bbe\u5907<\/h3>\n
\u5982\u679c\u4e32\u53e3\u53ef\u7528\uff0c\u5219\u53ef\u4ee5\u4f7f\u7528ls\u547d\u4ee4\u67e5\u770b\u4e32\u53e3\u8bbe\u5907\u3002<\/p>\n
\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u67e5\u770bLinux\u7cfb\u7edf\u4e2d\u7684\u4e32\u53e3\u8bbe\u5907\uff1a<\/p>\n
ls \/dev\/tty*<\/code><\/pre>\n \u8fd9\u6761\u547d\u4ee4\u4f1a\u8f93\u51fa\u7cfb\u7edf\u4e2d\u53ef\u7528\u7684\u4e32\u53e3\u8bbe\u5907\uff0c\u6bd4\u5982\/dev\/ttyS0\u3001\/dev\/ttyS1\u7b49\uff0c\u8fd9\u4e9b\u8bbe\u5907\u5c31\u662fLinux\u7cfb\u7edf\u4e2d\u53ef\u7528\u7684\u4e32\u53e3\u8bbe\u5907\u3002<\/p>\n
\u4f7f\u7528Linux\u4e32\u53e3\u8fdb\u884c\u6570\u636e\u4f20\u8f93<\/h2>\n \u4e32\u53e3\u9a71\u52a8\u5b89\u88c5<\/h3>\n
\u8981\u60f3\u4f7f\u7528Linux\u7cfb\u7edf\u4e2d\u7684\u4e32\u53e3\u8fdb\u884c\u6570\u636e\u4f20\u8f93\uff0c\u9996\u5148\u9700\u8981\u5b89\u88c5\u4e32\u53e3\u9a71\u52a8\u3002Linux\u7cfb\u7edf\u4e2d\u6709\u51e0\u79cd\u4e32\u53e3\u9a71\u52a8\u53ef\u4ee5\u9009\u62e9\uff0c\u6bd4\u5982serial_core\u3001serial8250\u3001pl2303\u7b49\uff0c\u53ef\u4ee5\u6839\u636e\u81ea\u5df1\u7684\u9700\u8981\u9009\u62e9\u5408\u9002\u7684\u9a71\u52a8\u8fdb\u884c\u5b89\u88c5\u3002<\/p>\n
\u4e32\u53e3\u7a0b\u5e8f\u7f16\u5199<\/h3>\n
\u5b89\u88c5\u5b8c\u4e32\u53e3\u9a71\u52a8\u540e\uff0c\u5c31\u53ef\u4ee5\u7f16\u5199\u4e32\u53e3\u7a0b\u5e8f\u4e86\u3002Linux\u7cfb\u7edf\u4e2d\u53ef\u4ee5\u4f7f\u7528C\u8bed\u8a00\u7f16\u5199\u4e32\u53e3\u7a0b\u5e8f\uff0c\u53ef\u4ee5\u4f7f\u7528\u7cfb\u7edf\u8c03\u7528\u51fd\u6570open\u3001read\u3001write\u6765\u64cd\u4f5c\u4e32\u53e3\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528\u7b2c\u4e09\u65b9\u5e93\uff0c\u6bd4\u5982libserial\uff0c\u6765\u64cd\u4f5c\u4e32\u53e3\u3002<\/p>\n
\u4e32\u53e3\u6570\u636e\u4f20\u8f93<\/h3>\n
\u7f16\u5199\u5b8c\u4e32\u53e3\u7a0b\u5e8f\u540e\uff0c\u5c31\u53ef\u4ee5\u4f7f\u7528\u4e32\u53e3\u8fdb\u884c\u6570\u636e\u4f20\u8f93\u4e86\u3002\u53ef\u4ee5\u4f7f\u7528open\u51fd\u6570\u6253\u5f00\u4e32\u53e3\u8bbe\u5907\uff0c\u4f7f\u7528read\u51fd\u6570\u4ece\u4e32\u53e3\u8bfb\u53d6\u6570\u636e\uff0c\u4f7f\u7528write\u51fd\u6570\u5411\u4e32\u53e3\u5199\u5165\u6570\u636e\uff0c\u4ece\u800c\u5b9e\u73b0\u4e32\u53e3\u6570\u636e\u4f20\u8f93\u3002<\/p>\n
\u603b\u7ed3<\/h2>\n
\u672c\u6587\u4ecb\u7ecd\u4e86\u5982\u4f55\u67e5\u770bLinux\u7cfb\u7edf\u4e2d\u7684\u4e32\u53e3\u662f\u5426\u53ef\u7528\uff0c\u4ee5\u53ca\u5982\u4f55\u4f7f\u7528\u4e32\u53e3\u8fdb\u884c\u6570\u636e\u4f20\u8f93\u3002<\/strong>\u9996\u5148\uff0c\u53ef\u4ee5\u4f7f\u7528dmesg\u547d\u4ee4\u67e5\u770b\u4e32\u53e3\u662f\u5426\u53ef\u7528\uff1b\u5176\u6b21\uff0c\u53ef\u4ee5\u4f7f\u7528ls\u547d\u4ee4\u67e5\u770b\u4e32\u53e3\u8bbe\u5907\uff1b\u7136\u540e\uff0c\u53ef\u4ee5\u5b89\u88c5\u4e32\u53e3\u9a71\u52a8\uff1b\u6700\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528C\u8bed\u8a00\u7f16\u5199\u4e32\u53e3\u7a0b\u5e8f\uff0c\u4f7f\u7528open\u3001read\u3001write\u51fd\u6570\u8fdb\u884c\u6570\u636e\u4f20\u8f93\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728Linux\u7cfb\u7edf\u4e2d\uff0c\u4e32\u53e3\u662f\u4e00\u79cd\u5e38\u89c1\u7684\u6570\u636e\u4f20\u8f93\u63a5\u53e3\uff0c\u5b83\u53ef\u4ee5\u7528\u6765\u8fde\u63a5\u7535\u8111\u548c\u5176\u4ed6\u5916\u90e8\u8bbe\u5907\uff0c\u5b9e\u73b0\u5916\u90e8\u8bbe\u5907\u548c\u7535\u8111\u4e4b\u95f4\u7684\u6570\u636e\u4f20\u8f93\u3002\u672c\u6587\u5c06\u4ecb\u7ecd\u5982\u4f55\u67e5\u770bLinux\u7cfb\u7edf\u4e2d\u7684\u4e32\u53e3\u662f\u5426\u53ef\u7528\uff0c\u4ee5<\/p>\n","protected":false},"author":1,"featured_media":4132,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"default","ast-global-header-display":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","footnotes":""},"categories":[36],"tags":[69],"class_list":["post-42152","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog","tag-cktx"],"_links":{"self":[{"href":"\/\/www.viralrail.com\/wp-json\/wp\/v2\/posts\/42152"}],"collection":[{"href":"\/\/www.viralrail.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"\/\/www.viralrail.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"\/\/www.viralrail.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"\/\/www.viralrail.com\/wp-json\/wp\/v2\/comments?post=42152"}],"version-history":[{"count":0,"href":"\/\/www.viralrail.com\/wp-json\/wp\/v2\/posts\/42152\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"\/\/www.viralrail.com\/wp-json\/wp\/v2\/media\/4132"}],"wp:attachment":[{"href":"\/\/www.viralrail.com\/wp-json\/wp\/v2\/media?parent=42152"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"\/\/www.viralrail.com\/wp-json\/wp\/v2\/categories?post=42152"},{"taxonomy":"post_tag","embeddable":true,"href":"\/\/www.viralrail.com\/wp-json\/wp\/v2\/tags?post=42152"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}