搜索
bottom↓
回复: 3

UART2TCP 不明白

[复制链接]

出0入0汤圆

发表于 2014-11-12 17:19:06 | 显示全部楼层 |阅读模式
本帖最后由 tara0809 于 2014-11-12 17:26 编辑

         请教UART2TCP 中红色的部分 w 是指的什么呢?
TCPFlush()是在什么情况下调用?
谢谢!
// Transmit pending data that has been placed into the UART RX FIFO (in the ISR)
                        //
                        wMaxPut = TCPIsPutReady(MySocket);        // Get TCP TX FIFO space
                        wMaxGet = RXHeadPtrShadow - RXTailPtrShadow;        // Get UART RX FIFO byte count
                        if(RXHeadPtrShadow < RXTailPtrShadow)
                                wMaxGet += sizeof(vUARTRXFIFO);
                        if(wMaxPut > wMaxGet)                                // Calculate the lesser of the two
                                wMaxPut = wMaxGet;
                        if(wMaxPut)                                                        // See if we can transfer anything
                        {
                                // Transfer the data over.  Note that a two part put
                                // may be needed if the data spans the vUARTRXFIFO
                                // end to start address.
                                w = vUARTRXFIFO + sizeof(vUARTRXFIFO) - RXTailPtrShadow;
                                if(wMaxPut >= w)
                                {
                                        TCPPutArray(MySocket, RXTailPtrShadow, w);
                                        RXTailPtrShadow = vUARTRXFIFO;
                                        wMaxPut -= w;
                                }
                                TCPPutArray(MySocket, RXTailPtrShadow, wMaxPut);
                                RXTailPtrShadow += wMaxPut;

                                // No flush.  The stack will automatically flush and do
                                // transmit coallescing to minimize the number of TCP
                                // packets that get sent.  If you explicitly call TCPFlush()
                                // here, latency will go down, but so will max throughput
                                // and bandwidth efficiency.

                        }

                        //
                        // Transfer received TCP data into the UART TX FIFO for future transmission (in the ISR)
                        //
                        wMaxGet = TCPIsGetReady(MySocket);        // Get TCP RX FIFO byte count
                        wMaxPut = TXTailPtrShadow - TXHeadPtrShadow - 1;// Get UART TX FIFO free space
                        if(TXHeadPtrShadow >= TXTailPtrShadow)
                                wMaxPut += sizeof(vUARTTXFIFO);
                        if(wMaxPut > wMaxGet)                                // Calculate the lesser of the two
                                wMaxPut = wMaxGet;
                        if(wMaxPut)                                                        // See if we can transfer anything
                        {
                                // Transfer the data over.  Note that a two part put
                                // may be needed if the data spans the vUARTTXFIFO
                                // end to start address.
                                w = vUARTTXFIFO + sizeof(vUARTTXFIFO) - TXHeadPtrShadow;
                                if(wMaxPut >= w)
                                {
                                        TCPGetArray(MySocket, TXHeadPtrShadow, w);
                                        TXHeadPtrShadow = vUARTTXFIFO;
                                        wMaxPut -= w;
                                }
                                TCPGetArray(MySocket, TXHeadPtrShadow, wMaxPut);
                                TXHeadPtrShadow += wMaxPut;
                        }

出0入0汤圆

发表于 2014-11-12 18:03:17 | 显示全部楼层
我也看不到呀呀呀

出0入0汤圆

 楼主| 发表于 2014-11-12 20:53:48 | 显示全部楼层
ruanxianwu 发表于 2014-11-12 18:03
我也看不到呀呀呀

看不到什么

出0入8汤圆

发表于 2014-11-12 23:41:42 来自手机 | 显示全部楼层
w是读指针到fifo尾部的数据长度,此时数据发生了循环溢出,写指针从fifo首部开始了。tcpflush的作用,上面的注释有提到了,可以仔细看看,即立即发送,否则,发送会缓冲延迟
回帖提示: 反政府言论将被立即封锁ID 在按“提交”前,请自问一下:我这样表达会给举报吗,会给自己惹麻烦吗? 另外:尽量不要使用Mark、顶等没有意义的回复。不得大量使用大字体和彩色字。【本论坛不允许直接上传手机拍摄图片,浪费大家下载带宽和论坛服务器空间,请压缩后(图片小于1兆)才上传。压缩方法可以在微信里面发给自己(不要勾选“原图),然后下载,就能得到压缩后的图片】。另外,手机版只能上传图片,要上传附件需要切换到电脑版(不需要使用电脑,手机上切换到电脑版就行,页面底部)。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|Archiver|amobbs.com 阿莫电子技术论坛 ( 粤ICP备2022115958号, 版权所有:东莞阿莫电子贸易商行 创办于2004年 (公安交互式论坛备案:44190002001997 ) )

GMT+8, 2024-5-5 15:25

© Since 2004 www.amobbs.com, 原www.ourdev.cn, 原www.ouravr.com

快速回复 返回顶部 返回列表