0

I have a project I'm going to be doing on a microcontroller. I plan on having it interface with my computer over a USB serial connection. I tried doing the basic tests like putc(getc()), but I'm having trouble getting it to behave as I expect.

With that simple hardware-echo thing, many things just don't work. When I push enter, I just get a carriage return. Backspace does nothing. CTRL-C for breaking doesn't work either.

I'm using GNU Screen as my terminal emulator. How do I learn how to handle all of this(along with stty settings) so I can make a useful command interface on my microcontroller?

Earlz
  • 62,085
  • 98
  • 303
  • 499
  • 1
    It would help to know which uController you have. – walrii Aug 26 '12 at 23:25
  • @walrii are you sure? I have an mbed. Capable of being programming C and use regular putc/getc/printf type stuff for IO to the terminal on my computer. I think this is fairly microcontroller-agnostic – Earlz Aug 26 '12 at 23:29
  • 1
    As a test, try to echo the decimal value of the character. I think you'll find that it's all working. With Enter you get a CR. What else would you expect? The way things like backspace and +c will be encoded depends on terminal emulation settings. – Greg Inozemtsev Aug 26 '12 at 23:35
  • @Earlz I assumed you would need to create the IO code on the uController. Generally that involves some buffering and interrupt handling. Sounds like you have an existing library that is handling that for you. – walrii Aug 27 '12 at 00:30
  • walrii yes, all of that's handled. @Greg I mean what kind of settings for stty allow me to do things like backspace and it do what's expected? – Earlz Aug 27 '12 at 00:49
  • @Earlz I think some extra logic will be required for these beyond just echoing them back. For example, say Ctrl+C is translated into ASCII ETX and sent out on the wire. Your board echoes it back, but Screen has no idea what to do with an incoming ETX. You'd have to decide if ETX should kill the program on the board, exit Screen, or do something else. Backspace should work, but is probably being translated into DEL where BS is expected, or vice versa. – Greg Inozemtsev Aug 27 '12 at 02:23

1 Answers1

2

You will need to know what terminal type your Screen terminal is emulating so that you know what codes to send out the serial port. For example, if you set your terminal to VT100, you can check out this link which provides some VT100 codes

And for gnu-screen you might want to check this out as it contains an exhaustive list of ESC and control strings/commands that you can use.

Chimera
  • 5,884
  • 7
  • 49
  • 81