相当于使用 C# SerialPort class 设置 termios c_iflag=IGNPAR
Equivalent to setting termios c_iflag=IGNPAR using C# SerialPort class
我正在尝试将与串行设备通信的旧 C 应用程序移植到 C# 中。
C 应用程序在设置串行通信时设置以下字段:
newtio.c_iflag = IGNPAR;
newtio.c_oflag = 0;
我没有看到在 C# 中复制它的方法,我相信这会导致串行设备在发送“9C”时表现不同。
https://msdn.microsoft.com/en-us/library/system.io.ports.parity(v=vs.110).aspx
Public enum Parity
Even Sets the parity bit so that the count of bits set is an even number.
Mark Leaves the parity bit set to 1.
None No parity check occurs.
Odd Sets the parity bit so that the count of bits set is an odd number.
Space Leaves the parity bit set to 0.
你应该对None
感兴趣
使用此构造函数创建端口:
https://msdn.microsoft.com/en-us/library/system.io.ports.serialport(v=vs.110).aspx
public SerialPort(
string portName,
int baudRate,
Parity parity
)
使用此方法设置奇偶校验值:
https://msdn.microsoft.com/en-us/library/system.io.ports.serialport.parity(v=vs.110).aspx
_serialPort.Parity = SetPortParity(_serialPort.Parity);
我正在尝试将与串行设备通信的旧 C 应用程序移植到 C# 中。 C 应用程序在设置串行通信时设置以下字段:
newtio.c_iflag = IGNPAR;
newtio.c_oflag = 0;
我没有看到在 C# 中复制它的方法,我相信这会导致串行设备在发送“9C”时表现不同。
https://msdn.microsoft.com/en-us/library/system.io.ports.parity(v=vs.110).aspx
Public enum Parity
Even Sets the parity bit so that the count of bits set is an even number.
Mark Leaves the parity bit set to 1.
None No parity check occurs.
Odd Sets the parity bit so that the count of bits set is an odd number.
Space Leaves the parity bit set to 0.
你应该对None
使用此构造函数创建端口:
https://msdn.microsoft.com/en-us/library/system.io.ports.serialport(v=vs.110).aspx
public SerialPort(
string portName,
int baudRate,
Parity parity
)
使用此方法设置奇偶校验值:
https://msdn.microsoft.com/en-us/library/system.io.ports.serialport.parity(v=vs.110).aspx
_serialPort.Parity = SetPortParity(_serialPort.Parity);