PySerial: How to send Ctrl-C command on the serial line

老子叫甜甜 提交于 2019-11-28 02:41:44

问题


I'm automating a configuration process for an embedded board. To enter the setup screen I need to send "Ctrl-C" command.

This is NOT to interrupt a process I'm running locally, KeyboardInterrupt will not work. I need to send a value that will be interpreted by the bootloader as Ctrl-C.

What is the value I need to send?

Thank you


回答1:


IIRC, Ctrl-C is etx. Thus send \x03.




回答2:


You should send a character with the ASCII code 3:

serial.write('\x03')



回答3:


\x03

Which means 'end of text' or 'break' is what Ctrl+C sends.



来源:https://stackoverflow.com/questions/7018139/pyserial-how-to-send-ctrl-c-command-on-the-serial-line

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!