Files
MicrochipFor32/Doc/docbook/bsp___mod_bus_8cpp_source.xml

293 lines
59 KiB
XML
Raw Normal View History

<?xml version='1.0' encoding='UTF-8' standalone='no'?>
<section xmlns="http://docbook.org/ns/docbook" version="5.0" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="_bsp___mod_bus_8cpp_source" xml:lang="zh">
<title>bsp_ModBus.cpp</title>
<indexterm><primary>D:/gitt/MicrochipFor32/bsp_Device/bsp_ModBus.cpp</primary></indexterm>
浏览该文件的文档.<programlisting linenumbering="unnumbered"><anchor xml:id="_bsp___mod_bus_8cpp_source_1l00001"/>00001 <emphasis role="comment">/*----------------------------------------------------------------------------------------------------</emphasis>
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00002"/>00002 <emphasis role="comment">&#32;#</emphasis>
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00003"/>00003 <emphasis role="comment">&#32;#&#32;&#32;Copyright&#32;(c)&#32;2022&#32;Yuankang&#32;Liang(XerolySkinner)</emphasis>
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00004"/>00004 <emphasis role="comment">&#32;#</emphasis>
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00005"/>00005 <emphasis role="comment">&#32;#&#32;&#32;本软件按原样提供,无任何明示或暗示</emphasis>
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00006"/>00006 <emphasis role="comment">&#32;#&#32;&#32;在任何情况下,作者都不承担任何损害赔偿责任</emphasis>
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00007"/>00007 <emphasis role="comment">&#32;#</emphasis>
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00008"/>00008 <emphasis role="comment">&#32;#&#32;&#32;使用的许可声明:</emphasis>
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00009"/>00009 <emphasis role="comment">&#32;#&#32;&#32;1.&#32;&#32;不得歪曲本软件的来源,你不能声称你编写了原始软件.</emphasis>
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00010"/>00010 <emphasis role="comment">&#32;#&#32;&#32;2.&#32;&#32;免费授予以任何目的,前提是版权声明出现在所有副本中.</emphasis>
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00011"/>00011 <emphasis role="comment">&#32;#&#32;&#32;&#32;&#32;&#32;&#32;并且版权声明和许可声明同时出现.</emphasis>
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00012"/>00012 <emphasis role="comment">&#32;#&#32;&#32;3.&#32;&#32;你有使用,复制,修改,分发,和销售本软件的许可.</emphasis>
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00013"/>00013 <emphasis role="comment">&#32;#&#32;&#32;4.&#32;&#32;如果你在产品中使用,产品文档中的声明是赞赏的但不是必须的.</emphasis>
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00014"/>00014 <emphasis role="comment">&#32;#&#32;&#32;5.&#32;&#32;本通知不得从任何来源删除或更改.</emphasis>
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00015"/>00015 <emphasis role="comment">&#32;#</emphasis>
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00016"/>00016 <emphasis role="comment">&#32;#&#32;&#32;Yuankang&#32;Liang(XerolySkinner)</emphasis>
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00017"/>00017 <emphasis role="comment">&#32;#&#32;&#32;&#32;&#32;&#32;&#32;E-mail:zabbcccbbaz@163.com</emphasis>
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00018"/>00018 <emphasis role="comment">&#32;#&#32;&#32;&#32;&#32;&#32;&#32;QQ:2715099320</emphasis>
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00019"/>00019 <emphasis role="comment">&#32;#&#32;&#32;&#32;&#32;&#32;&#32;Mobile&#32;Phone:13005636215</emphasis>
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00020"/>00020 <emphasis role="comment">&#32;#</emphasis>
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00021"/>00021 <emphasis role="comment">&#32;#&#32;&#32;All&#32;rights&#32;reserved.</emphasis>
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00022"/>00022 <emphasis role="comment">&#32;*/</emphasis>
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00023"/>00023
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00033"/>00033 <emphasis role="preprocessor">#pragma&#32;once</emphasis>
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00035"/>00035 <emphasis role="comment">//----------------------------------------------------------------------------------------------------</emphasis>
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00036"/>00036 <emphasis role="comment">//&#32;&#32;头文件</emphasis>
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00037"/>00037 <emphasis role="preprocessor">#include&#32;&quot;<link linkend="_bsp___mod_bus_8h">bsp_ModBus.h</link>&quot;</emphasis>
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00038"/>00038 <emphasis role="preprocessor">#include&#32;&quot;<link linkend="_bsp___c_r_c_8h">bsp_CRC.h</link>&quot;</emphasis>
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00039"/>00039 <emphasis role="preprocessor">#include&#32;&lt;stdio.h&gt;</emphasis>
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00040"/>00040 <emphasis role="preprocessor">#include&#32;&lt;stdlib.h&gt;</emphasis>
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00042"/>00042 <emphasis role="comment">//----------------------------------------------------------------------------------------------------</emphasis>
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00043"/>00043 <emphasis role="comment">//&#32;&#32;类函数</emphasis>
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00050"/><link linkend="_classbsp___mod_bus___tx_1ada605c0e9195aefd43968cfe5b347565">00050</link> <emphasis role="comment"></emphasis><emphasis role="keywordtype">void</emphasis>&#32;<link linkend="_classbsp___mod_bus___tx_1ada605c0e9195aefd43968cfe5b347565">bsp_ModBus_Tx::ReadKeepReg</link>(<link linkend="_varint_8h_1ace9d960e74685e2cd84b36132dbbf8aa">u16</link>&#32;address,&#32;<link linkend="_varint_8h_1ace9d960e74685e2cd84b36132dbbf8aa">u16</link>&#32;mem)&#32;{
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00051"/>00051 &#32;&#32;&#32;&#32;<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>&#32;dat[8];
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00052"/>00052 &#32;&#32;&#32;&#32;<link linkend="_varint_8h_1ace9d960e74685e2cd84b36132dbbf8aa">u16</link>&#32;crc;
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00053"/>00053 &#32;&#32;&#32;&#32;dat[0]&#32;=&#32;<link linkend="_classbsp___mod_bus___tx_1a4ee454ddd116e2b608d9b35b02eee0e4">ID</link>;
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00054"/>00054 &#32;&#32;&#32;&#32;dat[1]&#32;=&#32;<link linkend="_bsp___mod_bus_8h_1ac6d9f6c262df700be9045045502e7643a9ec5f1febebcade07d80148f67d51594">Fun_R_KeepReg</link>;
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00055"/>00055 &#32;&#32;&#32;&#32;dat[2]&#32;=&#32;((<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)(&amp;address))[1];
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00056"/>00056 &#32;&#32;&#32;&#32;dat[3]&#32;=&#32;((<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)(&amp;address))[0];
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00057"/>00057 &#32;&#32;&#32;&#32;dat[4]&#32;=&#32;((<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)(&amp;mem))[1];
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00058"/>00058 &#32;&#32;&#32;&#32;dat[5]&#32;=&#32;((<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)(&amp;mem))[0];
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00059"/>00059 &#32;&#32;&#32;&#32;crc&#32;=&#32;<link linkend="_bsp___c_r_c_8cpp_1abb1fda5ed561362d12fe987758986919">CRC16_MODBUS</link>(dat,&#32;6);
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00060"/>00060 &#32;&#32;&#32;&#32;dat[6]&#32;=&#32;((<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)(&amp;crc))[0];
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00061"/>00061 &#32;&#32;&#32;&#32;dat[7]&#32;=&#32;((<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)(&amp;crc))[1];
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00062"/>00062 &#32;&#32;&#32;&#32;<link linkend="_classbsp___mod_bus___tx_1ac017f6145ba6f87c69a16510f868dcc2">Transmit</link>(dat,8);}
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00063"/>00063 <emphasis role="comment">//----------------------------------------------------------------------------------------------------</emphasis>
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00070"/><link linkend="_classbsp___mod_bus___tx_1af055e2569107b8ece7abdce3301e9444">00070</link> <emphasis role="comment"></emphasis><emphasis role="keywordtype">void</emphasis>&#32;<link linkend="_classbsp___mod_bus___tx_1af055e2569107b8ece7abdce3301e9444">bsp_ModBus_Tx::ReadInReg</link>(<link linkend="_varint_8h_1ace9d960e74685e2cd84b36132dbbf8aa">u16</link>&#32;address,&#32;<link linkend="_varint_8h_1ace9d960e74685e2cd84b36132dbbf8aa">u16</link>&#32;mem)&#32;{
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00071"/>00071 &#32;&#32;&#32;&#32;<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>&#32;dat[8];
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00072"/>00072 &#32;&#32;&#32;&#32;<link linkend="_varint_8h_1ace9d960e74685e2cd84b36132dbbf8aa">u16</link>&#32;crc;
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00073"/>00073 &#32;&#32;&#32;&#32;dat[0]&#32;=&#32;<link linkend="_classbsp___mod_bus___tx_1a4ee454ddd116e2b608d9b35b02eee0e4">ID</link>;
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00074"/>00074 &#32;&#32;&#32;&#32;dat[1]&#32;=&#32;<link linkend="_bsp___mod_bus_8h_1ac6d9f6c262df700be9045045502e7643ab285b7d7c40fa9a85adba60a3a769fca">Fun_R_InReg</link>;
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00075"/>00075 &#32;&#32;&#32;&#32;dat[2]&#32;=&#32;((<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)(&amp;address))[1];
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00076"/>00076 &#32;&#32;&#32;&#32;dat[3]&#32;=&#32;((<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)(&amp;address))[0];
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00077"/>00077 &#32;&#32;&#32;&#32;dat[4]&#32;=&#32;((<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)(&amp;mem))[1];
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00078"/>00078 &#32;&#32;&#32;&#32;dat[5]&#32;=&#32;((<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)(&amp;mem))[0];
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00079"/>00079 &#32;&#32;&#32;&#32;crc&#32;=&#32;<link linkend="_bsp___c_r_c_8cpp_1abb1fda5ed561362d12fe987758986919">CRC16_MODBUS</link>(dat,6);
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00080"/>00080 &#32;&#32;&#32;&#32;dat[6]&#32;=&#32;((<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)(&amp;crc))[0];
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00081"/>00081 &#32;&#32;&#32;&#32;dat[7]&#32;=&#32;((<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)(&amp;crc))[1];
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00082"/>00082 &#32;&#32;&#32;&#32;<link linkend="_classbsp___mod_bus___tx_1ac017f6145ba6f87c69a16510f868dcc2">Transmit</link>(dat,&#32;8);}
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00083"/>00083 <emphasis role="comment">//----------------------------------------------------------------------------------------------------</emphasis>
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00090"/><link linkend="_classbsp___mod_bus___tx_1a02ea1680f5c361f2cf4ebcb48b565281">00090</link> <emphasis role="comment"></emphasis><emphasis role="keywordtype">void</emphasis>&#32;<link linkend="_classbsp___mod_bus___tx_1a02ea1680f5c361f2cf4ebcb48b565281">bsp_ModBus_Tx::WriteOneReg</link>(<link linkend="_varint_8h_1ace9d960e74685e2cd84b36132dbbf8aa">u16</link>&#32;address,&#32;<link linkend="_varint_8h_1ace9d960e74685e2cd84b36132dbbf8aa">u16</link>&#32;var)&#32;{
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00091"/>00091 &#32;&#32;&#32;&#32;<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>&#32;dat[8];
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00092"/>00092 &#32;&#32;&#32;&#32;<link linkend="_varint_8h_1ace9d960e74685e2cd84b36132dbbf8aa">u16</link>&#32;crc;
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00093"/>00093 &#32;&#32;&#32;&#32;dat[0]&#32;=&#32;<link linkend="_classbsp___mod_bus___tx_1a4ee454ddd116e2b608d9b35b02eee0e4">ID</link>;
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00094"/>00094 &#32;&#32;&#32;&#32;dat[1]&#32;=&#32;<link linkend="_bsp___mod_bus_8h_1ac6d9f6c262df700be9045045502e7643a2e8689560573f300af3a6c48fdd6ce86">Fun_W_OneReg</link>;
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00095"/>00095 &#32;&#32;&#32;&#32;dat[2]&#32;=&#32;((<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)(&amp;address))[1];
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00096"/>00096 &#32;&#32;&#32;&#32;dat[3]&#32;=&#32;((<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)(&amp;address))[0];
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00097"/>00097 &#32;&#32;&#32;&#32;dat[4]&#32;=&#32;((<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)(&amp;var))[1];
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00098"/>00098 &#32;&#32;&#32;&#32;dat[5]&#32;=&#32;((<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)(&amp;var))[0];
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00099"/>00099 &#32;&#32;&#32;&#32;crc&#32;=&#32;<link linkend="_bsp___c_r_c_8cpp_1abb1fda5ed561362d12fe987758986919">CRC16_MODBUS</link>(dat,&#32;6);
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00100"/>00100 &#32;&#32;&#32;&#32;dat[6]&#32;=&#32;((<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)(&amp;crc))[0];
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00101"/>00101 &#32;&#32;&#32;&#32;dat[7]&#32;=&#32;((<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)(&amp;crc))[1];
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00102"/>00102 &#32;&#32;&#32;&#32;<link linkend="_classbsp___mod_bus___tx_1ac017f6145ba6f87c69a16510f868dcc2">Transmit</link>(dat,&#32;8);}
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00103"/>00103 <emphasis role="comment">//----------------------------------------------------------------------------------------------------</emphasis>
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00112"/><link linkend="_classbsp___mod_bus___tx_1a268c136782f8146662f33878522c270c">00112</link> <emphasis role="comment"></emphasis><emphasis role="keywordtype">void</emphasis>&#32;<link linkend="_classbsp___mod_bus___tx_1a268c136782f8146662f33878522c270c">bsp_ModBus_Tx::WriteRegs</link>(<link linkend="_varint_8h_1ace9d960e74685e2cd84b36132dbbf8aa">u16</link>&#32;address,<link linkend="_varint_8h_1ace9d960e74685e2cd84b36132dbbf8aa">u16</link>&#32;mem,<link linkend="_varint_8h_1ace9d960e74685e2cd84b36132dbbf8aa">u16</link>*&#32;var)&#32;{
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00113"/>00113 &#32;&#32;&#32;&#32;<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>&#32;bytes&#32;=&#32;9&#32;+&#32;mem&#32;*&#32;2;
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00114"/>00114 &#32;&#32;&#32;&#32;<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*&#32;dat&#32;=&#32;(<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)malloc(bytes);
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00115"/>00115 &#32;&#32;&#32;&#32;<emphasis role="keywordflow">if</emphasis>&#32;(dat&#32;==&#32;NULL)<emphasis role="keywordflow">return</emphasis>;
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00116"/>00116 &#32;&#32;&#32;&#32;<link linkend="_varint_8h_1ace9d960e74685e2cd84b36132dbbf8aa">u16</link>&#32;crc;
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00117"/>00117 &#32;&#32;&#32;&#32;dat[0]&#32;=&#32;<link linkend="_classbsp___mod_bus___tx_1a4ee454ddd116e2b608d9b35b02eee0e4">ID</link>;
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00118"/>00118 &#32;&#32;&#32;&#32;dat[1]&#32;=&#32;<link linkend="_bsp___mod_bus_8h_1ac6d9f6c262df700be9045045502e7643a54562faaab8c1c932c46c6c4cb2552f9">Fun_W_Regs</link>;
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00119"/>00119 &#32;&#32;&#32;&#32;dat[2]&#32;=&#32;((<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)(&amp;address))[1];
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00120"/>00120 &#32;&#32;&#32;&#32;dat[3]&#32;=&#32;((<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)(&amp;address))[0];
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00121"/>00121 &#32;&#32;&#32;&#32;dat[4]&#32;=&#32;((<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)(&amp;mem))[1];
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00122"/>00122 &#32;&#32;&#32;&#32;dat[5]&#32;=&#32;((<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)(&amp;mem))[0];
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00123"/>00123 &#32;&#32;&#32;&#32;dat[6]&#32;=&#32;mem*2;
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00124"/>00124 &#32;&#32;&#32;&#32;<emphasis role="comment">//&#32;&#32;填入数据</emphasis>
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00125"/>00125 &#32;&#32;&#32;&#32;<emphasis role="keywordflow">for</emphasis>&#32;(<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>&#32;i&#32;=&#32;0;&#32;i&#32;&lt;&#32;mem;&#32;i++){
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00126"/>00126 &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;dat[7&#32;+&#32;i*2]&#32;=&#32;((<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)var)[1+i*2];
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00127"/>00127 &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;dat[8&#32;+&#32;i*2]&#32;=&#32;((<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)var)[0+i*2];}
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00128"/>00128 &#32;&#32;&#32;&#32;crc&#32;=&#32;<link linkend="_bsp___c_r_c_8cpp_1abb1fda5ed561362d12fe987758986919">CRC16_MODBUS</link>(dat,&#32;bytes&#32;-&#32;2);
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00129"/>00129 &#32;&#32;&#32;&#32;dat[bytes&#32;-&#32;2]&#32;=&#32;((<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)(&amp;crc))[0];
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00130"/>00130 &#32;&#32;&#32;&#32;dat[bytes&#32;-&#32;1]&#32;=&#32;((<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)(&amp;crc))[1];
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00131"/>00131 &#32;&#32;&#32;&#32;<link linkend="_classbsp___mod_bus___tx_1ac017f6145ba6f87c69a16510f868dcc2">Transmit</link>(dat,&#32;bytes);
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00132"/>00132 &#32;&#32;&#32;&#32;free(dat);}
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00133"/>00133 <emphasis role="comment">//----------------------------------------------------------------------------------------------------</emphasis>
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00142"/><link linkend="_classbsp___mod_bus___tx_1acc267977d61716e25fd3e3ec57bc2960">00142</link> <emphasis role="comment"></emphasis><emphasis role="keywordtype">void</emphasis>&#32;<link linkend="_classbsp___mod_bus___tx_1acc267977d61716e25fd3e3ec57bc2960">bsp_ModBus_Tx::WriteRegsVar</link>(<link linkend="_varint_8h_1ace9d960e74685e2cd84b36132dbbf8aa">u16</link>&#32;address,&#32;<link linkend="_varint_8h_1ace9d960e74685e2cd84b36132dbbf8aa">u16</link>&#32;mem,...)&#32;{
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00143"/>00143 &#32;&#32;&#32;&#32;va_list&#32;table;
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00144"/>00144 &#32;&#32;&#32;&#32;va_start(table,mem);
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00145"/>00145 &#32;&#32;&#32;&#32;<link linkend="_varint_8h_1ace9d960e74685e2cd84b36132dbbf8aa">u16</link>&#32;vars;
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00146"/>00146 &#32;&#32;&#32;&#32;<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>&#32;bytes&#32;=&#32;9&#32;+&#32;mem&#32;*&#32;2;
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00147"/>00147 &#32;&#32;&#32;&#32;<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*&#32;dat&#32;=&#32;(<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)malloc(bytes);
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00148"/>00148 &#32;&#32;&#32;&#32;<emphasis role="keywordflow">if</emphasis>&#32;(dat&#32;==&#32;NULL)<emphasis role="keywordflow">return</emphasis>;
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00149"/>00149 &#32;&#32;&#32;&#32;<link linkend="_varint_8h_1ace9d960e74685e2cd84b36132dbbf8aa">u16</link>&#32;crc;
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00150"/>00150 &#32;&#32;&#32;&#32;dat[0]&#32;=&#32;<link linkend="_classbsp___mod_bus___tx_1a4ee454ddd116e2b608d9b35b02eee0e4">ID</link>;
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00151"/>00151 &#32;&#32;&#32;&#32;dat[1]&#32;=&#32;<link linkend="_bsp___mod_bus_8h_1ac6d9f6c262df700be9045045502e7643a54562faaab8c1c932c46c6c4cb2552f9">Fun_W_Regs</link>;
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00152"/>00152 &#32;&#32;&#32;&#32;dat[2]&#32;=&#32;((<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)(&amp;address))[1];
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00153"/>00153 &#32;&#32;&#32;&#32;dat[3]&#32;=&#32;((<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)(&amp;address))[0];
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00154"/>00154 &#32;&#32;&#32;&#32;dat[4]&#32;=&#32;((<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)(&amp;mem))[1];
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00155"/>00155 &#32;&#32;&#32;&#32;dat[5]&#32;=&#32;((<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)(&amp;mem))[0];
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00156"/>00156 &#32;&#32;&#32;&#32;dat[6]&#32;=&#32;mem*2;
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00157"/>00157 &#32;&#32;&#32;&#32;<emphasis role="comment">//&#32;&#32;填入数据</emphasis>
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00158"/>00158 &#32;&#32;&#32;&#32;<emphasis role="keywordflow">for</emphasis>&#32;(<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>&#32;i&#32;=&#32;0;&#32;i&#32;&lt;&#32;mem;&#32;i++){
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00159"/>00159 &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;vars=va_arg(table,&#32;<link linkend="_varint_8h_1afaa62991928fb9fb18ff0db62a040aba">u32</link>);
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00160"/>00160 &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;dat[7&#32;+&#32;i*2]&#32;=&#32;((<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)(&amp;vars))[1];
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00161"/>00161 &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;dat[8&#32;+&#32;i*2]&#32;=&#32;((<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)(&amp;vars))[0];}
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00162"/>00162 &#32;&#32;&#32;&#32;crc&#32;=&#32;<link linkend="_bsp___c_r_c_8cpp_1abb1fda5ed561362d12fe987758986919">CRC16_MODBUS</link>(dat,&#32;bytes&#32;-&#32;2);
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00163"/>00163 &#32;&#32;&#32;&#32;dat[bytes&#32;-&#32;2]&#32;=&#32;((<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)(&amp;crc))[0];
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00164"/>00164 &#32;&#32;&#32;&#32;dat[bytes&#32;-&#32;1]&#32;=&#32;((<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)(&amp;crc))[1];
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00165"/>00165 &#32;&#32;&#32;&#32;<link linkend="_classbsp___mod_bus___tx_1ac017f6145ba6f87c69a16510f868dcc2">Transmit</link>(dat,&#32;bytes);
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00166"/>00166 &#32;&#32;&#32;&#32;free(dat);
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00167"/>00167 &#32;&#32;&#32;&#32;va_end(table);}
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00168"/>00168 <emphasis role="comment">//----------------------------------------------------------------------------------------------------</emphasis>
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00175"/><link linkend="_classbsp___mod_bus___tx_1abc721f5c61e236df505f3447818be921">00175</link> <emphasis role="comment"></emphasis><emphasis role="keywordtype">void</emphasis>&#32;<link linkend="_classbsp___mod_bus___tx_1abc721f5c61e236df505f3447818be921">bsp_ModBus_Tx::ReadOutCoil</link>(<link linkend="_varint_8h_1ace9d960e74685e2cd84b36132dbbf8aa">u16</link>&#32;address,&#32;<link linkend="_varint_8h_1ace9d960e74685e2cd84b36132dbbf8aa">u16</link>&#32;mem)&#32;{
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00176"/>00176 &#32;&#32;&#32;&#32;<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>&#32;dat[8];
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00177"/>00177 &#32;&#32;&#32;&#32;<link linkend="_varint_8h_1ace9d960e74685e2cd84b36132dbbf8aa">u16</link>&#32;crc;
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00178"/>00178 &#32;&#32;&#32;&#32;dat[0]&#32;=&#32;<link linkend="_classbsp___mod_bus___tx_1a4ee454ddd116e2b608d9b35b02eee0e4">ID</link>;
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00179"/>00179 &#32;&#32;&#32;&#32;dat[1]&#32;=&#32;<link linkend="_bsp___mod_bus_8h_1ac6d9f6c262df700be9045045502e7643afa0834864982fdb57c9a954bdbd1599b">Fun_R_OutCoil</link>;
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00180"/>00180 &#32;&#32;&#32;&#32;dat[2]&#32;=&#32;((<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)(&amp;address))[1];
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00181"/>00181 &#32;&#32;&#32;&#32;dat[3]&#32;=&#32;((<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)(&amp;address))[0];
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00182"/>00182 &#32;&#32;&#32;&#32;dat[4]&#32;=&#32;((<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)(&amp;mem))[1];
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00183"/>00183 &#32;&#32;&#32;&#32;dat[5]&#32;=&#32;((<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)(&amp;mem))[0];
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00184"/>00184 &#32;&#32;&#32;&#32;crc&#32;=&#32;<link linkend="_bsp___c_r_c_8cpp_1abb1fda5ed561362d12fe987758986919">CRC16_MODBUS</link>(dat,&#32;6);
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00185"/>00185 &#32;&#32;&#32;&#32;dat[6]&#32;=&#32;((<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)(&amp;crc))[0];
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00186"/>00186 &#32;&#32;&#32;&#32;dat[7]&#32;=&#32;((<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)(&amp;crc))[1];
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00187"/>00187 &#32;&#32;&#32;&#32;<link linkend="_classbsp___mod_bus___tx_1ac017f6145ba6f87c69a16510f868dcc2">Transmit</link>(dat,&#32;8);}
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00188"/>00188 <emphasis role="comment">//----------------------------------------------------------------------------------------------------</emphasis>
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00195"/><link linkend="_classbsp___mod_bus___tx_1a76e712e8d638ecc7b453e1c8afbbad98">00195</link> <emphasis role="comment"></emphasis><emphasis role="keywordtype">void</emphasis>&#32;<link linkend="_classbsp___mod_bus___tx_1a76e712e8d638ecc7b453e1c8afbbad98">bsp_ModBus_Tx::ReadInCoil</link>(<link linkend="_varint_8h_1ace9d960e74685e2cd84b36132dbbf8aa">u16</link>&#32;address,&#32;<link linkend="_varint_8h_1ace9d960e74685e2cd84b36132dbbf8aa">u16</link>&#32;mem)&#32;{
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00196"/>00196 &#32;&#32;&#32;&#32;<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>&#32;dat[8];
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00197"/>00197 &#32;&#32;&#32;&#32;<link linkend="_varint_8h_1ace9d960e74685e2cd84b36132dbbf8aa">u16</link>&#32;crc;
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00198"/>00198 &#32;&#32;&#32;&#32;dat[0]&#32;=&#32;<link linkend="_classbsp___mod_bus___tx_1a4ee454ddd116e2b608d9b35b02eee0e4">ID</link>;
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00199"/>00199 &#32;&#32;&#32;&#32;dat[1]&#32;=&#32;<link linkend="_bsp___mod_bus_8h_1ac6d9f6c262df700be9045045502e7643a8c70d4d5036c1a3f9c51a545d13fdd92">Fun_R_InCoil</link>;
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00200"/>00200 &#32;&#32;&#32;&#32;dat[2]&#32;=&#32;((<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)(&amp;address))[1];
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00201"/>00201 &#32;&#32;&#32;&#32;dat[3]&#32;=&#32;((<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)(&amp;address))[0];
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00202"/>00202 &#32;&#32;&#32;&#32;dat[4]&#32;=&#32;((<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)(&amp;mem))[1];
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00203"/>00203 &#32;&#32;&#32;&#32;dat[5]&#32;=&#32;((<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)(&amp;mem))[0];
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00204"/>00204 &#32;&#32;&#32;&#32;crc&#32;=&#32;<link linkend="_bsp___c_r_c_8cpp_1abb1fda5ed561362d12fe987758986919">CRC16_MODBUS</link>(dat,&#32;6);
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00205"/>00205 &#32;&#32;&#32;&#32;dat[6]&#32;=&#32;((<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)(&amp;crc))[0];
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00206"/>00206 &#32;&#32;&#32;&#32;dat[7]&#32;=&#32;((<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)(&amp;crc))[1];
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00207"/>00207 &#32;&#32;&#32;&#32;<link linkend="_classbsp___mod_bus___tx_1ac017f6145ba6f87c69a16510f868dcc2">Transmit</link>(dat,&#32;8);}
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00208"/>00208 <emphasis role="comment">//----------------------------------------------------------------------------------------------------</emphasis>
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00217"/><link linkend="_classbsp___mod_bus___tx_1aa8d37cc0cefaad8f41bc1d195a326d95">00217</link> <emphasis role="comment"></emphasis><emphasis role="keywordtype">void</emphasis>&#32;<link linkend="_classbsp___mod_bus___tx_1aa8d37cc0cefaad8f41bc1d195a326d95">bsp_ModBus_Tx::WriteOneCoil</link>(<link linkend="_varint_8h_1ace9d960e74685e2cd84b36132dbbf8aa">u16</link>&#32;address,&#32;<link linkend="_varint_8h_1ace9d960e74685e2cd84b36132dbbf8aa">u16</link>&#32;state){
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00218"/>00218 &#32;&#32;&#32;&#32;<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>&#32;dat[8];
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00219"/>00219 &#32;&#32;&#32;&#32;<link linkend="_varint_8h_1ace9d960e74685e2cd84b36132dbbf8aa">u16</link>&#32;var&#32;=&#32;state&#32;?&#32;0xFF00&#32;:&#32;0x0000;
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00220"/>00220 &#32;&#32;&#32;&#32;<link linkend="_varint_8h_1ace9d960e74685e2cd84b36132dbbf8aa">u16</link>&#32;crc;
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00221"/>00221 &#32;&#32;&#32;&#32;dat[0]&#32;=&#32;<link linkend="_classbsp___mod_bus___tx_1a4ee454ddd116e2b608d9b35b02eee0e4">ID</link>;
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00222"/>00222 &#32;&#32;&#32;&#32;dat[1]&#32;=&#32;<link linkend="_bsp___mod_bus_8h_1ac6d9f6c262df700be9045045502e7643a95bb48bd2de82de8a2f5684a6cccff0f">Fun_W_OneCoil</link>;
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00223"/>00223 &#32;&#32;&#32;&#32;dat[2]&#32;=&#32;((<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)(&amp;address))[1];
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00224"/>00224 &#32;&#32;&#32;&#32;dat[3]&#32;=&#32;((<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)(&amp;address))[0];
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00225"/>00225 &#32;&#32;&#32;&#32;dat[4]&#32;=&#32;((<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)(&amp;var))[1];
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00226"/>00226 &#32;&#32;&#32;&#32;dat[5]&#32;=&#32;((<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)(&amp;var))[0];
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00227"/>00227 &#32;&#32;&#32;&#32;crc&#32;=&#32;<link linkend="_bsp___c_r_c_8cpp_1abb1fda5ed561362d12fe987758986919">CRC16_MODBUS</link>(dat,&#32;6);
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00228"/>00228 &#32;&#32;&#32;&#32;dat[6]&#32;=&#32;((<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)(&amp;crc))[0];
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00229"/>00229 &#32;&#32;&#32;&#32;dat[7]&#32;=&#32;((<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)(&amp;crc))[1];
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00230"/>00230 &#32;&#32;&#32;&#32;<link linkend="_classbsp___mod_bus___tx_1ac017f6145ba6f87c69a16510f868dcc2">Transmit</link>(dat,&#32;8);}
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00231"/>00231 <emphasis role="comment">//----------------------------------------------------------------------------------------------------</emphasis>
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00240"/><link linkend="_classbsp___mod_bus___tx_1a630ac7566fe9d1773baa813802202d0f">00240</link> <emphasis role="comment"></emphasis><emphasis role="keywordtype">void</emphasis>&#32;<link linkend="_classbsp___mod_bus___tx_1a630ac7566fe9d1773baa813802202d0f">bsp_ModBus_Tx::WriteCoils</link>(<link linkend="_varint_8h_1ace9d960e74685e2cd84b36132dbbf8aa">u16</link>&#32;address,&#32;<link linkend="_varint_8h_1ace9d960e74685e2cd84b36132dbbf8aa">u16</link>&#32;mem,&#32;<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*&#32;var)&#32;{
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00241"/>00241 &#32;&#32;&#32;&#32;<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>&#32;bytes&#32;=&#32;(mem&#32;/&#32;8)&#32;+&#32;(mem&#32;%&#32;8&#32;!=&#32;0)&#32;+&#32;9;
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00242"/>00242 &#32;&#32;&#32;&#32;<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*&#32;dat&#32;=&#32;(<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)malloc(bytes);
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00243"/>00243 &#32;&#32;&#32;&#32;<emphasis role="keywordflow">if</emphasis>&#32;(dat&#32;==&#32;NULL)<emphasis role="keywordflow">return</emphasis>;
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00244"/>00244 &#32;&#32;&#32;&#32;<link linkend="_varint_8h_1ace9d960e74685e2cd84b36132dbbf8aa">u16</link>&#32;crc;
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00245"/>00245 &#32;&#32;&#32;&#32;dat[0]&#32;=&#32;<link linkend="_classbsp___mod_bus___tx_1a4ee454ddd116e2b608d9b35b02eee0e4">ID</link>;
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00246"/>00246 &#32;&#32;&#32;&#32;dat[1]&#32;=&#32;<link linkend="_bsp___mod_bus_8h_1ac6d9f6c262df700be9045045502e7643a0a40a9622af4e5cb7daecbdb303ee35e">Fun_W_Coils</link>;
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00247"/>00247 &#32;&#32;&#32;&#32;dat[2]&#32;=&#32;((<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)(&amp;address))[1];
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00248"/>00248 &#32;&#32;&#32;&#32;dat[3]&#32;=&#32;((<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)(&amp;address))[0];
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00249"/>00249 &#32;&#32;&#32;&#32;dat[4]&#32;=&#32;((<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)(&amp;mem))[1];
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00250"/>00250 &#32;&#32;&#32;&#32;dat[5]&#32;=&#32;((<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)(&amp;mem))[0];
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00251"/>00251 &#32;&#32;&#32;&#32;dat[6]&#32;=&#32;bytes&#32;-&#32;9;
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00252"/>00252 &#32;&#32;&#32;&#32;<emphasis role="comment">//&#32;&#32;填入数据</emphasis>
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00253"/>00253 &#32;&#32;&#32;&#32;<emphasis role="keywordflow">for</emphasis>&#32;(<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>&#32;i&#32;=&#32;0;&#32;i&#32;&lt;&#32;bytes&#32;-&#32;9;&#32;i++)dat[7&#32;+&#32;i]&#32;=&#32;var[i];
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00254"/>00254 &#32;&#32;&#32;&#32;crc&#32;=&#32;<link linkend="_bsp___c_r_c_8cpp_1abb1fda5ed561362d12fe987758986919">CRC16_MODBUS</link>(dat,&#32;bytes&#32;-&#32;2);
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00255"/>00255 &#32;&#32;&#32;&#32;dat[bytes&#32;-&#32;2]&#32;=&#32;((<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)(&amp;crc))[0];
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00256"/>00256 &#32;&#32;&#32;&#32;dat[bytes&#32;-&#32;1]&#32;=&#32;((<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)(&amp;crc))[1];
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00257"/>00257 &#32;&#32;&#32;&#32;<link linkend="_classbsp___mod_bus___tx_1ac017f6145ba6f87c69a16510f868dcc2">Transmit</link>(dat,&#32;bytes);
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00258"/>00258 &#32;&#32;&#32;&#32;free(dat);}
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00259"/>00259 <emphasis role="comment">//----------------------------------------------------------------------------------------------------</emphasis>
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00268"/><link linkend="_classbsp___mod_bus___tx_1a280c5d7c99196a11b5fee7b34421a8ff">00268</link> <emphasis role="comment"></emphasis><emphasis role="keywordtype">void</emphasis>&#32;<link linkend="_classbsp___mod_bus___tx_1a280c5d7c99196a11b5fee7b34421a8ff">bsp_ModBus_Tx::WriteCoilsVar</link>(<link linkend="_varint_8h_1ace9d960e74685e2cd84b36132dbbf8aa">u16</link>&#32;address,&#32;<link linkend="_varint_8h_1ace9d960e74685e2cd84b36132dbbf8aa">u16</link>&#32;mem,...)&#32;{
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00269"/>00269 &#32;&#32;&#32;&#32;va_list&#32;table;
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00270"/>00270 &#32;&#32;&#32;&#32;va_start(table,mem);
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00271"/>00271 &#32;&#32;&#32;&#32;<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>&#32;var=0;
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00272"/>00272 &#32;&#32;&#32;&#32;<link linkend="_varint_8h_1ace9d960e74685e2cd84b36132dbbf8aa">u16</link>&#32;crc;
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00273"/>00273 &#32;&#32;&#32;&#32;<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>&#32;bytes&#32;=&#32;(mem&#32;/&#32;8)&#32;+&#32;(mem&#32;%&#32;8&#32;!=&#32;0)&#32;+&#32;9;
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00274"/>00274 &#32;&#32;&#32;&#32;<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*&#32;dat&#32;=&#32;(<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)malloc(bytes);
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00275"/>00275 &#32;&#32;&#32;&#32;<emphasis role="keywordflow">if</emphasis>&#32;(dat&#32;==&#32;NULL)<emphasis role="keywordflow">return</emphasis>;
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00276"/>00276 &#32;&#32;&#32;&#32;dat[0]&#32;=&#32;<link linkend="_classbsp___mod_bus___tx_1a4ee454ddd116e2b608d9b35b02eee0e4">ID</link>;
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00277"/>00277 &#32;&#32;&#32;&#32;dat[1]&#32;=&#32;<link linkend="_bsp___mod_bus_8h_1ac6d9f6c262df700be9045045502e7643a0a40a9622af4e5cb7daecbdb303ee35e">Fun_W_Coils</link>;
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00278"/>00278 &#32;&#32;&#32;&#32;dat[2]&#32;=&#32;((<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)(&amp;address))[1];
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00279"/>00279 &#32;&#32;&#32;&#32;dat[3]&#32;=&#32;((<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)(&amp;address))[0];
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00280"/>00280 &#32;&#32;&#32;&#32;dat[4]&#32;=&#32;((<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)(&amp;mem))[1];
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00281"/>00281 &#32;&#32;&#32;&#32;dat[5]&#32;=&#32;((<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)(&amp;mem))[0];
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00282"/>00282 &#32;&#32;&#32;&#32;dat[6]&#32;=&#32;bytes&#32;-&#32;9;
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00283"/>00283 &#32;&#32;&#32;&#32;<emphasis role="comment">//&#32;&#32;填入管脚信息</emphasis>
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00284"/>00284 &#32;&#32;&#32;&#32;<emphasis role="keywordflow">for</emphasis>(<link linkend="_varint_8h_1ace9d960e74685e2cd84b36132dbbf8aa">u16</link>&#32;i=0;i&lt;mem;i++){
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00285"/>00285 &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;var=va_arg(table,<link linkend="_varint_8h_1afaa62991928fb9fb18ff0db62a040aba">u32</link>);
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00286"/>00286 &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;<emphasis role="keywordflow">if</emphasis>(var)
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00287"/>00287 &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;dat[7&#32;+&#32;(i/8)]|=1&lt;&lt;(i%8);
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00288"/>00288 &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;<emphasis role="keywordflow">else</emphasis>
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00289"/>00289 &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;dat[7&#32;+&#32;(i/8)]&amp;=~(1&lt;&lt;(i%8));}
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00290"/>00290 &#32;&#32;&#32;&#32;crc&#32;=&#32;<link linkend="_bsp___c_r_c_8cpp_1abb1fda5ed561362d12fe987758986919">CRC16_MODBUS</link>(dat,&#32;bytes&#32;-&#32;2);
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00291"/>00291 &#32;&#32;&#32;&#32;dat[bytes&#32;-&#32;2]&#32;=&#32;((<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)(&amp;crc))[0];
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00292"/>00292 &#32;&#32;&#32;&#32;dat[bytes&#32;-&#32;1]&#32;=&#32;((<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)(&amp;crc))[1];
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00293"/>00293 &#32;&#32;&#32;&#32;<link linkend="_classbsp___mod_bus___tx_1ac017f6145ba6f87c69a16510f868dcc2">Transmit</link>(dat,&#32;bytes);
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00294"/>00294 &#32;&#32;&#32;&#32;free(dat);
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00295"/>00295 &#32;&#32;&#32;&#32;va_end(table);}
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00297"/>00297 <emphasis role="comment">//----------------------------------------------------------------------------------------------------</emphasis>
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00298"/>00298 <emphasis role="comment">//&#32;&#32;类函数</emphasis>
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00304"/><link linkend="_classbsp___mod_bus___rx_1a39330845d4ced51850b9edaaab052e0f">00304</link> <emphasis role="comment"></emphasis><emphasis role="keywordtype">void</emphasis>&#32;<link linkend="_classbsp___mod_bus___rx_1a39330845d4ced51850b9edaaab052e0f">bsp_ModBus_Rx::analysis</link>(<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*&#32;dat)&#32;{
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00305"/>00305 &#32;&#32;&#32;&#32;<link linkend="_varint_8h_1ace9d960e74685e2cd84b36132dbbf8aa">u16</link>&#32;crc&#32;=&#32;0;
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00306"/>00306 &#32;&#32;&#32;&#32;<link linkend="_classbsp___mod_bus___rx_1a045cc9c5f9d26ad5be1da2d2cfdcbefc">ID</link>&#32;=&#32;dat[0];
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00307"/>00307 &#32;&#32;&#32;&#32;<link linkend="_classbsp___mod_bus___rx_1a0a5cdc492b09b33ae665706c9968e5d5">Func</link>&#32;=&#32;dat[1];
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00308"/>00308 &#32;&#32;&#32;&#32;<emphasis role="comment">//&#32;&#32;释放缓存内存</emphasis>
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00309"/>00309 &#32;&#32;&#32;&#32;free(<link linkend="_classbsp___mod_bus___rx_1a6612d15d148b4944662851bd8fabae04">OutCoilDat</link>);
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00310"/>00310 &#32;&#32;&#32;&#32;free(<link linkend="_classbsp___mod_bus___rx_1a8ca97f2e7b033faddbb1772f15d91d4d">InCoilDat</link>);
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00311"/>00311 &#32;&#32;&#32;&#32;free(<link linkend="_classbsp___mod_bus___rx_1a091cc0733eb4aa6b06c10afdbfd46b7f">KeepRegDat</link>);
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00312"/>00312 &#32;&#32;&#32;&#32;free(<link linkend="_classbsp___mod_bus___rx_1ab275dbfa83dd90eff0cbf0411dfe8e4a">InRegDat</link>);
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00313"/>00313 &#32;&#32;&#32;&#32;<emphasis role="comment">//&#32;&#32;CRC检验</emphasis>
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00314"/>00314 &#32;&#32;&#32;&#32;<emphasis role="keywordflow">if</emphasis>&#32;(<link linkend="_classbsp___mod_bus___rx_1a0a5cdc492b09b33ae665706c9968e5d5">Func</link>&#32;==&#32;<link linkend="_bsp___mod_bus_8h_1ac6d9f6c262df700be9045045502e7643afa0834864982fdb57c9a954bdbd1599b">Fun_R_OutCoil</link>&#32;||
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00315"/>00315 &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;<link linkend="_classbsp___mod_bus___rx_1a0a5cdc492b09b33ae665706c9968e5d5">Func</link>&#32;==&#32;<link linkend="_bsp___mod_bus_8h_1ac6d9f6c262df700be9045045502e7643a8c70d4d5036c1a3f9c51a545d13fdd92">Fun_R_InCoil</link>&#32;||
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00316"/>00316 &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;<link linkend="_classbsp___mod_bus___rx_1a0a5cdc492b09b33ae665706c9968e5d5">Func</link>&#32;==&#32;<link linkend="_bsp___mod_bus_8h_1ac6d9f6c262df700be9045045502e7643a9ec5f1febebcade07d80148f67d51594">Fun_R_KeepReg</link>&#32;||
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00317"/>00317 &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;<link linkend="_classbsp___mod_bus___rx_1a0a5cdc492b09b33ae665706c9968e5d5">Func</link>&#32;==&#32;<link linkend="_bsp___mod_bus_8h_1ac6d9f6c262df700be9045045502e7643ab285b7d7c40fa9a85adba60a3a769fca">Fun_R_InReg</link>)&#32;{
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00318"/>00318 &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;crc&#32;=&#32;<link linkend="_bsp___c_r_c_8cpp_1abb1fda5ed561362d12fe987758986919">CRC16_MODBUS</link>(dat,&#32;dat[2]&#32;+&#32;3);
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00319"/>00319 &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;<link linkend="_classbsp___mod_bus___rx_1ac1a35ae91223298913373de0d3e7c02d">crcts</link>&#32;=&#32;(&#32;&#32;&#32;((<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)(&amp;crc))[1]&#32;==&#32;dat[dat[2]&#32;+&#32;3]&#32;&amp;&amp;
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00320"/>00320 &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;((<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)(&amp;crc))[0]&#32;==&#32;dat[dat[2]&#32;+&#32;4]);}
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00321"/>00321 &#32;&#32;&#32;&#32;<emphasis role="keywordflow">switch</emphasis>&#32;(<link linkend="_classbsp___mod_bus___rx_1a0a5cdc492b09b33ae665706c9968e5d5">Func</link>)&#32;{
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00322"/>00322 &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;<emphasis role="keywordflow">case</emphasis>&#32;<link linkend="_bsp___mod_bus_8h_1ac6d9f6c262df700be9045045502e7643afa0834864982fdb57c9a954bdbd1599b">Fun_R_OutCoil</link>:
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00323"/>00323 &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;<emphasis role="comment">//&#32;&#32;输出线圈</emphasis>
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00324"/>00324 &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;<link linkend="_classbsp___mod_bus___rx_1a062f82edfe722d8cb783b67a5a085bee">OutCoilMem</link>&#32;=&#32;dat[2];
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00325"/>00325 &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;<link linkend="_classbsp___mod_bus___rx_1a6612d15d148b4944662851bd8fabae04">OutCoilDat</link>&#32;=&#32;(<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)malloc(<link linkend="_classbsp___mod_bus___rx_1a062f82edfe722d8cb783b67a5a085bee">OutCoilMem</link>);
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00326"/>00326 &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;<emphasis role="keywordflow">if</emphasis>&#32;(<link linkend="_classbsp___mod_bus___rx_1a6612d15d148b4944662851bd8fabae04">OutCoilDat</link>&#32;==&#32;NULL)<emphasis role="keywordflow">break</emphasis>;
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00327"/>00327 &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;<emphasis role="keywordflow">for</emphasis>&#32;(<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>&#32;i&#32;=&#32;0;&#32;i&#32;&lt;&#32;<link linkend="_classbsp___mod_bus___rx_1a062f82edfe722d8cb783b67a5a085bee">OutCoilMem</link>;&#32;i++)
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00328"/>00328 &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;<link linkend="_classbsp___mod_bus___rx_1a6612d15d148b4944662851bd8fabae04">OutCoilDat</link>[i]&#32;=&#32;dat[3&#32;+&#32;i];
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00329"/>00329 &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;<emphasis role="keywordflow">break</emphasis>;
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00330"/>00330 &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;<emphasis role="keywordflow">case</emphasis>&#32;<link linkend="_bsp___mod_bus_8h_1ac6d9f6c262df700be9045045502e7643a8c70d4d5036c1a3f9c51a545d13fdd92">Fun_R_InCoil</link>:
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00331"/>00331 &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;<emphasis role="comment">//&#32;&#32;输入线圈</emphasis>
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00332"/>00332 &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;<link linkend="_classbsp___mod_bus___rx_1a22f49f0782c4580b0f582c27fbd758a3">InCoilMem</link>&#32;=&#32;dat[2];
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00333"/>00333 &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;<link linkend="_classbsp___mod_bus___rx_1a8ca97f2e7b033faddbb1772f15d91d4d">InCoilDat</link>&#32;=&#32;(<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)malloc(<link linkend="_classbsp___mod_bus___rx_1a22f49f0782c4580b0f582c27fbd758a3">InCoilMem</link>);
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00334"/>00334 &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;<emphasis role="keywordflow">if</emphasis>&#32;(<link linkend="_classbsp___mod_bus___rx_1a8ca97f2e7b033faddbb1772f15d91d4d">InCoilDat</link>&#32;==&#32;NULL)<emphasis role="keywordflow">break</emphasis>;
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00335"/>00335 &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;<emphasis role="keywordflow">for</emphasis>&#32;(<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>&#32;i&#32;=&#32;0;&#32;i&#32;&lt;&#32;<link linkend="_classbsp___mod_bus___rx_1a22f49f0782c4580b0f582c27fbd758a3">InCoilMem</link>;&#32;i++)
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00336"/>00336 &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;<link linkend="_classbsp___mod_bus___rx_1a8ca97f2e7b033faddbb1772f15d91d4d">InCoilDat</link>[i]&#32;=&#32;dat[3&#32;+&#32;i];
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00337"/>00337 &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;<emphasis role="keywordflow">break</emphasis>;
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00338"/>00338 &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;<emphasis role="keywordflow">case</emphasis>&#32;<link linkend="_bsp___mod_bus_8h_1ac6d9f6c262df700be9045045502e7643a9ec5f1febebcade07d80148f67d51594">Fun_R_KeepReg</link>:
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00339"/>00339 &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;<emphasis role="comment">//&#32;&#32;保持寄存器</emphasis>
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00340"/>00340 &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;<link linkend="_classbsp___mod_bus___rx_1a7622d0c8c56feb97d263f57115ef3f6a">KeepRegMem</link>&#32;=&#32;dat[2]&#32;/&#32;2;
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00341"/>00341 &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;<link linkend="_classbsp___mod_bus___rx_1a091cc0733eb4aa6b06c10afdbfd46b7f">KeepRegDat</link>&#32;=&#32;(<link linkend="_varint_8h_1ace9d960e74685e2cd84b36132dbbf8aa">u16</link>*)malloc(<link linkend="_classbsp___mod_bus___rx_1a7622d0c8c56feb97d263f57115ef3f6a">KeepRegMem</link>&#32;*&#32;2);
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00342"/>00342 &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;<emphasis role="keywordflow">if</emphasis>&#32;(<link linkend="_classbsp___mod_bus___rx_1a091cc0733eb4aa6b06c10afdbfd46b7f">KeepRegDat</link>&#32;==&#32;NULL)<emphasis role="keywordflow">break</emphasis>;
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00343"/>00343 &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;<emphasis role="keywordflow">for</emphasis>&#32;(<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>&#32;i&#32;=&#32;0;&#32;i&#32;&lt;&#32;<link linkend="_classbsp___mod_bus___rx_1a7622d0c8c56feb97d263f57115ef3f6a">KeepRegMem</link>;&#32;i++)&#32;{
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00344"/>00344 &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;((<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)<link linkend="_classbsp___mod_bus___rx_1a091cc0733eb4aa6b06c10afdbfd46b7f">KeepRegDat</link>)[1&#32;+&#32;i&#32;*&#32;2]&#32;=&#32;dat[3&#32;+&#32;i&#32;*&#32;2];
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00345"/>00345 &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;((<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)<link linkend="_classbsp___mod_bus___rx_1a091cc0733eb4aa6b06c10afdbfd46b7f">KeepRegDat</link>)[0&#32;+&#32;i&#32;*&#32;2]&#32;=&#32;dat[4&#32;+&#32;i&#32;*&#32;2];}
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00346"/>00346 &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;<emphasis role="keywordflow">break</emphasis>;
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00347"/>00347 &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;<emphasis role="keywordflow">case</emphasis>&#32;<link linkend="_bsp___mod_bus_8h_1ac6d9f6c262df700be9045045502e7643ab285b7d7c40fa9a85adba60a3a769fca">Fun_R_InReg</link>:
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00348"/>00348 &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;<emphasis role="comment">//&#32;&#32;输入寄存器</emphasis>
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00349"/>00349 &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;<link linkend="_classbsp___mod_bus___rx_1a37508047d184916eb7133a4ad8f10a6c">InRegMem</link>&#32;=&#32;dat[2]&#32;/&#32;2;
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00350"/>00350 &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;<link linkend="_classbsp___mod_bus___rx_1ab275dbfa83dd90eff0cbf0411dfe8e4a">InRegDat</link>&#32;=&#32;(<link linkend="_varint_8h_1ace9d960e74685e2cd84b36132dbbf8aa">u16</link>*)malloc(<link linkend="_classbsp___mod_bus___rx_1a37508047d184916eb7133a4ad8f10a6c">InRegMem</link>&#32;*&#32;2);
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00351"/>00351 &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;<emphasis role="keywordflow">if</emphasis>&#32;(<link linkend="_classbsp___mod_bus___rx_1ab275dbfa83dd90eff0cbf0411dfe8e4a">InRegDat</link>&#32;==&#32;NULL)<emphasis role="keywordflow">break</emphasis>;
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00352"/>00352 &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;<emphasis role="keywordflow">for</emphasis>&#32;(<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>&#32;i&#32;=&#32;0;&#32;i&#32;&lt;&#32;<link linkend="_classbsp___mod_bus___rx_1a37508047d184916eb7133a4ad8f10a6c">InRegMem</link>;&#32;i++)&#32;{
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00353"/>00353 &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;((<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)<link linkend="_classbsp___mod_bus___rx_1ab275dbfa83dd90eff0cbf0411dfe8e4a">InRegDat</link>)[1&#32;+&#32;i&#32;*&#32;2]&#32;=&#32;dat[3&#32;+&#32;i&#32;*&#32;2];
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00354"/>00354 &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;((<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)<link linkend="_classbsp___mod_bus___rx_1ab275dbfa83dd90eff0cbf0411dfe8e4a">InRegDat</link>)[0&#32;+&#32;i&#32;*&#32;2]&#32;=&#32;dat[4&#32;+&#32;i&#32;*&#32;2];}
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00355"/>00355 &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;<emphasis role="keywordflow">break</emphasis>;
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00356"/>00356 &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;<emphasis role="keywordflow">default</emphasis>:
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00357"/>00357 &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;<emphasis role="comment">//&#32;&#32;写回显与其他</emphasis>
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00358"/>00358 &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;<emphasis role="keywordflow">break</emphasis>;}}
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00360"/>00360 <emphasis role="comment">//----------------------------------------------------------------------------------------------------</emphasis>
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00361"/>00361 <emphasis role="comment">//&#32;&#32;构造函数</emphasis>
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00362"/><link linkend="_classbsp___mod_bus___tx_1ac277122ddb733aa37a0000086d5ae239">00362</link> <link linkend="_classbsp___mod_bus___tx_1ac277122ddb733aa37a0000086d5ae239">bsp_ModBus_Tx::bsp_ModBus_Tx</link>(<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>&#32;ID)&#32;{
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00363"/>00363 &#32;&#32;&#32;&#32;<link linkend="_classbsp___mod_bus___tx_1a4ee454ddd116e2b608d9b35b02eee0e4">bsp_ModBus_Tx::ID</link>&#32;=&#32;<link linkend="_classbsp___mod_bus___tx_1a4ee454ddd116e2b608d9b35b02eee0e4">ID</link>;}
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00364"/>00364 <emphasis role="comment">//----------------------------------------------------------------------------------------------------</emphasis>
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00365"/><link linkend="_classbsp___mod_bus___rx_1a87e68578770301c3d78c9b7f551bb627">00365</link> <link linkend="_classbsp___mod_bus___rx_1a87e68578770301c3d78c9b7f551bb627">bsp_ModBus_Rx::bsp_ModBus_Rx</link>(<emphasis role="keywordtype">void</emphasis>)&#32;{
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00366"/>00366 &#32;&#32;&#32;&#32;<link linkend="_classbsp___mod_bus___rx_1a091cc0733eb4aa6b06c10afdbfd46b7f">KeepRegDat</link>&#32;=&#32;NULL;
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00367"/>00367 &#32;&#32;&#32;&#32;<link linkend="_classbsp___mod_bus___rx_1ab275dbfa83dd90eff0cbf0411dfe8e4a">InRegDat</link>&#32;=&#32;NULL;
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00368"/>00368 &#32;&#32;&#32;&#32;<link linkend="_classbsp___mod_bus___rx_1a6612d15d148b4944662851bd8fabae04">OutCoilDat</link>&#32;=&#32;NULL;
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00369"/>00369 &#32;&#32;&#32;&#32;<link linkend="_classbsp___mod_bus___rx_1a8ca97f2e7b033faddbb1772f15d91d4d">InCoilDat</link>&#32;=&#32;NULL;}
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00370"/>00370 <emphasis role="comment">//----------------------------------------------------------------------------------------------------</emphasis>
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00371"/><link linkend="_classbsp___mod_bus___rx_1afa1dac97034b51725349ab5b1a2aa909">00371</link> <link linkend="_classbsp___mod_bus___rx_1afa1dac97034b51725349ab5b1a2aa909">bsp_ModBus_Rx::~bsp_ModBus_Rx</link>(<emphasis role="keywordtype">void</emphasis>){
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00372"/>00372 &#32;&#32;&#32;&#32;free(<link linkend="_classbsp___mod_bus___rx_1a6612d15d148b4944662851bd8fabae04">OutCoilDat</link>);
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00373"/>00373 &#32;&#32;&#32;&#32;free(<link linkend="_classbsp___mod_bus___rx_1a8ca97f2e7b033faddbb1772f15d91d4d">InCoilDat</link>);
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00374"/>00374 &#32;&#32;&#32;&#32;free(<link linkend="_classbsp___mod_bus___rx_1a091cc0733eb4aa6b06c10afdbfd46b7f">KeepRegDat</link>);
<anchor xml:id="_bsp___mod_bus_8cpp_source_1l00375"/>00375 &#32;&#32;&#32;&#32;free(<link linkend="_classbsp___mod_bus___rx_1ab275dbfa83dd90eff0cbf0411dfe8e4a">InRegDat</link>);}
</programlisting></section>