<分区>
我问这个是为了防止我错误地使用了 SerialPort.Write()。我很确定我没有,但你永远不知道...
SerialPort.Write(byte[], int, int) 的文档状态:
By default, SerialPort uses ASCIIEncoding to encode the characters. ASCIIEncoding encodes all characters greater than 127 as (char)63 or '?'. To support additional characters in that range, set Encoding to UTF8Encoding, UTF32Encoding, or UnicodeEncoding.
这与 SerialPort.Write(string) 文档中的注释相同和 SerialPort.Write(char[], int, int) .
多年来一直如此,但我以前从未真正注意到它。我一直很高兴地使用 SerialPort.Write(byte[], int, int)
来发送值大于 0x7f 的二进制数据。我发现发送字节数组的文档在谈论字符很奇怪。
是我的问题,还是那里的文档有问题?