10 years, 2 months ago.

How to use a computer to do commands while a main function is running, TeraTerm, mbed

Hi Im troubling a bit with an mbed assignment. Im running an alarm function/system, and I'm going connect with TeraTerm as a "console". My problem is that I want to give commands in TeraTerm while the loop is running, and don't want it to stop until I´ve typed the right command. The way its running now, the loop must stop until a command is written, which is not something I want because I can't have the function stopping just because someone hits the keyboard. Can anyone help me out with this? Thanks

Anders Dahl

2 Answers

10 years, 2 months ago.

You can use interrupts to only put a char in a buffer when it is received. Then if it receives for example \n it evaluates the buffer. You can also have a look at MODSERIAL, which can do this partially automatically.

10 years, 2 months ago.

Take a look at my program CanonicalInputProcessing https://mbed.org/users/paulg/code/CanonicalInputProcessing/ . I think it does what you are looking for.

This program uses MODSERIAL to buffer incoming serial data. You can edit the incoming data (i.e. the command line) using BS and Delete. When you press Enter, MODSERIAL sets a flag. The main loop detects this and then processes the command line.