gpt4 book ai didi

c# - 相当于使用 C# SerialPort 类设置 termios c_iflag=IGNPAR

转载 作者:行者123 更新时间:2023-11-30 16:50:20 26 4
gpt4 key购买 nike

我正在尝试将与串行设备通信的旧 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.

您应该对感兴趣

使用此构造函数创建端口:
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# SerialPort 类设置 termios c_iflag=IGNPAR,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42234092/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com