In my ongoing quest to interface with some legacy equipment, I've discovered that the vendor supplied software sets the special characters to:
00 00 00 00 11 13
But the SerialPort class of .NET set them to:
1A 00 00 1A 11 13
I suppose that I have two questions:
- What do these bytes mean?
- How can I tell SerialPort to use a specific set of special characters?
The latter is all I really care about, but I suspect the former is going to be useful to know.
Update: The following doesn't work:
byte[] specialchars = {
0x00,
0x00,
0x00,
0x00,
0x11,
0x13
};
this.port.NewLine = System.Text.Encoding.ASCII.GetString(specialchars);
Update 2: As requested, here are Portmon logs for the vendor supplied app (filtered to remove the many thousands of IOCTL_SERIAL_GET_COMMSTATUS entries) and for my attempt to match even the first exchange.
You can add an extenstion to the serialPort in c# :
http://social.msdn.microsoft.com/Forums/vstudio/en-us/89b88e89-5814-4819-8b50-7caa3faf5f54/xonxoff-values-in-net20-serialport-class?forum=csharpgeneral
for the other fields you can change :
Code :
NewLine
is not what you are looking for. It's the plain old 'new line' sequence, e.g. CR LF or LF alone.The special characters are handled like this:
SerialPort.ParityReplace
It may be helpful for you to study the Win32 DCB structure as well. It's used by .NET internally to set the state of the serial port.