Sending “ENTER” key through serial port

后端 未结 8 1951
独厮守ぢ
独厮守ぢ 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:38

    To send the enter key, you would have to use

    serial.Write(new byte[]{13,10}, 0, 2);
    

    Assuming your syntax for Control + E is correct. The enter key is interpreted and usually saved in a file as CR-LF. However, depending on your device, it may only require CR=13, or LF=10. You should try all 3 combinations with your device to see what it expects.

    If you are looking for the actual scan code of the enter key, it's "43" on a PC 102/104 key keyboard. Depending on the actually computer you are using, it may be different. For instance on a Commodore 64 the scan code for the Return key is "1", which has the equivalent use of Enter on a PC keyboard.

提交回复
热议问题