{"id":42676,"date":"2023-09-27T11:05:15","date_gmt":"2023-09-27T03:05:15","guid":{"rendered":"\/\/www.dealsbon.com\/?p=42676"},"modified":"2023-09-27T11:05:15","modified_gmt":"2023-09-27T03:05:15","slug":"syjdyck","status":"publish","type":"post","link":"\/\/www.dealsbon.com\/blog\/42676.html","title":{"rendered":"\u4f7f\u7528jSerialComm\u8c03\u7528\u4e32\u53e3"},"content":{"rendered":"

  jSerialComm\u662f\u4e00\u4e2a\u5f00\u6e90\u7684Java\u5e93\uff0c\u7528\u4e8e\u8c03\u7528\u4e32\u53e3\u8bbe\u5907\u3002\u5b83\u63d0\u4f9b\u4e86\u4e00\u79cd\u7b80\u5355\u3001\u9ad8\u6548\u7684\u65b9\u5f0f\u6765\u8ba9\u4f60\u7684\u5e94\u7528\u7a0b\u5e8f\u4e0e\u4e32\u884c\u8bbe\u5907\u8fdb\u884c\u901a\u4fe1\uff0c\u65e0\u8bba\u662f\u4e00\u4e2a\u7b80\u5355\u7684Arduino\u677f\uff0c\u8fd8\u662f\u4e00\u4e2a\u590d\u6742\u7684GPS\u6a21\u5757\uff0c\u90fd\u53ef\u4ee5\u4f7f\u7528jSerialComm\u6765\u63a7\u5236\u3002<\/p>\n

jSerialComm\u7684\u7b80\u4ecb<\/h2>\n

  jSerialComm\u662f\u4e00\u4e2a\u5f00\u6e90Java\u5e93\uff0c\u5b83\u63d0\u4f9b\u4e86\u4e00\u79cd\u7b80\u5355\u7684\u65b9\u5f0f\u6765\u8bbf\u95ee\u548c\u63a7\u5236\u4e32\u53e3\u8bbe\u5907\u3002\u5b83\u652f\u6301\u6240\u6709\u4e3b\u6d41\u64cd\u4f5c\u7cfb\u7edf\uff0c\u5305\u62ecWindows\u3001Linux\u548cMac OS\uff0c\u5e76\u4e14\u53ef\u4ee5\u8f7b\u677e\u5730\u4e0e\u4efb\u4f55\u4e32\u53e3\u8bbe\u5907\u8fdb\u884c\u901a\u4fe1\uff0c\u65e0\u8bba\u662f\u4e00\u4e2a\u7b80\u5355\u7684Arduino\u677f\uff0c\u8fd8\u662f\u4e00\u4e2a\u590d\u6742\u7684GPS\u6a21\u5757\u3002<\/p>\n

  jSerialComm\u7684\u4e3b\u8981\u529f\u80fd\u5305\u62ec\uff1a\u8bbf\u95ee\u672c\u5730\u4e32\u53e3\u8bbe\u5907\uff0c\u8bbf\u95ee\u8fdc\u7a0b\u4e32\u53e3\u8bbe\u5907\uff0c\u8bbf\u95eeUSB\u8bbe\u5907\uff0c\u63a7\u5236\u4e32\u53e3\u8bbe\u5907\u7684\u53c2\u6570\uff0c\u4ee5\u53ca\u63a7\u5236\u4e32\u53e3\u8bbe\u5907\u7684\u6570\u636e\u6d41\u3002\u6b64\u5916\uff0cjSerialComm\u8fd8\u63d0\u4f9b\u4e86\u4e00\u7cfb\u5217\u7684API\uff0c\u53ef\u4ee5\u5e2e\u52a9\u5f00\u53d1\u4eba\u5458\u5feb\u901f\u5f00\u53d1\u57fa\u4e8e\u4e32\u53e3\u7684\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n

\u4f7f\u7528jSerialComm\u8c03\u7528\u4e32\u53e3<\/h2>\n

  1.\u5b89\u88c5jSerialComm<\/h3>\n

  \u4f7f\u7528jSerialComm\u8c03\u7528\u4e32\u53e3\u4e4b\u524d\uff0c\u9996\u5148\u9700\u8981\u5b89\u88c5jSerialComm\u3002\u53ef\u4ee5\u4eceGithub<\/a>\u4e0a\u4e0b\u8f7d\u6700\u65b0\u7248\u672c\u7684jSerialComm\u5e93\uff0c\u7136\u540e\u6309\u7167\u8bf4\u660e\u5b89\u88c5\u5373\u53ef\u3002<\/p>\n

  2.\u8bbf\u95ee\u4e32\u53e3\u8bbe\u5907<\/h3>\n

  \u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u5c31\u53ef\u4ee5\u5f00\u59cb\u4f7f\u7528jSerialComm\u6765\u8bbf\u95ee\u4e32\u53e3\u8bbe\u5907\u4e86\u3002\u9996\u5148\uff0c\u9700\u8981\u4f7f\u7528SerialPort.getCommPorts()\u65b9\u6cd5\u83b7\u53d6\u53ef\u7528\u7684\u4e32\u53e3\u8bbe\u5907\u5217\u8868\uff0c\u7136\u540e\u904d\u5386\u5217\u8868\uff0c\u627e\u5230\u9700\u8981\u8bbf\u95ee\u7684\u8bbe\u5907\u3002\u63a5\u7740\uff0c\u53ef\u4ee5\u4f7f\u7528SerialPort.openPort()\u65b9\u6cd5\u6253\u5f00\u4e32\u53e3\u8bbe\u5907\uff0c\u5e76\u4f7f\u7528SerialPort.setComPortParameters()\u65b9\u6cd5\u8bbe\u7f6e\u4e32\u53e3\u8bbe\u5907\u7684\u53c2\u6570\uff0c\u5982\u6ce2\u7279\u7387\u3001\u6570\u636e\u4f4d\u3001\u505c\u6b62\u4f4d\u7b49\u3002<\/p>\n

  3.\u63a7\u5236\u4e32\u53e3\u8bbe\u5907<\/h3>\n

  \u5b8c\u6210\u8bbe\u7f6e\u540e\uff0c\u5c31\u53ef\u4ee5\u4f7f\u7528SerialPort.writeBytes()\u65b9\u6cd5\u6765\u63a7\u5236\u4e32\u53e3\u8bbe\u5907\u4e86\u3002\u4f7f\u7528\u8fd9\u4e2a\u65b9\u6cd5\uff0c\u53ef\u4ee5\u5411\u4e32\u53e3\u8bbe\u5907\u53d1\u9001\u6570\u636e\uff0c\u4e5f\u53ef\u4ee5\u4ece\u4e32\u53e3\u8bbe\u5907\u8bfb\u53d6\u6570\u636e\u3002\u6b64\u5916\uff0c\u8fd8\u53ef\u4ee5\u4f7f\u7528SerialPort.addDataListener()\u65b9\u6cd5\u6765\u76d1\u542c\u4e32\u53e3\u8bbe\u5907\u7684\u6570\u636e\u6d41\uff0c\u4ee5\u4fbf\u80fd\u591f\u53ca\u65f6\u5904\u7406\u4e32\u53e3\u8bbe\u5907\u53d1\u9001\u7684\u6570\u636e\u3002<\/p>\n

\u603b\u7ed3<\/h2>\n

  jSerialComm\u662f\u4e00\u4e2a\u5f00\u6e90\u7684Java\u5e93\uff0c\u5b83\u63d0\u4f9b\u4e86\u4e00\u79cd\u7b80\u5355\u3001\u9ad8\u6548\u7684\u65b9\u5f0f\u6765\u8ba9\u4f60\u7684\u5e94\u7528\u7a0b\u5e8f\u4e0e\u4e32\u884c\u8bbe\u5907\u8fdb\u884c\u901a\u4fe1\u3002<\/strong>\u4f7f\u7528jSerialComm\uff0c\u53ef\u4ee5\u8f7b\u677e\u5730\u8bbf\u95ee\u548c\u63a7\u5236\u4e32\u53e3\u8bbe\u5907\uff0c\u4ece\u800c\u5b9e\u73b0\u4e0e\u4e32\u53e3\u8bbe\u5907\u7684\u901a\u4fe1\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

jSerialComm\u662f\u4e00\u4e2a\u5f00\u6e90\u7684Java\u5e93\uff0c\u7528\u4e8e\u8c03\u7528\u4e32\u53e3\u8bbe\u5907\u3002\u5b83\u63d0\u4f9b\u4e86\u4e00\u79cd\u7b80\u5355\u3001\u9ad8\u6548\u7684\u65b9\u5f0f\u6765\u8ba9\u4f60\u7684\u5e94\u7528\u7a0b\u5e8f\u4e0e\u4e32\u884c\u8bbe\u5907\u8fdb\u884c\u901a\u4fe1\uff0c\u65e0\u8bba\u662f\u4e00\u4e2a\u7b80\u5355\u7684Arduino\u677f\uff0c\u8fd8\u662f\u4e00\u4e2a<\/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-42676","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog","tag-cktx"],"_links":{"self":[{"href":"\/\/www.dealsbon.com\/wp-json\/wp\/v2\/posts\/42676"}],"collection":[{"href":"\/\/www.dealsbon.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"\/\/www.dealsbon.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"\/\/www.dealsbon.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"\/\/www.dealsbon.com\/wp-json\/wp\/v2\/comments?post=42676"}],"version-history":[{"count":0,"href":"\/\/www.dealsbon.com\/wp-json\/wp\/v2\/posts\/42676\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"\/\/www.dealsbon.com\/wp-json\/wp\/v2\/media\/4132"}],"wp:attachment":[{"href":"\/\/www.dealsbon.com\/wp-json\/wp\/v2\/media?parent=42676"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"\/\/www.dealsbon.com\/wp-json\/wp\/v2\/categories?post=42676"},{"taxonomy":"post_tag","embeddable":true,"href":"\/\/www.dealsbon.com\/wp-json\/wp\/v2\/tags?post=42676"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}