Sending “ENTER” key through serial port

后端 未结 8 1913
独厮守ぢ
独厮守ぢ 2020-12-17 00:11

Hi I want to send some command to my device which is connected via serial port. How to send it?

For example i found this on google search but for me it\'s useless.

8条回答
  •  囚心锁ツ
    2020-12-17 00:57

    You need send the commands CR (Carriage Return) and LF (Line Feed, or new line).

    For this is just to send your command plus the the CR and LF like this:

    string command = "myCommand";
    
    port.write(string.format("{0}\r\n", command));
    

    \r\n = CR + LF -> Used as a new line character in Windows

提交回复
热议问题