Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
11 years, 5 months ago.
can't detect enter key on serial PC
This seems to be really basic but it's not working. I'm simply reading the input from a user over a serial console and want to see if he pressed the enter key but the key is not being detected. The other keys work though
- include "mbed.h"
Serial pc(USBTX, USBRX);
int main() {
char c; while(1) {
c = pc.getc(); if (c == '\n') pc.printf("You pressed enter");
} }
3 Answers
11 years, 5 months ago.
What SW do you use for terminal communication? Check settings at "append".
I tried PuTTY and there was a problem with this, but in Termite 2.9, which is my favorite (google it), it works well. (There i have "Append LF" in settings)
11 years, 5 months ago.
I'm not sure I understand what you're telling me. I'm using serial port from the terminal application of my mac. I just put the command screen /dev/tty.device to connect to my device that's all I know.
What you get will depend on your terminal application and its settings. You would normally receive CR (\r or 0x0d) although there may be an option turning this into \r\n (0x0d 0x0a) but in your case that does not seem to be the case. You can also just print out what you receive using a %02x printf format to find out.
posted by Peter Holzleitner 14 Jul 2013