I have an application that I need to disable parity checking for Serial or Com Ports in Windows XP, Vista, or Windows 7.
I am currently using The .NET Framework SerialPort class
the reason I ask is because I get framing errors because I am changing the parity
fairly quickly and looks to be occurring as bytes are being received by the com port.
NOTE: I have to emulate 9 data bits and the only way to do so with the SerialPort Class is to use mark or space parity.
None, even or odd parity will not work.
I think that using DCB to change fParity to false or 0 would be the best way to solve my issue.
I know my program basically works other than the parity errors that I see with a serial port monitoring program.
Example code segments.
Private Poll1()
{
SerialPort1.Parity=Parity.Mark;
SerialPort1.Write(GenPoll,0,2);
SerialPort1.Parity=Parity.Space;
int numbytes1 = SerialPort1.BytestoRead;
Byte[] readbuffer1 = new Byte[numbytes1]; creates a Byte array
SerialPort1.Read(readbuffer1,numbytes1);
.......
}
example of sending a
command to the machine
private SendCommand1(Byte[] Command)
{
SerialPort1.Parity=Parity.Mark;
SerialPort1.Write(Command,0,1); Address byte
SerialPort1.Parity=Parity.Space;
SerialPort1.Write(Command,1,Command.Length-1); command to the machine.
}
[edit]Code block added - OriginalGriff[/edit]