{"id":19773,"date":"2025-04-19T02:22:20","date_gmt":"2025-04-18T18:22:20","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/19773.html"},"modified":"2025-04-19T02:22:20","modified_gmt":"2025-04-18T18:22:20","slug":"modbus-rtu%e8%af%a6%e8%a7%a3","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/19773.html","title":{"rendered":"Modbus-RTU\u8be6\u89e3"},"content":{"rendered":"<p id=\"main-toc\">\u76ee\u5f55<\/p>\n<p id=\"Modbus-RTU%E5%8D%8F%E8%AE%AE-toc\" style=\"margin-left:0px\">Modbus-RTU\u534f\u8bae<\/p>\n<p id=\"%E4%B8%80%E3%80%81Modbus-RTU%20%E6%A0%B8%E5%BF%83%E7%89%B9%E6%80%A7-toc\" style=\"margin-left:80px\">Modbus-RTU \u6838\u5fc3\u7279\u6027<\/p>\n<p id=\"%E6%95%B0%E6%8D%AE%E5%B8%A7%E6%A0%BC%E5%BC%8F-toc\" style=\"margin-left:80px\">\u6570\u636e\u5e27\u683c\u5f0f<\/p>\n<p id=\"%E5%B8%A7%E7%BB%93%E6%9E%84%E7%A4%BA%E4%BE%8B-toc\" style=\"margin-left:80px\">\u5e27\u7ed3\u6784\u793a\u4f8b<\/p>\n<p id=\"%E5%BA%94%E7%94%A8%E5%9C%BA%E6%99%AF%E4%B8%8E%E7%A4%BA%E4%BE%8B-toc\" style=\"margin-left:80px\">\u5e94\u7528\u573a\u666f\u4e0e\u793a\u4f8b<\/p>\n<p id=\"1.%20PLC%20%E6%8E%A7%E5%88%B6%E7%94%B5%E6%9C%BA%E5%90%AF%E5%81%9C-toc\" style=\"margin-left:120px\">1. PLC \u63a7\u5236\u7535\u673a\u542f\u505c<\/p>\n<p id=\"2.%20%E8%AF%BB%E5%8F%96%E6%B8%A9%E5%BA%A6%E4%BC%A0%E6%84%9F%E5%99%A8%E6%95%B0%E6%8D%AE-toc\" style=\"margin-left:120px\">2. \u8bfb\u53d6\u6e29\u5ea6\u4f20\u611f\u5668\u6570\u636e<\/p>\n<p id=\"CRC16%E6%A0%A1%E9%AA%8C%E7%AE%97%E6%B3%95-toc\" style=\"margin-left:80px\">CRC16\u6821\u9a8c\u7b97\u6cd5<\/p>\n<p id=\"CRC16%E7%AE%97%E6%B3%95%E7%9A%84%E8%BF%87%E7%A8%8B-toc\" style=\"margin-left:120px\">CRC16\u7b97\u6cd5\u7684\u8fc7\u7a0b<\/p>\n<p id=\"modbus-rtu%E7%9A%84%E4%BD%BF%E7%94%A8-toc\" style=\"margin-left:40px\">modbus-rtu\u7684\u4f7f\u7528<\/p>\n<p id=\"%E5%8F%91%E9%80%81%E6%95%B0%E6%8D%AE-toc\" style=\"margin-left:80px\">\u53d1\u9001\u6570\u636e<\/p>\n<p id=\"%E6%8E%A5%E6%94%B6%E6%95%B0%E6%8D%AE-toc\" style=\"margin-left:80px\">\u63a5\u6536\u6570\u636e<\/p>\n<p id=\"tcp%E7%BD%91%E5%8F%A3%E5%AE%8C%E6%95%B4%E5%AE%9E%E7%8E%B0modbus-rtu%E5%8D%8F%E8%AE%AE-toc\" style=\"margin-left:80px\">tcp\u7f51\u53e3\u5b8c\u6574\u5b9e\u73b0modbus-rtu\u534f\u8bae<\/p>\n<p id=\"Modbus-RTU%E5%92%8CModbus-TCP%E7%9A%84%E8%B6%8B%E5%8C%BA%E5%88%AB-toc\" style=\"margin-left:40px\">Modbus-RTU\u548cModbus-TCP\u7684\u8d8b\u533a\u522b<\/p>\n<p id=\"%E4%BD%BF%E7%94%A8NModbus4%E5%AE%9E%E7%8E%B0modbus-rtu%E5%8D%8F%E8%AE%AE-toc\" style=\"margin-left:40px\">\u4f7f\u7528NModbus4\u5b9e\u73b0modbus-rtu\u534f\u8bae<\/p>\n<p id=\"%E5%AE%89%E8%A3%85NModbus4%E5%BA%93%E3%80%82-toc\" style=\"margin-left:80px\">\u5b89\u88c5NModbus4\u5e93\u3002<\/p>\n<p id=\"%E4%B8%B2%E5%8F%A3%E5%AE%9E%E7%8E%B0NModbus4-toc\" style=\"margin-left:80px\">\u4e32\u53e3\u5b9e\u73b0NModbus4<\/p>\n<hr id=\"hr-toc\" \/>\n<\/p>\n<h2 id=\"Modbus-RTU%E5%8D%8F%E8%AE%AE\">Modbus-RTU\u534f\u8bae<\/h2>\n<p>Modbus RTU \u534f\u8bae\u662f\u4e00\u79cd\u5f00\u653e\u7684\u4e32\u884c\u534f\u8bae&#xff0c;\u5e7f\u6cdb\u5e94\u7528\u4e8e\u5f53\u4eca\u7684\u5de5\u4e1a\u76d1\u63a7\u8bbe\u5907\u4e2d\u3002\u8be5\u534f\u8bae\u4f7f\u7528 RS-232 \u6216 RS-485 \u4e32\u884c\u63a5\u53e3\u8fdb\u884c\u901a\u4fe1&#xff0c;\u5e76\u5f97\u5230\u5e02\u573a\u4e0a\u51e0\u4e4e\u6240\u6709\u5546\u4e1a SCADA\u3001HMI\u3001OPC \u670d\u52a1\u5668\u548c\u6570\u636e\u91c7\u96c6\u8f6f\u4ef6\u7a0b\u5e8f\u7684\u652f\u6301\u3002\u56e0\u6b64&#xff0c;\u5f88\u5bb9\u6613\u5c06 Modbus \u517c\u5bb9\u8bbe\u5907\u96c6\u6210\u5230\u65b0\u7684\u6216\u73b0\u6709\u7684\u76d1\u63a7\u5e94\u7528\u7a0b\u5e8f\u4e2d&#xff0c;\u5e76\u5177\u6709\u5373\u65f6\u7684\u8f6f\u4ef6\u652f\u6301\u3002<\/p>\n<hr \/>\n<h4 id=\"%E4%B8%80%E3%80%81Modbus-RTU%20%E6%A0%B8%E5%BF%83%E7%89%B9%E6%80%A7\">Modbus-RTU \u6838\u5fc3\u7279\u6027<\/h4>\n<table>\n<tr>\u7279\u6027\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>\u4f20\u8f93\u65b9\u5f0f<\/td>\n<td>\u4e8c\u8fdb\u5236\u6570\u636e\u4f20\u8f93&#xff08;\u7d27\u51d1\u9ad8\u6548&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\u7269\u7406\u63a5\u53e3<\/td>\n<td>RS-485&#xff08;\u591a\u8bbe\u5907\u603b\u7ebf&#xff09;\u6216 RS-232&#xff08;\u70b9\u5bf9\u70b9&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\u6821\u9a8c\u65b9\u5f0f<\/td>\n<td>\u5faa\u73af\u5197\u4f59\u6821\u9a8c&#xff08;CRC-16&#xff09;&#xff0c;\u6821\u9a8c\u8303\u56f4\u5305\u62ec\u6574\u4e2a\u6570\u636e\u5e27<\/td>\n<\/tr>\n<tr>\n<td>\u4f20\u8f93\u6548\u7387<\/td>\n<td>\u9ad8&#xff08;\u65e0\u5b57\u7b26\u8f6c\u6362\u5f00\u9500&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\u6700\u5927\u8bbe\u5907\u6570<\/td>\n<td>RS-485 \u603b\u7ebf\u652f\u6301\u6700\u591a 32~247 \u4e2a\u8bbe\u5907&#xff08;\u4f9d\u8d56\u9a71\u52a8\u80fd\u529b&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\u5178\u578b\u5e94\u7528<\/td>\n<td>\u5de5\u4e1a\u5b9e\u65f6\u63a7\u5236\u3001\u8bbe\u5907\u76d1\u63a7\u3001\u9ad8\u901f\u6570\u636e\u91c7\u96c6<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<h4 id=\"%E6%95%B0%E6%8D%AE%E5%B8%A7%E6%A0%BC%E5%BC%8F\">\u6570\u636e\u5e27\u683c\u5f0f<\/h4>\n<p>\u5e27\u7ed3\u6784&#xff1a;\u8bbe\u5907\u5730\u5740\u3001\u529f\u80fd\u7801\u3001\u6570\u636e\u548cCRC\u6821\u9a8c\u5b57\u6bb5\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"178\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418182218-6802985a33e34.png\" width=\"639\" \/><\/p>\n<p>\u5e38\u7528\u529f\u80fd\u7801&#xff1a;Modbus-RTU\u534f\u8bae\u5b9a\u4e49\u4e86\u4e00\u7cfb\u5217\u5e38\u7528\u7684\u529f\u80fd\u7801&#xff0c;\u7528\u4e8e\u6267\u884c\u4e0d\u540c\u7684\u64cd\u4f5c&#xff0c;\u5982\u8bfb\u53d6\u4fdd\u6301\u5bc4\u5b58\u5668\u3001\u5199\u5165\u5355\u4e2a\u5bc4\u5b58\u5668\u3001\u5199\u5165\u591a\u4e2a\u5bc4\u5b58\u5668\u7b49\u3002<\/p>\n<p>(1). \u529f\u80fd\u7801-0x03\u8bfb\u4fdd\u6301\u5bc4\u5b58\u5668&#xff1a;\u8be5\u529f\u80fd\u7801\u7528\u4e8e\u4ece\u8bbe\u5907\u4e2d\u8bfb\u53d6\u4e00\u4e2a\u6216\u591a\u4e2a\u4fdd\u6301\u5bc4\u5b58\u5668\u7684\u503c\u3002 (2). \u529f\u80fd\u7801-0x06\u5199\u5355\u4e2a\u5bc4\u5b58\u5668&#xff1a;\u8be5\u529f\u80fd\u7801\u7528\u4e8e\u5411\u8bbe\u5907\u4e2d\u5199\u5165\u4e00\u4e2a\u4fdd\u6301\u5bc4\u5b58\u5668\u7684\u503c\u3002 (3). \u529f\u80fd\u7801-0x10\u5199\u591a\u4e2a\u5bc4\u5b58\u5668&#xff1a;\u8be5\u529f\u80fd\u7801\u7528\u4e8e\u5411\u8bbe\u5907\u4e2d\u5199\u5165\u591a\u4e2a\u8fde\u7eed\u7684\u4fdd\u6301\u5bc4\u5b58\u5668\u7684\u503c\u3002<\/p>\n<\/p>\n<h4 id=\"%E5%B8%A7%E7%BB%93%E6%9E%84%E7%A4%BA%E4%BE%8B\">\u5e27\u7ed3\u6784\u793a\u4f8b<\/h4>\n<p>Modbus RTU \u529f\u80fd 01 \u7528\u4e8e\u4ece Modbus \u4ece\u7ad9\u6570\u636e\u91c7\u96c6\u8bbe\u5907\u8bfb\u53d6\u7ebf\u5708\u72b6\u6001\u6216\u6570\u5b57\u8f93\u51fa\u72b6\u6001\u3002\u8bf7\u53c2\u9605\u4e0b\u9762\u7684\u5178\u578b\u547d\u4ee4\u548c\u54cd\u5e94\u4ee5\u53ca\u4f7f\u7528\u8bf4\u660e\u3002<\/p>\n<p>\u00a0 \u00a0 \u4e3b\u673a\u53d1\u9001&#xff1a; \u00a001 03 00 00 00 01 84 0A \u00a0 \u00a0 \u4ece\u673a\u54cd\u5e94&#xff1a; \u00a001 03 02 19 98 B2 7E<\/p>\n<p>\u8be5\u4f8b\u5b50\u4e2d&#xff0c;\u4e3b\u673a\u53d1\u9001\u7684\u6570\u636e\u4e3a&#096;\u5730\u5740 &#043; \u529f\u80fd\u7801 &#043; \u6570\u636e &#043; \u6821\u9a8c&#096;\u200b&#xff0c;CRC\u6821\u9a8c\u7801\u662f\u6839\u636e\u524d\u9762\u7684\u6570\u636e\u8ba1\u7b97\u5f97\u51fa\u7684<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"469\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418182218-6802985a4ccc9.png\" width=\"1170\" \/><\/p>\n<p>\u56de\u590d\u7684\u6570\u636e\u683c\u5f0f<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"468\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418182218-6802985a90bc3.png\" width=\"1170\" \/><\/p>\n<p>\u200b<\/p>\n<hr \/>\n<h4 id=\"%E5%BA%94%E7%94%A8%E5%9C%BA%E6%99%AF%E4%B8%8E%E7%A4%BA%E4%BE%8B\">\u5e94\u7528\u573a\u666f\u4e0e\u793a\u4f8b<\/h4>\n<h5 id=\"1.%20PLC%20%E6%8E%A7%E5%88%B6%E7%94%B5%E6%9C%BA%E5%90%AF%E5%81%9C\">1. PLC \u63a7\u5236\u7535\u673a\u542f\u505c<\/h5>\n<ul>\n<li>\n<p>\u8bf7\u6c42\u5e27&#xff08;\u4e3b\u673a \u2192 \u4ece\u673a\u5730\u5740 0x02&#xff09;&#xff1a; 02 05 00 01 FF 00 8C 09<\/p>\n<ul>\n<li>\n<p>\u529f\u80fd\u7801\u00a00x05&#xff1a;\u5199\u5355\u4e2a\u7ebf\u5708\u3002<\/p>\n<\/li>\n<li>\n<p>\u5730\u5740\u00a00x0001&#xff1a;\u7535\u673a\u63a7\u5236\u5bc4\u5b58\u5668\u3002<\/p>\n<\/li>\n<li>\n<p>\u503c\u00a0FF 00&#xff1a;ON&#xff08;FF00\u00a0\u8868\u793a ON&#xff0c;0000\u00a0\u8868\u793a OFF&#xff09;\u3002<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h5 id=\"2.%20%E8%AF%BB%E5%8F%96%E6%B8%A9%E5%BA%A6%E4%BC%A0%E6%84%9F%E5%99%A8%E6%95%B0%E6%8D%AE\">2. \u8bfb\u53d6\u6e29\u5ea6\u4f20\u611f\u5668\u6570\u636e<\/h5>\n<ul>\n<li>\n<p>\u8bf7\u6c42\u5e27&#xff08;\u4e3b\u673a \u2192 \u4ece\u673a\u5730\u5740 0x03&#xff09;&#xff1a; 03 04 00 00 00 01 70 0B<\/p>\n<ul>\n<li>\n<p>\u529f\u80fd\u7801\u00a00x04&#xff1a;\u8bfb\u8f93\u5165\u5bc4\u5b58\u5668\u3002<\/p>\n<\/li>\n<li>\n<p>\u5730\u5740\u00a00x0000&#xff1a;\u6e29\u5ea6\u4f20\u611f\u5668\u5bc4\u5b58\u5668\u3002<\/p>\n<\/li>\n<li>\n<p>\u6570\u91cf\u00a00x0001&#xff1a;\u8bfb\u53d6 1 \u4e2a\u5bc4\u5b58\u5668\u3002<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<hr \/>\n<h4 id=\"CRC16%E6%A0%A1%E9%AA%8C%E7%AE%97%E6%B3%95\">CRC16\u6821\u9a8c\u7b97\u6cd5<\/h4>\n<p>CRC\u5168\u79f0\u5faa\u73af\u5197\u4f59\u6821\u9a8c(Cyclic Redundancy Check&#xff0c; CRC)&#xff0c;\u662f\u901a\u4fe1\u9886\u57df\u6570\u636e\u4f20\u8f93\u6280\u672f\u4e2d\u5e38\u7528\u7684\u68c0\u9519\u65b9\u6cd5&#xff0c;\u7528\u4e8e\u4fdd\u8bc1\u6570\u636e\u4f20\u8f93\u7684\u53ef\u9760\u6027\u3002<\/p>\n<p>CRC\u6821\u9a8c\u7684\u57fa\u672c\u601d\u8def\u662f\u6570\u636e\u53d1\u9001\u65b9\u53d1\u9001\u6570\u636e\u4e4b\u524d&#xff0c;\u5148\u751f\u6210\u4e00\u4e2aCRC\u6821\u9a8c\u7801&#xff0c;\u53ef\u4ee5\u662f\u5355bit\u4e5f\u53ef\u4ee5\u662f\u591abit&#xff0c;\u5e76\u9644\u5728\u6709\u6548\u6570\u636e\u672b\u5c3e&#xff0c;\u4ee5\u4e32\u884c\u65b9\u5f0f\u53d1\u9001\u5230\u63a5\u6536\u65b9\u3002\u63a5\u6536\u65b9\u63a5\u6536\u5230\u6570\u636e\u540e&#xff0c;\u8fdb\u884cCRC\u6821\u9a8c&#xff0c;\u6839\u636e\u6821\u9a8c\u7ed3\u679c\u5c31\u53ef\u4ee5\u77e5\u9053\u6570\u636e\u662f\u5426\u6709\u8bef\u3002<\/p>\n<p>CRC\u6821\u9a8c\u7801\u7684\u751f\u6210&#xff1a;\u5c06\u6709\u6548\u6570\u636e**\u6269\u5c55\u540e**\u4f5c\u4e3a\u88ab\u9664\u6570&#xff0c;\u4f7f\u7528\u4e00\u4e2a\u6307\u5b9a\u7684**\u591a\u9879\u5f0f**\u4f5c\u4e3a\u9664\u6570&#xff0c;\u8fdb\u884c\u6a21\u4e8c\u9664\u6cd5&#xff0c;\u5f97\u5230\u7684**\u4f59\u6570**\u5c31\u662f\u6821\u9a8c\u7801\u3002<\/p>\n<p>\u6570\u636e\u63a5\u6536\u65b9\u7684CRC\u6821\u9a8c&#xff1a;\u5c06\u63a5\u53d7\u7684\u6570\u636e(**\u6709\u6548\u6570\u636e&#043;CRC\u6821\u9a8c\u7801**)\u6269\u5c55\u540e\u4f5c\u4e3a\u88ab\u9664\u6570&#xff0c;\u7528\u6307\u5b9a\u7684\u591a\u9879\u5f0f\u4f5c\u4e3a\u9664\u6570&#xff0c;\u8fdb\u884c\u6a21\u4e8c\u9664\u6cd5&#xff0c;\u5f97\u5230**\u4f59\u6570\u4e3a0**&#xff0c;\u5219\u8868\u793a\u6821\u9a8c\u6b63\u786e\u3002<\/p>\n<p>\u6211\u4eec\u4f7f\u7528\u4ee3\u7801\u5411\u8bbe\u5907\u53d1\u9001\u547d\u4ee4\u5e27\u65f6\u9700\u8981\u4f7f\u7528CRC\u7b97\u6cd5\u8ba1\u7b97\u6821\u9a8c\u503c&#xff0c;\u5f53\u8bbe\u5907\u54cd\u5e94\u6570\u636e\u65f6\u4f7f\u7528CRC\u7b97\u6cd5\u6821\u9a8c\u8be5\u6570\u636e\u662f\u5426\u6b63\u786e&#xff0c;<\/p>\n<h5 id=\"CRC16%E7%AE%97%E6%B3%95%E7%9A%84%E8%BF%87%E7%A8%8B\">CRC16\u7b97\u6cd5\u7684\u8fc7\u7a0b<\/h5>\n<p>1 \u521d\u59cb\u5316\u4e00\u4e2a16\u4f4d\u7684\u5bc4\u5b58\u5668\u5730\u5740 \u7528\u4f5c\u521d\u59cb\u503c 2 \u904d\u5386\u6570\u636e\u5b57\u8282&#xff0c;\u4ece\u6700\u9ad8\u4f4d\u5230\u6700\u4f4e\u4f4d&#xff0c;\u00a0 3 \u5c06\u6570\u636e\u5b57\u8282\u4e0e\u5bc4\u5b58\u5668\u5f02\u6216 4 \u5bf9\u5bc4\u5b58\u5668\u8fdb\u884c8\u6b21\u8fed\u4ee3&#xff0c;\u6bcf\u4e00\u6b21\u8fed\u4ee3\u5c06\u5bc4\u5b58\u5668\u53f3\u79fb\u4e00\u4f4d 5 \u5982\u679c\u6700\u4f4e\u4f4d\u4f4d1&#xff0c;\u5c06\u5bc4\u5b58\u5668\u4e0e\u751f\u6210\u591a\u9879\u5f0f0x8005\u5f02\u6216&#xff0c;\u5426\u5219\u53ea\u8fdb\u884c\u53f3\u79fb\u64cd\u4f5c 6 \u91cd\u590d\u4e0a\u8ff0\u6b65\u9aa4\u76f4\u5230\u904d\u5386\u5b8c\u6240\u6709\u7684\u5b57\u8282 7 \u6700\u7ec8\u5bc4\u5b58\u5668\u7684\u503c\u5c31\u662fcrc16\u6821\u9a8c\u7801 8 crc\u8ba1\u7b97\u4e4b\u540e\u9ad8\u4f4e\u4f4d\u8fdb\u884c\u4e92\u6362<\/p>\n<p>\u4ee5\u4e0b\u662f\u5c01\u88c5\u7684CRC16\u6548\u9a8c\u7b97\u6cd5\u7c7b&#xff1a;<\/p>\n<p>\u00a0 \u00a0 public static class CRC16<br \/>\n\u00a0 \u00a0 {<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \/\/\/ &lt;summary&gt;<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \/\/\/ CRC\u6821\u9a8c&#xff0c;\u53c2\u6570data\u4e3abyte\u6570\u7ec4<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \/\/\/ &lt;\/summary&gt;<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \/\/\/ &lt;param name&#061;&#034;data&#034;&gt;\u6821\u9a8c\u6570\u636e&#xff0c;\u5b57\u8282\u6570\u7ec4&lt;\/param&gt;<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \/\/\/ &lt;returns&gt;\u5b57\u82820\u662f\u9ad88\u4f4d&#xff0c;\u5b57\u82821\u662f\u4f4e8\u4f4d&lt;\/returns&gt;<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 public static byte[] CRCCalc(byte[] data)<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 {<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \/\/crc\u8ba1\u7b97\u8d4b\u521d\u59cb\u503c<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 int crc &#061; 0xffff;<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 for (int i &#061; 0; i &lt; data.Length; i&#043;&#043;)<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 {<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 crc &#061; crc ^ data[i];<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 for (int j &#061; 0; j &lt; 8; j&#043;&#043;)<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 {<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 int temp;<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 temp &#061; crc &amp; 1;<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 crc &#061; crc &gt;&gt; 1;<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 crc &#061; crc &amp; 0x7fff;<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 if (temp &#061;&#061; 1)<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 {<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 crc &#061; crc ^ 0xa001;<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 }<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 crc &#061; crc &amp; 0xffff;<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 }<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 }<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \/\/CRC\u5bc4\u5b58\u5668\u7684\u9ad8\u4f4e\u4f4d\u8fdb\u884c\u4e92\u6362<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 byte[] crc16 &#061; new byte[2];<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \/\/CRC\u5bc4\u5b58\u5668\u7684\u9ad88\u4f4d\u53d8\u6210\u4f4e8\u4f4d&#xff0c;<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 crc16[1] &#061; (byte)((crc &gt;&gt; 8) &amp; 0xff);<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \/\/CRC\u5bc4\u5b58\u5668\u7684\u4f4e8\u4f4d\u53d8\u6210\u9ad88\u4f4d<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 crc16[0] &#061; (byte)(crc &amp; 0xff);<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 return crc16;<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 }<br \/>\n\u00a0 \u00a0\u00a0<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \/\/\/ &lt;summary&gt;<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \/\/\/ CRC\u6821\u9a8c&#xff0c;\u53c2\u6570\u4e3a\u7a7a\u683c\u6216\u9017\u53f7\u95f4\u9694\u7684\u5b57\u7b26\u4e32<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \/\/\/ &lt;\/summary&gt;<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \/\/\/ &lt;param name&#061;&#034;data&#034;&gt;\u6821\u9a8c\u6570\u636e&#xff0c;\u9017\u53f7\u6216\u7a7a\u683c\u95f4\u9694\u768416\u8fdb\u5236\u5b57\u7b26\u4e32(\u5e26\u67090x\u62160X\u4e5f\u53ef\u4ee5),\u9017\u53f7\u4e0e\u7a7a\u683c\u4e0d\u80fd\u6df7\u7528&lt;\/param&gt;<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \/\/\/ &lt;returns&gt;\u5b57\u82820\u662f\u9ad88\u4f4d&#xff0c;\u5b57\u82821\u662f\u4f4e8\u4f4d&lt;\/returns&gt;<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 public static byte[] CRCCalc(string data)<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 {<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \/\/\u5206\u9694\u7b26\u662f\u7a7a\u683c\u8fd8\u662f\u9017\u53f7\u8fdb\u884c\u5206\u7c7b&#xff0c;\u5e76\u53bb\u9664\u8f93\u5165\u5b57\u7b26\u4e32\u4e2d\u7684\u591a\u4f59\u7a7a\u683c<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 IEnumerable&lt;string&gt; datac &#061; data.Contains(&#034;,&#034;) ? data.Replace(&#034; &#034;, &#034;&#034;).Replace(&#034;0x&#034;, &#034;&#034;).Replace(&#034;0X&#034;, &#034;&#034;).Trim().Split(&#039;,&#039;) : data.Replace(&#034;0x&#034;, &#034;&#034;).Replace(&#034;0X&#034;, &#034;&#034;).Split(&#039; &#039;).ToList().Where(u &#061;&gt; u !&#061; &#034;&#034;);<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 List&lt;byte&gt; bytedata &#061; new List&lt;byte&gt;();<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 foreach (string str in datac)<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 {<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 bytedata.Add(byte.Parse(str, System.Globalization.NumberStyles.AllowHexSpecifier));<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 }<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 byte[] crcbuf &#061; bytedata.ToArray();<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \/\/crc\u8ba1\u7b97\u8d4b\u521d\u59cb\u503c<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 return CRCCalc(crcbuf);<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 }<br \/>\n\u00a0 \u00a0\u00a0<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \/\/\/ &lt;summary&gt;<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \/\/\/ \u00a0CRC\u6821\u9a8c&#xff0c;\u622a\u53d6data\u4e2d\u7684\u4e00\u6bb5\u8fdb\u884cCRC16\u6821\u9a8c<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \/\/\/ &lt;\/summary&gt;<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \/\/\/ &lt;param name&#061;&#034;data&#034;&gt;\u6821\u9a8c\u6570\u636e&#xff0c;\u5b57\u8282\u6570\u7ec4&lt;\/param&gt;<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \/\/\/ &lt;param name&#061;&#034;offset&#034;&gt;\u4ece\u5934\u5f00\u59cb\u504f\u79fb\u51e0\u4e2abyte&lt;\/param&gt;<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \/\/\/ &lt;param name&#061;&#034;length&#034;&gt;\u504f\u79fb\u540e\u53d6\u51e0\u4e2a\u5b57\u8282byte&lt;\/param&gt;<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \/\/\/ &lt;returns&gt;\u5b57\u82820\u662f\u9ad88\u4f4d&#xff0c;\u5b57\u82821\u662f\u4f4e8\u4f4d&lt;\/returns&gt;<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 public static byte[] CRCCalc(byte[] data, int offset, int length)<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 {<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 byte[] Tdata &#061; data.Skip(offset).Take(length).ToArray();<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 return CRCCalc(Tdata);<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 }<br \/>\n\u00a0 \u00a0 } <\/p>\n<hr \/>\n<\/p>\n<h3 id=\"modbus-rtu%E7%9A%84%E4%BD%BF%E7%94%A8\">modbus-rtu\u7684\u4f7f\u7528<\/h3>\n<h4 id=\"%E5%8F%91%E9%80%81%E6%95%B0%E6%8D%AE\">\u53d1\u9001\u6570\u636e<\/h4>\n<p>\u73b0\u8981\u8bfb\u53d6\u53d8\u9001\u5668\u8bbe\u5907&#xff08;\u5730\u5740 0x01&#xff09;\u7684\u98ce\u901f\u503c&#xff0c;\u6587\u6863\u5982\u56fe\u6240\u793a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"95\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418182218-6802985ad341b.png\" width=\"745\" \/><\/p>\n<p>\u6211\u4eec\u53d1\u9001\u7684\u547d\u4ee4\u5e27\u5e94\u4e3a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"124\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418182218-6802985ae9458.png\" width=\"915\" \/><\/p>\n<p>\u6839\u636e\u547d\u4ee4\u5e27\u8ba1\u7b97\u6821\u9a8c\u7801&#xff08;3\u79cd\u65b9\u5f0f&#xff09;<\/p>\n<p>\u00a0 \u00a0 byte[] buffer &#061; new byte[] { 0x01, 0x03, 0x00, 0x00, 0x00, 0x01 };<br \/>\n\u00a0 \u00a0 byte[] crc16 &#061; CRC16.CRCCalc(buffer); \u00a0\/\/ \u6839\u636e\u5b57\u8282\u6570\u7ec4\u8ba1\u7b97<br \/>\n\u00a0 \u00a0 Console.WriteLine($&#034;{crc16[0]:X2} {crc16[1]:X2}&#034;);<br \/>\n\u00a0 \u00a0\u00a0<br \/>\n\u00a0 \u00a0 string data1 &#061; &#034;0x01,0x03,0x00,0x00,0x00,0x02&#034;;<br \/>\n\u00a0 \u00a0 string data1 &#061; &#034;0x01 0x03 0x00 0x00 0x00 0x02&#034;;<br \/>\n\u00a0 \u00a0 byte[] crc16 &#061; CRC16.CRCCalc(data1); \u00a0 \u00a0\/\/ \u6839\u636e\u5b57\u7b26\u4e32\u8ba1\u7b97<br \/>\n\u00a0 \u00a0 Console.WriteLine($&#034;{crc16[0]:X2} {crc16[1]:X2}&#034;);<br \/>\n\u00a0 \u00a0\u00a0<br \/>\n\u00a0 \u00a0 \u00a0byte[] buffer &#061; new byte[] { 0x01, 0x03, 0x00, 0x00, 0x00, 0x02, 0xC4, 0x0B };<br \/>\n\u00a0 \u00a0 \u00a0byte[] crc16 &#061; CRC16Calc(buffer,0,6); \u00a0\/\/ \u4ece\u5b57\u8282\u6570\u7ec4\u4e2d\u622a\u53d6\u67d0\u90e8\u5206\u8ba1\u7b97<br \/>\n\u00a0 \u00a0 \u00a0Console.WriteLine($&#034;{crc16[0]:X2} {crc16[1]:X2}&#034;); <\/p>\n<p>\u5c06\u6570\u636e\u548c\u6821\u9a8c\u7801\u6570\u7ec4\u8fdb\u884c\u5408\u5e76\u7136\u540e\u53d1\u9001<\/p>\n<p>\u00a0 \u00a0 byte[] buffer &#061; new byte[] { 0x01, 0x03, 0x00, 0x00, 0x00, 0x01 };<br \/>\n\u00a0 \u00a0 byte[] crc16 &#061; CRC16.CRCCalc(buffer);<br \/>\n\u00a0 \u00a0 byte[] data &#061; buffer.Concat(crc16).ToArray();<br \/>\n\u00a0 \u00a0 serialPort.Write(data, 0, data.Length); <\/p>\n<\/p>\n<h4 id=\"%E6%8E%A5%E6%94%B6%E6%95%B0%E6%8D%AE\">\u63a5\u6536\u6570\u636e<\/h4>\n<p>\u6211\u4eec\u5c06\u547d\u4ee4\u5e27&#xff08;\u8bf7\u6c42\u5e27\u3001\u95ee\u8be2\u7801&#xff09;\u53d1\u9001\u540e&#xff0c;\u5982\u679c\u6ca1\u6709\u9519\u8bef&#xff0c;\u4ece\u8bbe\u5907\u4f1a\u8fd4\u56de\u5bf9\u5e94\u7684\u6570\u636e&#xff0c;\u5982\u4e0b\u8bfb\u53d6\u53d8\u9001\u5668\u8bbe\u5907&#xff08;\u5730\u5740 0x01&#xff09;\u7684\u5b9e\u65f6\u98ce\u529b\u7b49\u7ea7\u503c&#xff0c;\u5c06\u4f1a\u8fd4\u56de\u5982\u56fe\u6240\u793a\u7684\u6570\u636e&#xff0c;\u6211\u4eec\u9700\u8981\u5c06\u6570\u636e\u8bfb\u53d6\u3001\u6821\u9a8c\u3001\u8ba1\u7b97\u3001\u5c55\u793a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"301\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418182219-6802985b111b2.png\" width=\"755\" \/><\/p>\n<p>\u00a0 \u00a0 \/\/ \u5047\u8bbe\u8fd9\u662f\u4ece\u8bbe\u5907\u54cd\u5e94\u7684\u6570\u636e<br \/>\n\u00a0 \u00a0 \/\/ 0x01&#xff1a;\u8bbe\u5907\u5730\u5740\u7801<br \/>\n\u00a0 \u00a0 \/\/ 0x03&#xff1a;\u529f\u80fd\u7801<br \/>\n\u00a0 \u00a0 \/\/ 0x02&#xff1a;\u8bfb\u53d6\u5230\u7684\u6570\u636e\u5b57\u8282<br \/>\n\u00a0 \u00a0 \/\/ 0x00, 0x01&#xff1a;\u5f53\u524d\u98ce\u529b\u7b49\u7ea7<br \/>\n\u00a0 \u00a0 \/\/ 0x79, 0x84&#xff1a;\u6821\u9a8c\u7801<br \/>\n\u00a0 \u00a0 byte[] value &#061; new byte[] { 0x01, 0x03, 0x02, 0x00, 0x01, 0x79, 0x84 };<br \/>\n\u00a0 \u00a0 \/\/ 1\u3001\u9a8c\u8bc1\u6821\u9a8c\u7801\u662f\u5426\u6b63\u786e<br \/>\n\u00a0 \u00a0 byte[] crc &#061; CRC16.CRCCalc(value, 0, value.Length &#8211; 2);<br \/>\n\u00a0 \u00a0 if (crc[0] !&#061; value[value.Length &#8211; 2] || crc[1] !&#061; value[value.Length-1] ) {<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 MessageBox.Show(&#034;\u6570\u636e\u6821\u9a8c\u9519\u8bef&#xff0c;\u5e94\u5ffd\u7565&#034;);<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 return;<br \/>\n\u00a0 \u00a0 }<br \/>\n\u00a0 \u00a0 \/\/ 2\u3001\u9a8c\u8bc1\u8bbe\u5907\u5730\u5740<br \/>\n\u00a0 \u00a0 if (value[0] !&#061; \u00a00x01)<br \/>\n\u00a0 \u00a0 {<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 MessageBox.Show(&#034;\u8bbe\u5907\u5730\u5740\u4e0d\u6b63\u786e&#034;);<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 return;<br \/>\n\u00a0 \u00a0 }<br \/>\n\u00a0 \u00a0 \/\/ 3\u3001\u8ba1\u7b97\u6570\u636e<br \/>\n\u00a0 \u00a0 \/\/ int v &#061; value[3] * 256 &#043; value[4]; \u00a0\/\/ \u56e0\u4e3a\u8fd9\u4e2a\u6570\u636e\u5360\u4e24\u4e2a\u5b57\u8282&#xff0c;\u6bcf\u4e2a\u5b57\u8282\u6700\u5927255&#xff0c;\u76f8\u5f53\u4e8e256\u8fdb\u5236&#xff0c;\u8f6c\u6362\u4e3a10\u8fdb\u5236<br \/>\n\u00a0 \u00a0 int v &#061; (value[3] &lt;&lt; 8) &#043; value[4]; \u00a0 \u00a0 \u00a0 \/\/ \u4e5f\u53ef\u4ee5\u4f7f\u7528\u5de6\u79fb\u8fd0\u7b97\u7b26&#xff0c;\u9ad8\u4f4d\u5de6\u79fb8\u4f4d&#xff0c;\u76f8\u5f53\u4e8e\u4e582\u76848\u6b21\u65b9<br \/>\n\u00a0 \u00a0\u00a0<br \/>\n\u00a0 \u00a0 \/\/ 4\u3001\u6570\u636e\u5c55\u793a<br \/>\n\u00a0 \u00a0 MessageBox.Show(&#034;\u98ce\u529b\u7b49\u7ea7&#xff1a;&#034; &#043; v); <\/p>\n<\/p>\n<h4 id=\"tcp%E7%BD%91%E5%8F%A3%E5%AE%8C%E6%95%B4%E5%AE%9E%E7%8E%B0modbus-rtu%E5%8D%8F%E8%AE%AE\">tcp\u7f51\u53e3\u5b8c\u6574\u5b9e\u73b0modbus-rtu\u534f\u8bae<\/h4>\n<p>public partial class Form1 : Form<br \/>\n{<br \/>\n    \/\/\/ &lt;summary&gt;<br \/>\n    \/\/\/ \u5957\u63a5\u5b57<br \/>\n    \/\/\/ &lt;\/summary&gt;<br \/>\n    Socket socket;<\/p>\n<p>    \/\/\/ &lt;summary&gt;<br \/>\n    \/\/\/ IP\u5730\u5740<br \/>\n    \/\/\/ &lt;\/summary&gt;<br \/>\n    string Ip &#061; &#034;192.168.107.5&#034;;<\/p>\n<p>    \/\/\/ &lt;summary&gt;<br \/>\n    \/\/\/ \u7aef\u53e3<br \/>\n    \/\/\/ &lt;\/summary&gt;<br \/>\n    string Dk &#061; &#034;8016&#034;;<\/p>\n<p>    \/\/\/ &lt;summary&gt;<br \/>\n    \/\/\/ \u547d\u4ee4\u5e27<br \/>\n    \/\/\/ &lt;\/summary&gt;<br \/>\n    string Icommand &#061; &#034;01 03 00 00 00 02&#034;;<\/p>\n<p>    public Form1()<br \/>\n    {<br \/>\n        InitializeComponent();<br \/>\n        button1.Enabled &#061; false;<br \/>\n        checkBox1.Enabled &#061; false;<br \/>\n    }<\/p>\n<p>    \/\/\/ &lt;summary&gt;<br \/>\n    \/\/\/ \u6253\u5f00\u8fde\u63a5<br \/>\n    \/\/\/ &lt;\/summary&gt;<br \/>\n    \/\/\/ &lt;param name&#061;&#034;sender&#034;&gt;&lt;\/param&gt;<br \/>\n    \/\/\/ &lt;param name&#061;&#034;e&#034;&gt;&lt;\/param&gt;<br \/>\n    private void button2_Click(object sender, EventArgs e)<br \/>\n    {<br \/>\n        if (button2.Text &#061;&#061; &#034;\u8fde\u63a5\u7f51\u53e3&#034;)<br \/>\n        {<br \/>\n            try<br \/>\n            {<br \/>\n                socket &#061; new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);<br \/>\n                socket.Connect(Ip, int.Parse(Dk));<\/p>\n<p>                button1.Enabled &#061; true;<br \/>\n                checkBox1.Enabled &#061; true;<br \/>\n                button2.Text &#061; &#034;\u65ad\u5f00&#034;;<br \/>\n                this.timer1.Start();<br \/>\n            }<br \/>\n            catch (Exception ex)<br \/>\n            {<br \/>\n                MessageBox.Show(ex.Message);<br \/>\n            }<br \/>\n        }<br \/>\n        else<br \/>\n        {<br \/>\n            if (socket &#061;&#061; null) return;<br \/>\n            socket.Close();<br \/>\n            button1.Enabled &#061; false;<br \/>\n            checkBox1.Enabled &#061; false;<br \/>\n            checkBox1.Checked &#061; false;<br \/>\n            button2.Text &#061; &#034;\u8fde\u63a5\u7f51\u53e3&#034;;<br \/>\n            this.timer1.Stop();<br \/>\n        }<\/p>\n<p>    }<\/p>\n<p>    \/\/\/ &lt;summary&gt;<br \/>\n    \/\/\/ \u5237\u65b0\u98ce\u901f\u98ce\u5411\u6570\u636e<br \/>\n    \/\/\/ &lt;\/summary&gt;<br \/>\n    \/\/\/ &lt;param name&#061;&#034;sender&#034;&gt;&lt;\/param&gt;<br \/>\n    \/\/\/ &lt;param name&#061;&#034;e&#034;&gt;&lt;\/param&gt;<br \/>\n    private async void button1_Click(object sender, EventArgs e)<br \/>\n    {<br \/>\n        byte[] bs &#061; new byte[1024];<br \/>\n        bs &#061; StringToByte(Icommand);<br \/>\n        byte[] bb &#061; CRCCalc(bs);<br \/>\n        bs &#061; bs.Concat(bb).ToArray();<br \/>\n        await Task.Run(() &#061;&gt;<br \/>\n        {<br \/>\n            socket.Send(bs); \/\/ \u53d1\u9001\u8bf7\u6c42\u5e27<\/p>\n<p>            byte[] body &#061; new byte[1024];<br \/>\n            int length &#061; socket.Receive(body); \/\/ \u83b7\u53d6\u54cd\u5e94\u5e27<\/p>\n<p>            double value &#061; (body[3] * 256&#043; body[4]) *0.01;<br \/>\n            double value2 &#061; (body[5] * 256 &#043; body[6]);<br \/>\n            this.Invoke(new Action(() &#061;&gt;<br \/>\n            {<br \/>\n                this.textBox1.Text &#061; value.ToString() &#043; &#034;m\/s&#034;;<br \/>\n                this.textBox2.Text &#061; value2.ToString();<br \/>\n            }));<\/p>\n<p>        });<\/p>\n<p>    }<\/p>\n<p>    \/\/\/ &lt;summary&gt;<br \/>\n    \/\/\/ \u5b57\u7b26\u4e32\u8f6c\u5b57\u8282<br \/>\n    \/\/\/ &lt;\/summary&gt;<br \/>\n    \/\/\/ &lt;param name&#061;&#034;s&#034;&gt;&lt;\/param&gt;<br \/>\n    \/\/\/ &lt;returns&gt;&lt;\/returns&gt;<br \/>\n    byte[] StringToByte(string s)<br \/>\n    {<br \/>\n        string[] strings &#061; s.Split(&#039; &#039;) ;<br \/>\n        byte[] bs &#061; new byte[strings.Length];<br \/>\n        for (int i &#061; 0; i &lt; strings.Length; i&#043;&#043;)<br \/>\n        {<br \/>\n            bs[i] &#061; Convert.ToByte(strings[i],16);<br \/>\n        }<br \/>\n        return bs;<br \/>\n    }<\/p>\n<p>    \/\/\/ &lt;summary&gt;<br \/>\n    \/\/\/ CRC\u6548\u9a8c<br \/>\n    \/\/\/ &lt;\/summary&gt;<br \/>\n    \/\/\/ &lt;param name&#061;&#034;data&#034;&gt;&lt;\/param&gt;<br \/>\n    \/\/\/ &lt;returns&gt;&lt;\/returns&gt;<br \/>\n    public static byte[] CRCCalc(byte[] data)<br \/>\n    {<br \/>\n        \/\/crc\u8ba1\u7b97\u8d4b\u521d\u59cb\u503c<br \/>\n        int crc &#061; 0xffff;<br \/>\n        for (int i &#061; 0; i &lt; data.Length; i&#043;&#043;)<br \/>\n        {<br \/>\n            \/\/XOR<br \/>\n            \/\/(1) 0^0&#061;0,0^1&#061;1  0\u5f02\u6216\u4efb\u4f55\u6570&#xff1d;\u4efb\u4f55\u6570<br \/>\n            \/\/(2) 1 ^ 0 &#061; 1,1 ^ 1 &#061; 0  1\u5f02\u6216\u4efb\u4f55\u6570&#xff0d;\u4efb\u4f55\u6570\u53d6\u53cd<br \/>\n            \/\/(3) 1 ^ 1 &#061; 0,0 ^ 0 &#061; 0  \u4efb\u4f55\u6570\u5f02\u6216\u81ea\u5df1&#xff1d;\u628a\u81ea\u5df1\u7f6e0<br \/>\n            \/\/\u5f02\u6216\u64cd\u4f5c\u7b26\u662f^\u3002\u5f02\u6216\u7684\u7279\u70b9\u662f\u76f8\u540c\u4e3afalse&#xff0c;\u4e0d\u540c\u4e3atrue\u3002<br \/>\n            crc &#061; crc ^ data[i]; \/\/\u548c^\u8868\u793a\u6309\u4f4d\u5f02\u6216\u8fd0\u7b97\u3002<br \/>\n                                 \/\/0x0fff ^ 0x01 Console.WriteLine(result.ToString(&#034;X&#034;));<br \/>\n                                 \/\/ \u8f93\u51fa\u7ed3\u679c\u4e3a4094&#xff0c;\u5373\u5341\u516d\u8fdb\u5236\u65701001<br \/>\n            for (int j &#061; 0; j &lt; 8; j&#043;&#043;)<br \/>\n            {<br \/>\n                int temp;<br \/>\n                temp &#061; crc &amp; 1; \/\/ &amp; \u8fd0\u7b97\u7b26(\u4e0e) 1 &amp; 0 \u4e3a 0  ;0 &amp; 0 \u4e3a0;1 &amp; 1 \u4e3a1<\/p>\n<p>                \/\/\u53f3\u79fb (&gt;&gt;) \u5c06\u7b2c\u4e00\u4e2a\u64cd\u4f5c\u6570\u5411\u53f3\u79fb\u52a8\u7b2c\u4e8c\u4e2a\u64cd\u4f5c\u6570\u6240\u6307\u5b9a\u7684\u4f4d\u6570&#xff0c;\u7a7a\u51fa\u7684\u4f4d\u7f6e\u88650\u3002\u53f3\u79fb\u76f8\u5f53\u4e8e\u6574\u9664. \u53f3\u79fb\u4e00\u4f4d\u76f8\u5f53\u4e8e\u9664\u4ee52;\u53f3\u79fb\u4e24\u4f4d\u76f8\u5f53\u4e8e\u9664\u4ee54;\u53f3\u79fb\u4e09\u4f4d\u76f8\u5f53\u4e8e\u9664\u4ee58\u3002<br \/>\n                \/\/int i &#061; 7;<br \/>\n                \/\/int j &#061; 2;<br \/>\n                \/\/Console.WriteLine(i &gt;&gt; j);   \/\/\u8f93\u51fa\u7ed3\u679c\u4e3a1<br \/>\n                crc &#061; crc &gt;&gt; 1;<br \/>\n                crc &#061; crc &amp; 0x7fff;<br \/>\n                if (temp &#061;&#061; 1)<br \/>\n                {<br \/>\n                    crc &#061; crc ^ 0xa001;<br \/>\n                }<br \/>\n                crc &#061; crc &amp; 0xffff;<br \/>\n            }<br \/>\n        }<br \/>\n        \/\/CRC\u5bc4\u5b58\u5668\u7684\u9ad8\u4f4e\u4f4d\u8fdb\u884c\u4e92\u6362<br \/>\n        byte[] crc16 &#061; new byte[2];<br \/>\n        \/\/CRC\u5bc4\u5b58\u5668\u7684\u9ad88\u4f4d\u53d8\u6210\u4f4e8\u4f4d&#xff0c;<br \/>\n        crc16[1] &#061; (byte)((crc &gt;&gt; 8) &amp; 0xff);<br \/>\n        \/\/CRC\u5bc4\u5b58\u5668\u7684\u4f4e8\u4f4d\u53d8\u6210\u9ad88\u4f4d<br \/>\n        crc16[0] &#061; (byte)(crc &amp; 0xff);<br \/>\n        return crc16;<br \/>\n    }<br \/>\n} <\/p>\n<hr \/>\n<\/p>\n<h3 id=\"Modbus-RTU%E5%92%8CModbus-TCP%E7%9A%84%E8%B6%8B%E5%8C%BA%E5%88%AB\">Modbus-RTU\u548cModbus-TCP\u7684\u8d8b\u533a\u522b<\/h3>\n<table>\n<tr>\u7279\u6027Modbus-RTUModbus-TCP<\/tr>\n<tbody>\n<tr>\n<td>\u7269\u7406\u5c42<\/td>\n<td>RS-485\/RS-232<\/td>\n<td>\u4ee5\u592a\u7f51&#xff08;RJ45&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\u4f20\u8f93\u901f\u7387<\/td>\n<td>\u6700\u9ad8 115.2 kbps<\/td>\n<td>100 Mbps ~ 1 Gbps<\/td>\n<\/tr>\n<tr>\n<td>\u62d3\u6251\u7ed3\u6784<\/td>\n<td>\u603b\u7ebf\u578b<\/td>\n<td>\u661f\u578b\/\u6811\u578b\/\u7f51\u72b6<\/td>\n<\/tr>\n<tr>\n<td>\u5b9e\u65f6\u6027<\/td>\n<td>\u9ad8&#xff08;\u786e\u5b9a\u6027\u5ef6\u8fdf&#xff09;<\/td>\n<td>\u4f9d\u8d56\u7f51\u7edc\u72b6\u51b5<\/td>\n<\/tr>\n<tr>\n<td>\u6269\u5c55\u6027<\/td>\n<td>\u6709\u9650&#xff08;\u53d7\u603b\u7ebf\u957f\u5ea6\u9650\u5236&#xff09;<\/td>\n<td>\n<p>\u9ad8&#xff08;\u652f\u6301\u8de8\u7f51\u6bb5\u901a\u4fe1&#xff09;<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<\/p>\n<h3 id=\"%E4%BD%BF%E7%94%A8NModbus4%E5%AE%9E%E7%8E%B0modbus-rtu%E5%8D%8F%E8%AE%AE\">\u4f7f\u7528NModbus4\u5b9e\u73b0modbus-rtu\u534f\u8bae<\/h3>\n<p>NModbus4\u662f\u4e00\u4e2aC#\u5b9e\u73b0\u7684Modbus\u5e93&#xff0c;\u5b83\u5141\u8bb8\u5f00\u53d1\u8005\u4ee5Modbus RTU\u7684\u65b9\u5f0f\u4e0e\u5de5\u4e1a\u8bbe\u5907\u8fdb\u884c\u901a\u4fe1\u3002<\/p>\n<h4 id=\"%E5%AE%89%E8%A3%85NModbus4%E5%BA%93%E3%80%82\">\u5b89\u88c5NModbus4\u5e93\u3002<\/h4>\n<p>\u901a\u8fc7NuGet\u5b89\u88c5NModbus4<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"143\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418182219-6802985b2cceb.png\" width=\"938\" \/><\/p>\n<h4 id=\"%E4%B8%B2%E5%8F%A3%E5%AE%9E%E7%8E%B0NModbus4\">\u4e32\u53e3\u5b9e\u73b0NModbus4<\/h4>\n<p>public partial class Form1 : Form<br \/>\n{<br \/>\n    \/\/ \u521b\u5efa\u5bf9\u8c61<br \/>\n    ModbusSerialMaster master;<br \/>\n    public Form1()<br \/>\n    {<br \/>\n        InitializeComponent();<br \/>\n        this.serialPort1.PortName &#061; &#034;COM2&#034;; \/\/ \u4e32\u53e3\u540d<br \/>\n        this.serialPort1.BaudRate &#061; 9600;<br \/>\n        this.serialPort1.DataBits &#061; 8;<br \/>\n        this.serialPort1.Parity &#061;System.IO.Ports.Parity.None;<br \/>\n        this.serialPort1.StopBits &#061; System.IO.Ports.StopBits.One;<\/p>\n<p>        serialPort1.Open();<br \/>\n        master &#061; ModbusSerialMaster.CreateRtu(serialPort1);<br \/>\n    }<\/p>\n<p>    \/\/\/ &lt;summary&gt;<br \/>\n    \/\/\/  \u8bfb\u53d6\u6570\u636e<br \/>\n    \/\/\/ &lt;\/summary&gt;<br \/>\n    \/\/\/ &lt;param name&#061;&#034;sender&#034;&gt;&lt;\/param&gt;<br \/>\n    \/\/\/ &lt;param name&#061;&#034;e&#034;&gt;&lt;\/param&gt;<br \/>\n    private async void button1_Click(object sender, EventArgs e)<br \/>\n    {<br \/>\n        \/\/ ReadHoldingRegistersAsync \u5f02\u6b65\u8bfb\u53d6\u6570\u636e<br \/>\n        \/\/ await \u7b49\u5f85\u5f02\u6b65\u4efb\u52a1\u6267\u884c\u5b8c\u4e4b\u540e \u518d\u5f80\u4e0b\u6267\u884c<br \/>\n        \/\/ \u53c2\u65701 \u4ece\u7ad9\u5730\u5740&#xff0c; \u53c2\u65702 \u8d77\u59cb\u5730\u5740  \u53c2\u65703&#xff1a;\u5bc4\u5b58\u5668\u4e2a\u6570<br \/>\n        \/\/ values \u5143\u7d20\u4e2a\u6570\u548c\u5bc4\u5b58\u5668\u4e2a\u6570\u6709\u5173<br \/>\n        ushort[] values &#061; await master.ReadHoldingRegistersAsync(1,0&#215;00,3);<br \/>\n        comboBox1.DataSource &#061; values;<br \/>\n    }<\/p>\n<p>    \/\/\/ &lt;summary&gt;<br \/>\n    \/\/\/ \u5199\u5165\u6570\u636e<br \/>\n    \/\/\/ &lt;\/summary&gt;<br \/>\n    \/\/\/ &lt;param name&#061;&#034;sender&#034;&gt;&lt;\/param&gt;<br \/>\n    \/\/\/ &lt;param name&#061;&#034;e&#034;&gt;&lt;\/param&gt;<br \/>\n    private async void button2_Click(object sender, EventArgs e)<br \/>\n    {<br \/>\n        \/\/ \u5199\u5165 \u5355\u4e2a\u7684\u5bc4\u5b58\u5668<br \/>\n        \/\/ \u53c2\u65701 \u4ece\u7ad9\u5730\u5740<br \/>\n        \/\/ \u53c2\u65702 \u5199\u5165\u7684\u5730\u5740<br \/>\n        \/\/ \u53c2\u65703 \u5199\u5165\u7684\u6570\u636e<br \/>\n        \/\/ short \u77ed\u6574\u578b<br \/>\n        \/\/ ushort \u65e0\u7b26\u53f7\u7684\u77ed\u6574\u578b<br \/>\n        await master.WriteSingleRegisterAsync(1,0&#215;04,14);<br \/>\n    }<br \/>\n} <\/p>\n<\/p>\n<\/p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.7w\u6b21\uff0c\u70b9\u8d5e70\u6b21\uff0c\u6536\u85cf94\u6b21\u3002Modbus RTU \u534f\u8bae\u662f\u4e00\u79cd\u5f00\u653e\u7684\u4e32\u884c\u534f\u8bae\uff0c\u5e7f\u6cdb\u5e94\u7528\u4e8e\u5f53\u4eca\u7684\u5de5\u4e1a\u76d1\u63a7\u8bbe\u5907\u4e2d\u3002\u8be5\u534f\u8bae\u4f7f\u7528 RS-232 \u6216 RS-485 \u4e32\u884c\u63a5\u53e3\u8fdb\u884c\u901a\u4fe1\uff0c\u5e76\u5f97\u5230\u5e02\u573a\u4e0a\u51e0\u4e4e\u6240\u6709\u5546\u4e1a SCADA\u3001HMI\u3001OPC \u670d\u52a1\u5668\u548c\u6570\u636e\u91c7\u96c6\u8f6f\u4ef6\u7a0b\u5e8f\u7684\u652f\u6301\u3002\u56e0\u6b64\uff0c\u5f88\u5bb9\u6613\u5c06 Modbus \u517c\u5bb9\u8bbe\u5907\u96c6\u6210\u5230\u65b0\u7684\u6216\u73b0\u6709\u7684\u76d1\u63a7\u5e94\u7528\u7a0b\u5e8f\u4e2d\uff0c\u5e76\u5177\u6709\u5373\u65f6\u7684\u8f6f\u4ef6\u652f\u6301\u3002\u5e27\u7ed3\u6784\uff1a\u8bbe\u5907\u5730\u5740\u3001\u529f\u80fd\u7801\u3001\u6570\u636e\u548cCRC\u6821\u9a8c\u5b57\u6bb5\u3002\u5e38\u7528\u529f\u80fd\u7801\uff1aModbus-RTU\u534f\u8bae\u5b9a\u4e49\u4e86\u4e00\u7cfb\u5217\u5e38\u7528\u7684\u529f\u80fd\u7801\uff0c\u7528\u4e8e\u6267\u884c\u4e0d\u540c\u7684\u64cd\u4f5c\uff0c\u5982\u8bfb\u53d6\u4fdd\u6301\u5bc4\u5b58\u5668\u3001\u5199\u5165\u5355\u4e2a\u5bc4\u5b58\u5668\u3001\u5199\u5165\u591a\u4e2a\u5bc4\u5b58\u5668\u7b49\u3002_modbus rtu<\/p>\n","protected":false},"author":2,"featured_media":19766,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[1537,205,43,78,191],"topic":[],"class_list":["post-19773","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-modbus","tag-tcp-ip","tag-43","tag-78","tag-191"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Modbus-RTU\u8be6\u89e3 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/19773.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Modbus-RTU\u8be6\u89e3 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.7w\u6b21\uff0c\u70b9\u8d5e70\u6b21\uff0c\u6536\u85cf94\u6b21\u3002Modbus RTU \u534f\u8bae\u662f\u4e00\u79cd\u5f00\u653e\u7684\u4e32\u884c\u534f\u8bae\uff0c\u5e7f\u6cdb\u5e94\u7528\u4e8e\u5f53\u4eca\u7684\u5de5\u4e1a\u76d1\u63a7\u8bbe\u5907\u4e2d\u3002\u8be5\u534f\u8bae\u4f7f\u7528 RS-232 \u6216 RS-485 \u4e32\u884c\u63a5\u53e3\u8fdb\u884c\u901a\u4fe1\uff0c\u5e76\u5f97\u5230\u5e02\u573a\u4e0a\u51e0\u4e4e\u6240\u6709\u5546\u4e1a SCADA\u3001HMI\u3001OPC \u670d\u52a1\u5668\u548c\u6570\u636e\u91c7\u96c6\u8f6f\u4ef6\u7a0b\u5e8f\u7684\u652f\u6301\u3002\u56e0\u6b64\uff0c\u5f88\u5bb9\u6613\u5c06 Modbus \u517c\u5bb9\u8bbe\u5907\u96c6\u6210\u5230\u65b0\u7684\u6216\u73b0\u6709\u7684\u76d1\u63a7\u5e94\u7528\u7a0b\u5e8f\u4e2d\uff0c\u5e76\u5177\u6709\u5373\u65f6\u7684\u8f6f\u4ef6\u652f\u6301\u3002\u5e27\u7ed3\u6784\uff1a\u8bbe\u5907\u5730\u5740\u3001\u529f\u80fd\u7801\u3001\u6570\u636e\u548cCRC\u6821\u9a8c\u5b57\u6bb5\u3002\u5e38\u7528\u529f\u80fd\u7801\uff1aModbus-RTU\u534f\u8bae\u5b9a\u4e49\u4e86\u4e00\u7cfb\u5217\u5e38\u7528\u7684\u529f\u80fd\u7801\uff0c\u7528\u4e8e\u6267\u884c\u4e0d\u540c\u7684\u64cd\u4f5c\uff0c\u5982\u8bfb\u53d6\u4fdd\u6301\u5bc4\u5b58\u5668\u3001\u5199\u5165\u5355\u4e2a\u5bc4\u5b58\u5668\u3001\u5199\u5165\u591a\u4e2a\u5bc4\u5b58\u5668\u7b49\u3002_modbus rtu\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/19773.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-04-18T18:22:20+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418182218-6802985a33e34.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/19773.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/19773.html\",\"name\":\"Modbus-RTU\u8be6\u89e3 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-04-18T18:22:20+00:00\",\"dateModified\":\"2025-04-18T18:22:20+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/19773.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/19773.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/19773.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Modbus-RTU\u8be6\u89e3\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Modbus-RTU\u8be6\u89e3 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/19773.html","og_locale":"zh_CN","og_type":"article","og_title":"Modbus-RTU\u8be6\u89e3 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.7w\u6b21\uff0c\u70b9\u8d5e70\u6b21\uff0c\u6536\u85cf94\u6b21\u3002Modbus RTU \u534f\u8bae\u662f\u4e00\u79cd\u5f00\u653e\u7684\u4e32\u884c\u534f\u8bae\uff0c\u5e7f\u6cdb\u5e94\u7528\u4e8e\u5f53\u4eca\u7684\u5de5\u4e1a\u76d1\u63a7\u8bbe\u5907\u4e2d\u3002\u8be5\u534f\u8bae\u4f7f\u7528 RS-232 \u6216 RS-485 \u4e32\u884c\u63a5\u53e3\u8fdb\u884c\u901a\u4fe1\uff0c\u5e76\u5f97\u5230\u5e02\u573a\u4e0a\u51e0\u4e4e\u6240\u6709\u5546\u4e1a SCADA\u3001HMI\u3001OPC \u670d\u52a1\u5668\u548c\u6570\u636e\u91c7\u96c6\u8f6f\u4ef6\u7a0b\u5e8f\u7684\u652f\u6301\u3002\u56e0\u6b64\uff0c\u5f88\u5bb9\u6613\u5c06 Modbus \u517c\u5bb9\u8bbe\u5907\u96c6\u6210\u5230\u65b0\u7684\u6216\u73b0\u6709\u7684\u76d1\u63a7\u5e94\u7528\u7a0b\u5e8f\u4e2d\uff0c\u5e76\u5177\u6709\u5373\u65f6\u7684\u8f6f\u4ef6\u652f\u6301\u3002\u5e27\u7ed3\u6784\uff1a\u8bbe\u5907\u5730\u5740\u3001\u529f\u80fd\u7801\u3001\u6570\u636e\u548cCRC\u6821\u9a8c\u5b57\u6bb5\u3002\u5e38\u7528\u529f\u80fd\u7801\uff1aModbus-RTU\u534f\u8bae\u5b9a\u4e49\u4e86\u4e00\u7cfb\u5217\u5e38\u7528\u7684\u529f\u80fd\u7801\uff0c\u7528\u4e8e\u6267\u884c\u4e0d\u540c\u7684\u64cd\u4f5c\uff0c\u5982\u8bfb\u53d6\u4fdd\u6301\u5bc4\u5b58\u5668\u3001\u5199\u5165\u5355\u4e2a\u5bc4\u5b58\u5668\u3001\u5199\u5165\u591a\u4e2a\u5bc4\u5b58\u5668\u7b49\u3002_modbus rtu","og_url":"https:\/\/www.wsisp.com\/helps\/19773.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-04-18T18:22:20+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418182218-6802985a33e34.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"6 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/19773.html","url":"https:\/\/www.wsisp.com\/helps\/19773.html","name":"Modbus-RTU\u8be6\u89e3 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-04-18T18:22:20+00:00","dateModified":"2025-04-18T18:22:20+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/19773.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/19773.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/19773.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"Modbus-RTU\u8be6\u89e3"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/19773","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=19773"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/19773\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/19766"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=19773"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=19773"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=19773"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=19773"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}