SerialPort encoding - how do I get 8 bit ASCII?

前端 未结 3 1812
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-23 16:34

I\'m having a problem with a program that communicates over a serial port. One of the characters it must send and receive is the degree symbol, ASCII 0xBF. It\'s been working fi

3条回答
  •  北恋
    北恋 (楼主)
    2021-01-23 17:26

    System.Text.ASCIIEncoding isn't the right encoding to use for 8-bit communication. Instead use e.g. the "ISO 8859-1 Latin 1; Western European (ISO)" code page:

    port.Encoding = Encoding.GetEncoding(28591);
    

提交回复
热议问题