重要な部分は SerialDataReceivedEventHandler です。
バッファ サイズ自体のほぼ 2 倍のバイト数を読み取る必要があることを (ブレークポイントとホバー オーバーを介して) 観察しています。みたいな?
これがコードです
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
Mouse-Hover-Over を少し実行すると、それがわかります..
LastByteInUartBuffer
4096ありますTheNumberOfBytes
8092ありますRenameThisInt
8092ありますinputData
適切なものがあります
(自分で生成したので、シリアルポートの反対側からデータがどのように見えるかを知っています)
MSDN サイトの ReadBufferSizeとBytesToReadの 2 つのページを読みました。
誰でも、私を修正してください。4K バッファーからほぼ 8K バイトを取得するにはどうすればよいですか?