{"id":46340,"date":"2023-09-30T14:51:18","date_gmt":"2023-09-30T06:51:18","guid":{"rendered":"https:\/\/www.techphant.cn\/?p=46340"},"modified":"2023-09-30T14:51:18","modified_gmt":"2023-09-30T06:51:18","slug":"sylpzckgj","status":"publish","type":"post","link":"https:\/\/www.techphant.cn\/blog\/46340.html","title":{"rendered":"\u4f7f\u7528LuaT\u914d\u7f6e\u4e32\u53e3\u7ba1\u811a"},"content":{"rendered":"
\u4e32\u53e3\u7ba1\u811a\u662f\u4e00\u79cd\u5e38\u7528\u7684\u7535\u5b50\u8bbe\u5907\u8fde\u63a5\u6280\u672f\uff0c\u53ef\u4ee5\u5c06\u4e0d\u540c\u7684\u8bbe\u5907\u8fde\u63a5\u5728\u4e00\u8d77\uff0c\u4ee5\u4fbf\u5b9e\u73b0\u6570\u636e\u4f20\u8f93\u3002LuaT\u662f\u4e00\u79cd\u529f\u80fd\u5f3a\u5927\u7684\u7f16\u7a0b\u8bed\u8a00\uff0c\u53ef\u4ee5\u7528\u4e8e\u914d\u7f6e\u4e32\u53e3\u7ba1\u811a\uff0c\u5b9e\u73b0\u8bbe\u5907\u95f4\u7684\u6570\u636e\u4f20\u8f93\u3002\u672c\u6587\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528LuaT\u6765\u914d\u7f6e\u4e32\u53e3\u7ba1\u811a\u3002<\/p>\n
LuaT\u662f\u4e00\u79cd\u8f7b\u91cf\u7ea7\u7684\u811a\u672c\u8bed\u8a00\uff0c\u5b83\u5177\u6709\u7075\u6d3b\u7684\u8bed\u6cd5\u3001\u6613\u4e8e\u7406\u89e3\u7684\u8bed\u4e49\u3001\u529f\u80fd\u5f3a\u5927\u7684\u5e93\u548c\u9ad8\u6548\u7684\u8fd0\u884c\u673a\u5236\uff0c\u53ef\u4ee5\u88ab\u7528\u4e8e\u7f16\u7a0b\u3001\u8c03\u8bd5\u548c\u81ea\u52a8\u5316\u3002LuaT\u7684\u8bed\u6cd5\u7b80\u6d01\uff0c\u53ef\u4ee5\u5728\u77ed\u65f6\u95f4\u5185\u5b66\u4e60\u4f7f\u7528\uff0c\u5e76\u4e14\u652f\u6301\u591a\u79cd\u6570\u636e\u7c7b\u578b\u548c\u591a\u79cd\u7f16\u7a0b\u8303\u5f0f\uff0c\u4f7f\u7a0b\u5e8f\u5458\u53ef\u4ee5\u6839\u636e\u9700\u8981\u81ea\u7531\u9009\u62e9\u3002<\/p>\n
\u9996\u5148\uff0c\u6211\u4eec\u9700\u8981\u5b89\u88c5LuaT\uff0c\u53ef\u4ee5\u4eceLuaT\u5b98\u7f51\u4e0b\u8f7d\u5b89\u88c5\u5305\uff0c\u7136\u540e\u6309\u7167\u63d0\u793a\u5b89\u88c5\u5373\u53ef\u3002\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u5728\u684c\u9762\u4e0a\u4f1a\u51fa\u73b0\u4e00\u4e2aLuaT\u7684\u56fe\u6807\uff0c\u70b9\u51fb\u5373\u53ef\u6253\u5f00LuaT\u7684\u7f16\u8f91\u5668\u3002<\/p>\n
\u5728LuaT\u7f16\u8f91\u5668\u4e2d\uff0c\u70b9\u51fb\u201c\u65b0\u5efa\u201d\u6309\u94ae\uff0c\u8f93\u5165\u5de5\u7a0b\u540d\u79f0\uff0c\u7136\u540e\u70b9\u51fb\u201c\u786e\u5b9a\u201d\u6309\u94ae\uff0c\u5373\u53ef\u521b\u5efa\u4e00\u4e2a\u65b0\u7684LuaT\u5de5\u7a0b\u3002<\/p>\n
\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u9700\u8981\u7f16\u5199LuaT\u4ee3\u7801\uff0c\u7528\u6765\u914d\u7f6e\u4e32\u53e3\u7ba1\u811a\u3002LuaT\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u51fd\u6570\u5e93\uff0c\u53ef\u4ee5\u7528\u6765\u64cd\u4f5c\u4e32\u53e3\u7ba1\u811a\u3002\u4f8b\u5982\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528uart.setup()\u51fd\u6570\u6765\u8bbe\u7f6e\u4e32\u53e3\u7ba1\u811a\u7684\u53c2\u6570\uff0c\u4f7f\u7528uart.on()\u51fd\u6570\u6765\u8bbe\u7f6e\u4e32\u53e3\u7ba1\u811a\u7684\u4e2d\u65ad\u51fd\u6570\uff0c\u4f7f\u7528uart.write()\u51fd\u6570\u6765\u5411\u4e32\u53e3\u7ba1\u811a\u53d1\u9001\u6570\u636e\uff0c\u4f7f\u7528uart.read()\u51fd\u6570\u6765\u4ece\u4e32\u53e3\u7ba1\u811a\u8bfb\u53d6\u6570\u636e\u7b49\u3002<\/p>\n
\u7f16\u5199\u5b8cLuaT\u4ee3\u7801\u540e\uff0c\u6211\u4eec\u9700\u8981\u5c06\u5176\u7f16\u8bd1\u4e3a\u53ef\u6267\u884c\u6587\u4ef6\uff0c\u4fbf\u4e8e\u5728\u6307\u5b9a\u73af\u5883\u4e2d\u8fd0\u884c\u3002\u5728LuaT\u7f16\u8f91\u5668\u4e2d\uff0c\u70b9\u51fb\u201c\u7f16\u8bd1\u201d\u6309\u94ae\uff0c\u5373\u53ef\u5c06LuaT\u4ee3\u7801\u7f16\u8bd1\u4e3a\u53ef\u6267\u884c\u6587\u4ef6\u3002<\/p>\n
\u7f16\u8bd1\u5b8c\u6210\u540e\uff0c\u6211\u4eec\u53ef\u4ee5\u5c06\u53ef\u6267\u884c\u6587\u4ef6\u590d\u5236\u5230\u6307\u5b9a\u7684\u8bbe\u5907\u4e0a\uff0c\u7136\u540e\u8fd0\u884cLuaT\u4ee3\u7801\uff0c\u5373\u53ef\u5b9e\u73b0\u4e32\u53e3\u7ba1\u811a\u7684\u914d\u7f6e\u3002<\/p>\n
\u4ee5\u4e0a\u5c31\u662f\u4f7f\u7528LuaT\u914d\u7f6e\u4e32\u53e3\u7ba1\u811a\u7684\u8be6\u7ec6\u6b65\u9aa4\uff0cLuaT\u662f\u4e00\u79cd\u529f\u80fd\u5f3a\u5927\u7684\u7f16\u7a0b\u8bed\u8a00\uff0c\u53ef\u4ee5\u7528\u4e8e\u914d\u7f6e\u4e32\u53e3\u7ba1\u811a\uff0c\u5b9e\u73b0\u8bbe\u5907\u95f4\u7684\u6570\u636e\u4f20\u8f93\u3002<\/strong>\u5b83\u5177\u6709\u7075\u6d3b\u7684\u8bed\u6cd5\u3001\u6613\u4e8e\u7406\u89e3\u7684\u8bed\u4e49\u3001\u529f\u80fd\u5f3a\u5927\u7684\u5e93\u548c\u9ad8\u6548\u7684\u8fd0\u884c\u673a\u5236\uff0c\u53ef\u4ee5\u88ab\u7528\u4e8e\u7f16\u7a0b\u3001\u8c03\u8bd5\u548c\u81ea\u52a8\u5316\u3002<\/p>\n","protected":false},"excerpt":{"rendered":" \u4e32\u53e3\u7ba1\u811a\u662f\u4e00\u79cd\u5e38\u7528\u7684\u7535\u5b50\u8bbe\u5907\u8fde\u63a5\u6280\u672f\uff0c\u53ef\u4ee5\u5c06\u4e0d\u540c\u7684\u8bbe\u5907\u8fde\u63a5\u5728\u4e00\u8d77\uff0c\u4ee5\u4fbf\u5b9e\u73b0\u6570\u636e\u4f20\u8f93\u3002LuaT\u662f\u4e00\u79cd\u529f\u80fd\u5f3a\u5927\u7684\u7f16\u7a0b\u8bed\u8a00\uff0c\u53ef\u4ee5\u7528\u4e8e\u914d\u7f6e\u4e32\u53e3\u7ba1\u811a\uff0c\u5b9e\u73b0\u8bbe\u5907\u95f4\u7684\u6570\u636e\u4f20\u8f93\u3002\u672c\u6587\u5c06\u8be6<\/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-46340","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog","tag-cktx"],"_links":{"self":[{"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/posts\/46340","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/comments?post=46340"}],"version-history":[{"count":0,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/posts\/46340\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/media\/4132"}],"wp:attachment":[{"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/media?parent=46340"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/categories?post=46340"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/tags?post=46340"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}