📄 windowsce_net 420串口驱动分析(3)--jesse.htm
字号:
<TABLE width="95%" border=0>
<TBODY>
<TR>
<TD><STRONG>留言板</STRONG></TD></TR>
<TR>
<TD>
<DIV align=left>
<DIV align=left>
<SCRIPT
src="windowsCE_net 420串口驱动分析(3)--jesse.files/show_newmessage.htm"></SCRIPT>
</DIV></DIV></TD></TR></TBODY></TABLE><BR>
<TABLE height=36 width="95%" border=0>
<TBODY>
<TR>
<TD><STRONG>链接</STRONG></TD></TR>
<TR>
<TD height=15>
<DIV align=left>
<SCRIPT
src="windowsCE_net 420串口驱动分析(3)--jesse.files/show_links.htm"></SCRIPT>
<SCRIPT
src="windowsCE_net 420串口驱动分析(3)--jesse.files/ad_userlinks.htm"></SCRIPT>
</DIV></TD></TR></TBODY></TABLE><BR>
<TABLE width="95%" border=0>
<TBODY>
<TR>
<TD><STRONG>Blog信息</STRONG></TD></TR>
<TR>
<TD>
<DIV align=left>
<SCRIPT
src="windowsCE_net 420串口驱动分析(3)--jesse.files/show_info.htm"></SCRIPT>
</DIV></TD></TR></TBODY></TABLE>
<P align=center>
<SCRIPT
src="windowsCE_net 420串口驱动分析(3)--jesse.files/show_xml.htm"></SCRIPT>
<BR></P>
<DIV align=center></DIV>
<DIV align=center><BR></DIV></TD></TR></TBODY></TABLE></TD>
<TD vAlign=top align=middle><BR><BR>
<DIV id=saveurl><A
href="http://www.embeddedhelp.com/oblog/user1/6/index.html">首页</A> | <A
href="http://www.embeddedhelp.com/oblog/go.asp?action=up&logid=13&userid=6">上一篇</A>
| <A
href="http://www.embeddedhelp.com/oblog/go.asp?action=down&logid=13&userid=6">下一篇</A></DIV>
<TABLE style="TABLE-LAYOUT: fixed; WORD-BREAK: break-all" cellSpacing=1
cellPadding=3 width="98%" bgColor=#cccccc border=0>
<TBODY>
<TR bgColor=#f8f8f8>
<TD><FONT
size=4><STRONG>windowsCE.net 420串口驱动分析(3)</STRONG></FONT><BR>jesse
发表于 2005-10-9 13:19:18 </TD></TR>
<TR bgColor=#ffffff>
<TD height=0>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">接收分支:在接收分支的开始计算软件缓冲器的剩余空间,如果有剩余的空间的话直接调用</SPAN><SPAN
lang=EN-US>HWRxIntrHandler(PDDa</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">实现</SPAN><SPAN
lang=EN-US>)</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">来从硬件缓冲区获取剩余空间大小的数据,若已无剩余空间则建立一个</SPAN><SPAN
lang=EN-US>16byte</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的临时缓冲区,将数据读入该区域,实际上这个缓冲区在后面根本就不会被读取所以这些数据全部丢失掉了这也就自然需要统计硬件</SPAN><SPAN
lang=EN-US>/</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">软件缓冲导致的数据丢失</SPAN><SPAN
lang=EN-US>(</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">接收不及时导致</SPAN><SPAN
lang=EN-US>)</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">。接下来就是所谓</SPAN><SPAN
lang=EN-US>XFlow</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的流程了,所谓</SPAN><SPAN
lang=EN-US>XFlow</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">就是我们上面提到的软件流控制。也就是用软件的方法来协调发送和接收端的收发,保障数据的完整接收。当接收到</SPAN><SPAN
lang=EN-US>XOFF/XON</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">标记的时候由于这个标记本身不数据数据而是控制标志,所以要讲后面的数据全部前置一位,覆盖掉</SPAN><SPAN
lang=EN-US>XON/XOFF</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的位置。同时还需要根据标示的具体状态来设置</SPAN><SPAN
lang=EN-US>DCB</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">结构中的控制标示来控制数据收发流程。如果是</SPAN><SPAN
lang=EN-US>XON</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">标志,还需要在处理完接收流程后恢复发送流程。接收的动作会改变</SPAN><SPAN
lang=EN-US>write</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">标记的位置,这里需要重新计算该标示。至于硬件流控制的流程中该驱动模型是以缓冲器的</SPAN><SPAN
lang=EN-US>75%</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">为分位点来起停收发的,可用的硬件连线可以是</SPAN><SPAN
lang=EN-US>DTR,</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">也可以是</SPAN><SPAN
lang=EN-US>RTS</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">(模式相同仅仅是连线不同),这里的操作很简单,仅仅是通过计算缓冲器的存储状态来清除该标志就完成了硬件流控制的操作。由于在此过程中</SPAN><SPAN
lang=EN-US>IST</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">与其他部分是同步执行的</SPAN><SPAN
lang=EN-US>,</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">所以这个时候如果使用</SPAN><SPAN
lang=EN-US>XFlow</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">可能还会需要做一次安全检查。这样接收的流程就结束了。</SPAN>
</P>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">发送分支:</SPAN>
<SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">我们同样来看看</SPAN><SPAN
lang=EN-US>TX_BUFFER_INFO</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">结构,看样子似乎该结构维护了一个和</SPAN><SPAN
lang=EN-US>TX</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">缓冲类似的缓冲区,但事实上这个缓冲区域是不独立存在的,发送的流程因为可以直接使用所需发送的数据的存储区域来作为发送缓冲,所以这个缓冲没有独立存在的必要。由于使用其它进程的数据区域,所以这里增加了权限控制项的成分,用于突破进程间的访问限制。</SPAN>
</P>
<P class=MsoNormal><SPAN lang=EN-US>typedef struct
__TX_BUFFER_INFO {</SPAN> </P>
<P class=MsoNormal><SPAN lang=EN-US><SPAN
style="mso-tab-count: 1">
</SPAN>DWORD<SPAN style="mso-tab-count: 1">
</SPAN>Permissions;<SPAN
style="mso-tab-count: 2">
</SPAN>/* @field Current permissions */</SPAN> </P>
<P class=MsoNormal><SPAN lang=EN-US><SPAN
style="mso-tab-count: 1">
</SPAN>ULONG<SPAN
style="mso-tab-count: 1">
</SPAN>Read;<SPAN
style="mso-tab-count: 4">
</SPAN>/* @field Current Read index. */</SPAN> </P>
<P class=MsoNormal><SPAN lang=EN-US><SPAN
style="mso-tab-count: 1">
</SPAN>ULONG<SPAN
style="mso-tab-count: 1">
</SPAN>Length;<SPAN
style="mso-tab-count: 4">
</SPAN>/* @field Length of buffer */</SPAN> </P>
<P class=MsoNormal><SPAN lang=EN-US><SPAN
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -