Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of MTS-Cellular by
Utils/Terminal.h@4:1f63354b8d1b, 2014-05-20 (annotated)
- Committer:
- Mike Fiore
- Date:
- Tue May 20 16:11:38 2014 -0500
- Revision:
- 4:1f63354b8d1b
- Parent:
- 1:f155d94d6f3a
use MTSLog, put mbed.h in cpp files
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mfiore | 0:830c436480e3 | 1 | #ifndef TERMINAL_H |
mfiore | 0:830c436480e3 | 2 | #define TERMINAL_H |
mfiore | 0:830c436480e3 | 3 | |
Mike Fiore |
1:f155d94d6f3a | 4 | #include "MTSBufferedIO.h" |
Mike Fiore |
1:f155d94d6f3a | 5 | #include "MTSSerial.h" |
Mike Fiore |
1:f155d94d6f3a | 6 | |
Mike Fiore |
1:f155d94d6f3a | 7 | namespace mts |
Mike Fiore |
1:f155d94d6f3a | 8 | { |
Mike Fiore |
1:f155d94d6f3a | 9 | |
Mike Fiore |
1:f155d94d6f3a | 10 | // A constant holding the exit message for the terminal program. |
Mike Fiore |
1:f155d94d6f3a | 11 | const std::string exitMsg = "emtech"; |
Mike Fiore |
1:f155d94d6f3a | 12 | |
Mike Fiore |
1:f155d94d6f3a | 13 | /** This class provides terminal style access to a serial interface on the |
Mike Fiore |
1:f155d94d6f3a | 14 | * processor. This is done by seamlessly "connecting" the data traffic between the |
Mike Fiore |
1:f155d94d6f3a | 15 | * mbed debug interface, usually accessed through the USB port, and the serial |
Mike Fiore |
1:f155d94d6f3a | 16 | * interface in question. Once started you can also exit this mode by sending the |
Mike Fiore |
1:f155d94d6f3a | 17 | * appropraite exit sequence through your terminal program. This sequence is: emtech |
Mike Fiore |
1:f155d94d6f3a | 18 | */ |
Mike Fiore |
1:f155d94d6f3a | 19 | class Terminal |
Mike Fiore |
1:f155d94d6f3a | 20 | { |
Mike Fiore |
1:f155d94d6f3a | 21 | public: |
Mike Fiore |
1:f155d94d6f3a | 22 | /** This constructs a Terminal object that connects the standard |
Mike Fiore |
1:f155d94d6f3a | 23 | * mbed USB serial inteface to the passed in serial interface. In |
Mike Fiore |
1:f155d94d6f3a | 24 | * odrder for this class to function you must call the start method. |
Mike Fiore |
1:f155d94d6f3a | 25 | * |
Mike Fiore |
1:f155d94d6f3a | 26 | * @param io the serial interface to connect to the console as an |
Mike Fiore |
1:f155d94d6f3a | 27 | * MTSBufferedIO object. |
Mike Fiore |
1:f155d94d6f3a | 28 | */ |
Mike Fiore |
1:f155d94d6f3a | 29 | Terminal(MTSBufferedIO* io); |
Mike Fiore |
1:f155d94d6f3a | 30 | |
Mike Fiore |
1:f155d94d6f3a | 31 | /** Destructs an Terminal object and frees all created resources. |
Mike Fiore |
1:f155d94d6f3a | 32 | */ |
Mike Fiore |
1:f155d94d6f3a | 33 | ~Terminal(); |
Mike Fiore |
1:f155d94d6f3a | 34 | |
Mike Fiore |
1:f155d94d6f3a | 35 | /** This starts the terminal functionality and is a blocking call |
Mike Fiore |
1:f155d94d6f3a | 36 | * until you send the exit sequence "emtech" through you terminal |
Mike Fiore |
1:f155d94d6f3a | 37 | * program, at which point this method returns. |
Mike Fiore |
1:f155d94d6f3a | 38 | */ |
Mike Fiore |
1:f155d94d6f3a | 39 | void start(); |
Mike Fiore |
1:f155d94d6f3a | 40 | |
Mike Fiore |
1:f155d94d6f3a | 41 | private: |
Mike Fiore |
1:f155d94d6f3a | 42 | MTSBufferedIO* io; //The interface you want terminal access to |
Mike Fiore |
1:f155d94d6f3a | 43 | MTSSerial* terminal; //The interface to the console or terminal |
Mike Fiore |
1:f155d94d6f3a | 44 | int index; //The index you are at with the exit sequence |
Mike Fiore |
1:f155d94d6f3a | 45 | }; |
Mike Fiore |
1:f155d94d6f3a | 46 | |
Mike Fiore |
1:f155d94d6f3a | 47 | } |
Mike Fiore |
1:f155d94d6f3a | 48 | |
Mike Fiore |
1:f155d94d6f3a | 49 | #endif /* TERMINAL_H */ |