In my SerialPort.DataReceived event handler, I check SerialData.Eof :
void DataReceived(object sender, SerialDataReceivedEventArgs e) { if (e.EventType == SerialData.Eof) throw new NotImplementedException("SerialData.Eof");
In my development up to this point, I have never encountered this exception. But today, while working on another part of the protocol, he did.
My question is: what does SerialData.Eof mean? MSDN says:
The end of the file character was received and placed in the input buffer.
I am dealing with binary data. What is the "end of file character"?
This MSDN forum post states that
the DCB.EofChar element always gets initialized to 0x1A (Ctrl + Z)
In the reference sources for the SerialStream class on line 1343, we see what is really:
dcb.EofChar = NativeMethods.EOFCHAR;
And in Microsoft.Win32.NativeMethods :
internal const byte EOFCHAR = (byte) 26;
Does this mean that at any time when my device sends a 0x1A byte, I get a SerialData.Eof event? If so, should I just stop testing for him at all?
Jonathon reinhart
source share