Answer the question
In order to leave comments, you need to log in
How to correctly send data via Serialport C# to a microcontroller?
It is necessary to send a number (within 0-255) to serialPort from the computer to the STM32 microcontroller. The idea is as follows - we translate the number into a symbol and push it to the port. However, it is not always what we would like. I send the string "qweqweqwe" to the serialPort and everything comes through. But when I send, for example, the number 231 (i.e. 'ç'), I get 63 (i.e. '?'). What could be the problem?
Answer the question
In order to leave comments, you need to log in
The documentation for SerialPort.Write says:
By default, SerialPort uses ASCIIEncoding to encode the characters. ASCIIEncoding encodes all characters greater then 127 as (char)63 or '?'. To support additional characters in that range, set Encoding to UTF8Encoding, UTF32Encoding, or UnicodeEncoding.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question