我正在调试一些串行的东西,重要的部分是 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
有 4096TheNumberOfBytes
有 8092RenameThisInt
有 8092inputData
有合适的东西
(我知道串行端口另一端的数据是什么样的,因为我自己生成它们)
我阅读了 MSDN 网站上的这两页 ReadBufferSize和BytesToRead
任何人,请纠正我。如何从 4K 缓冲区中获取近 8K 字节?