Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does PuTTY send when I press Enter key?

I am trying desperately to get a Bluetooth dongle working with my Arduino but I can't send it a command that it needs. I can use it when I plug it into my computer via a USB to UART chip and send the command (C) from PuTTY and then press Enter.

The Bluetooth dongle's command sheet says that the command I am trying to send it C<cr> but I can't figure out how to send the proper carriage return character from the Arduino code. I have tried using the Serial.println() function as well as adding the \r character to my current Serial.write("C\r") but neither of those are working.

How can I achieve this?

like image 986
Sponge Bob Avatar asked Aug 17 '12 00:08

Sponge Bob


People also ask

Is it possible to press Ctrl+J to send in putty?

I found that it is possible to press CTRL+J to send - but I would like to press just enter. Someone advised to set Terminal->"Implicit CR in every LF". But this does not work for me (I assume it is for what putty receives not send).

How to send both CR and LF keystrokes in putty?

In Putty, there are several options that are related to CR (“\r”) or LF (“\n”) but none of them makes pressing enter key sends both CR and LF.

Is there a way to send a newline in putty?

The modified PuTTY is the easiest solution. If you want to stick with the standard PuTTY, there's some other options... You can send a newline using ctrl+j before pressing enter, but that's a faff. To automate it, you can use AutoHotKey to change your {ENTER} to ^J {ENTER} when you've got a PuTTY window active:

Is putty supposed to send control-m by default?

My scope clearly shows that Putty's default is to send only. This is not documented. @carveone, I found the docs here, see sec. 4.6.14:<br/> By default, PuTTY sends the Telnet New Line code when you press Return, instead of sending Control-M as it does in most other protocols.


3 Answers

Sending CR+LF is possible in modified PuTTY. Source code is available at https://github.com/gniemirowski/putty-crlf and Windows binary at https://www.grzegorz.net/pliki/putty-crlf.zip When you run this version just go to Terminal -> Keyboard and select "CR LF" for "The Enter key" option.

enter image description here

like image 174
grzegorz Avatar answered Oct 19 '22 07:10

grzegorz


Interestingly, I can report the opposite on Win 7: PuTTY for me and my embedded project is sending ONLY \r over the COM port. Curious, read: frustratingly unexplainable, but I simply look for either character on the other end of the serial connection.

Then, if you enable "Implicit LF in every CR" under Terminal options it will send both \r\n. Default behaviour seems to be akin to a Commodore machine :D (http://en.wikipedia.org/wiki/Newline). who knew...

like image 24
Sowka Avatar answered Oct 19 '22 05:10

Sowka


PuTTY emulates xterm which emulates vt100. To have putty send CR/LF when pressing enter, type ESC[20h in putty after connecting to the serial device. This sets VT100 LNM true.

http://vt100.net/docs/vt100-ug/chapter3.html

Line feed/new line New line ESC [20h Line feed ESC [20l

like image 7
bubbasnmp Avatar answered Oct 19 '22 05:10

bubbasnmp