Reading from serial port asynchronously using Async await method

后端 未结 1 635
面向向阳花
面向向阳花 2021-01-06 11:02

I\'m using this way for reading from serial port :

public static void Main()
{
    SerialPort mySerialPort = new SerialPort(\"COM1\");

    mySerialPort.Baud         


        
相关标签:
1条回答
  • 2021-01-06 11:52

    You can also read data from SerialPort.BaseStream. Which is of type Stream so supports the awaitable ReadAsync() method. Converting it to a string is up to you, use the proper Encoding. The default for SerialPort is ASCIIEncoding.

    0 讨论(0)
提交回复
热议问题