{"id":39393,"date":"2023-10-01T02:15:48","date_gmt":"2023-09-30T18:15:48","guid":{"rendered":"https:\/\/www.techphant.cn\/?p=39393"},"modified":"2023-10-01T02:15:48","modified_gmt":"2023-09-30T18:15:48","slug":"syjssck","status":"publish","type":"post","link":"https:\/\/www.techphant.cn\/blog\/39393.html","title":{"rendered":"\u4f7f\u7528jSerialComm\u641c\u7d22\u4e32\u53e3"},"content":{"rendered":"
jSerialComm\u662f\u4e00\u4e2a\u5f00\u6e90\u7684Java\u5e93\uff0c\u53ef\u4ee5\u7b80\u5316\u4e32\u53e3\u7f16\u7a0b\u3002\u5b83\u63d0\u4f9b\u4e86\u4e00\u4e2a\u7b80\u5355\u7684API\uff0c\u53ef\u4ee5\u8ba9\u4f60\u8f7b\u677e\u5730\u8fde\u63a5\u5230\u4e32\u53e3\u8bbe\u5907\uff0c\u5e76\u4e14\u53ef\u4ee5\u641c\u7d22\u4e32\u53e3\u8bbe\u5907\u3002\u8fd9\u7bc7\u6587\u7ae0\u5c06\u4ecb\u7ecdjSerialComm\u7684\u7528\u6cd5\uff0c\u5e76\u8ba8\u8bba\u5982\u4f55\u4f7f\u7528\u5b83\u6765\u641c\u7d22\u4e32\u53e3\u8bbe\u5907\u3002<\/p>\n
jSerialComm\u662f\u4e00\u4e2a\u5f00\u6e90\u7684Java\u5e93\uff0c\u53ef\u4ee5\u7528\u4e8e\u8bbf\u95ee\u548c\u63a7\u5236\u4e32\u53e3\u8bbe\u5907\u3002\u5b83\u63d0\u4f9b\u4e86\u4e00\u4e2a\u7b80\u5355\u7684API\uff0c\u53ef\u4ee5\u8ba9\u4f60\u8f7b\u677e\u5730\u8fde\u63a5\u5230\u4e32\u53e3\u8bbe\u5907\uff0c\u5e76\u4e14\u53ef\u4ee5\u641c\u7d22\u4e32\u53e3\u8bbe\u5907\u3002jSerialComm\u652f\u6301Windows\uff0cLinux\u548cmacOS\uff0c\u5e76\u4e14\u53ef\u4ee5\u8ba9\u4f60\u8f7b\u677e\u5730\u8fde\u63a5\u5230\u4efb\u4f55\u7c7b\u578b\u7684\u4e32\u53e3\u8bbe\u5907\uff0c\u5305\u62ecRS-232\uff0cRS-485\uff0cUSB\u548cBluetooth\u3002<\/p>\n
\u4f7f\u7528jSerialComm\u641c\u7d22\u4e32\u53e3\u5f88\u5bb9\u6613\u3002\u9996\u5148\uff0c\u4f60\u9700\u8981\u4e0b\u8f7djSerialComm\u5e93\uff0c\u5e76\u5c06\u5176\u6dfb\u52a0\u5230\u4f60\u7684\u9879\u76ee\u4e2d\u3002\u7136\u540e\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528jSerialComm API\u6765\u641c\u7d22\u4e32\u53e3\u8bbe\u5907\u3002jSerialComm\u63d0\u4f9b\u4e86\u4e00\u4e2aCommPortIdentifier\u7c7b\uff0c\u53ef\u4ee5\u7528\u6765\u679a\u4e3e\u53ef\u7528\u7684\u4e32\u53e3\u8bbe\u5907\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528CommPortIdentifier\u7c7b\u7684getPortIdentifiers()\u65b9\u6cd5\u6765\u83b7\u53d6\u53ef\u7528\u7684\u4e32\u53e3\u8bbe\u5907\u5217\u8868\u3002<\/p>\n
\u4f7f\u7528CommPortIdentifier\u7c7b<\/strong><\/p>\n CommPortIdentifier\u7c7b\u63d0\u4f9b\u4e86\u4e00\u4e2a\u7b80\u5355\u7684API\uff0c\u53ef\u4ee5\u7528\u6765\u679a\u4e3e\u53ef\u7528\u7684\u4e32\u53e3\u8bbe\u5907\u3002\u4f7f\u7528CommPortIdentifier\u7c7b\u7684getPortIdentifiers()\u65b9\u6cd5\uff0c\u4f60\u53ef\u4ee5\u83b7\u53d6\u53ef\u7528\u7684\u4e32\u53e3\u8bbe\u5907\u5217\u8868\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528CommPortIdentifier\u7c7b\u7684getName()\u65b9\u6cd5\u6765\u83b7\u53d6\u4e32\u53e3\u8bbe\u5907\u7684\u540d\u79f0\uff0c\u4ee5\u53cagetPortType()\u65b9\u6cd5\u6765\u83b7\u53d6\u4e32\u53e3\u8bbe\u5907\u7684\u7c7b\u578b\uff08\u4f8b\u5982RS-232\uff0cRS-485\uff0cUSB\u7b49\uff09\u3002 <\/p>\n \u4e00\u65e6\u4f60\u641c\u7d22\u5230\u4e32\u53e3\u8bbe\u5907\uff0c\u4f60\u5c31\u53ef\u4ee5\u4f7f\u7528jSerialComm API\u6765\u8fde\u63a5\u5230\u4e32\u53e3\u8bbe\u5907\u3002jSerialComm\u63d0\u4f9b\u4e86\u4e00\u4e2aSerialPort\u7c7b\uff0c\u53ef\u4ee5\u7528\u6765\u8fde\u63a5\u5230\u4e32\u53e3\u8bbe\u5907\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528SerialPort\u7c7b\u7684openPort()\u65b9\u6cd5\u6765\u6253\u5f00\u4e32\u53e3\u8bbe\u5907\uff0c\u7136\u540e\u4f7f\u7528SerialPort\u7c7b\u7684getInputStream()\u548cgetOutputStream()\u65b9\u6cd5\u6765\u83b7\u53d6\u8f93\u5165\u548c\u8f93\u51fa\u6d41\u3002<\/p>\n SerialPort\u7c7b\u63d0\u4f9b\u4e86\u4e00\u4e2a\u7b80\u5355\u7684API\uff0c\u53ef\u4ee5\u7528\u6765\u8fde\u63a5\u5230\u4e32\u53e3\u8bbe\u5907\u3002\u4f7f\u7528SerialPort\u7c7b\u7684openPort()\u65b9\u6cd5\uff0c\u4f60\u53ef\u4ee5\u6253\u5f00\u4e32\u53e3\u8bbe\u5907\u3002\u7136\u540e\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528SerialPort\u7c7b\u7684getInputStream()\u548cgetOutputStream()\u65b9\u6cd5\u6765\u83b7\u53d6\u8f93\u5165\u548c\u8f93\u51fa\u6d41\u3002\u4f60\u8fd8\u53ef\u4ee5\u4f7f\u7528SerialPort\u7c7b\u7684setBaudRate()\u65b9\u6cd5\u6765\u8bbe\u7f6e\u4e32\u53e3\u8bbe\u5907\u7684\u6ce2\u7279\u7387\uff0c\u4ee5\u53casetDataBits()\u3001setParity()\u548csetStopBits()\u65b9\u6cd5\u6765\u8bbe\u7f6e\u4e32\u53e3\u8bbe\u5907\u7684\u6570\u636e\u4f4d\u3001\u6821\u9a8c\u4f4d\u548c\u505c\u6b62\u4f4d\u3002 <\/p>\n \u672c\u6587\u4ecb\u7ecd\u4e86jSerialComm\u7684\u7528\u6cd5\uff0c\u4ee5\u53ca\u5982\u4f55\u4f7f\u7528\u5b83\u6765\u641c\u7d22\u4e32\u53e3\u8bbe\u5907\u3002<\/strong>jSerialComm\u662f\u4e00\u4e2a\u5f00\u6e90\u7684Java\u5e93\uff0c\u53ef\u4ee5\u7b80\u5316\u4e32\u53e3\u7f16\u7a0b\u3002\u5b83\u63d0\u4f9b\u4e86\u4e00\u4e2a\u7b80\u5355\u7684API\uff0c\u53ef\u4ee5\u8ba9\u4f60\u8f7b\u677e\u5730\u8fde\u63a5\u5230\u4e32\u53e3\u8bbe\u5907\uff0c\u5e76\u4e14\u53ef\u4ee5\u641c\u7d22\u4e32\u53e3\u8bbe\u5907\u3002\u4f7f\u7528jSerialComm\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528CommPortIdentifier\u7c7b\u6765\u679a\u4e3e\u53ef\u7528\u7684\u4e32\u53e3\u8bbe\u5907\uff0c\u5e76\u4f7f\u7528SerialPort\u7c7b\u6765\u8fde\u63a5\u5230\u4e32\u53e3\u8bbe\u5907\u3002<\/p>\n","protected":false},"excerpt":{"rendered":" jSerialComm\u662f\u4e00\u4e2a\u5f00\u6e90\u7684Java\u5e93\uff0c\u53ef\u4ee5\u7b80\u5316\u4e32\u53e3\u7f16\u7a0b\u3002\u5b83\u63d0\u4f9b\u4e86\u4e00\u4e2a\u7b80\u5355\u7684API\uff0c\u53ef\u4ee5\u8ba9\u4f60\u8f7b\u677e\u5730\u8fde\u63a5\u5230\u4e32\u53e3\u8bbe\u5907\uff0c\u5e76\u4e14\u53ef\u4ee5\u641c\u7d22\u4e32\u53e3\u8bbe\u5907\u3002\u8fd9\u7bc7\u6587\u7ae0\u5c06\u4ecb\u7ecdjSerial<\/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-39393","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\/39393","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=39393"}],"version-history":[{"count":0,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/posts\/39393\/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=39393"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/categories?post=39393"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/tags?post=39393"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}\u8fde\u63a5\u5230\u4e32\u53e3\u8bbe\u5907<\/h2>\n
\u4f7f\u7528SerialPort\u7c7b<\/h3>\n
\u603b\u7ed3<\/h2>\n