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

2020-02-11 18:46发布

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

3条回答
劳资没心,怎么记你
2楼-- · 2020-02-11 19:09

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

查看更多
干净又极端
3楼-- · 2020-02-11 19:13
\x03

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

查看更多
劳资没心,怎么记你
4楼-- · 2020-02-11 19:14

You should send a character with the ASCII code 3:

serial.write('\x03')
查看更多
登录 后发表回答