【发布时间】:2013-01-08 01:17:27
【问题描述】:
我正在调试一些串行的东西,重要的部分是 SerialDataReceivedEventHandler。
我观察到(通过断点和悬停)读取的字节数几乎是缓冲区大小本身的两倍。喜欢吗?
这是代码
aUartSemaphoreThatTells.WhatTheUartBackgroundRxIsDoing = (int)aValueWhichIndicatesThat.theUARTisReceivingData;
SerialPort CurrentPort = (SerialPort)sender; //// Int routine gave is this in the arguments
int LastByteInUartBuffer = CurrentPort.ReadBufferSize;
int TheNumberOfBytes = CurrentPort.BytesToRead;
byte[] inputData = new byte[TheNumberOfBytes];
int RenameThisInt = CurrentPort.Read(inputData, 0, TheNumberOfBytes); //// This is a C# property method of ports
int Dest;
Dest = UartPlaceHolders.RxBufferLeader; //// Will index into buffer for Chief dispatch
做一点鼠标悬停告诉我......
-
LastByteInUartBuffer有 4096 个 -
TheNumberOfBytes有 8092 -
RenameThisInt有 8092 个 -
inputData有正确的东西
(我知道串行端口另一端的数据是什么样的,因为我自己生成它们)
我阅读了 MSDN 网站上的这两页,ReadBufferSize 和 BytesToRead
任何人,请纠正我。如何从 4K 缓冲区中获取近 8K 字节?
【问题讨论】:
标签: c# serial-port