This is a console for interacting with Vodafone dongles.

Dependencies:   mbed-rtos VodafoneUSBModem mbed

This is a bridge between a serial driven console and a serial driven cellular modem or modem interface. This was written to complement our collaboration with mbed: See https://mbed.org/users/mbed_official/code/VodafoneUSBModem/ for further information.

For example, one can use GNU screen or PuTTY (two popular consoles) to interact with a Vodafone K3770 USB dongle. In the image below I used the UNIX version of PuTTY:

/media/uploads/ashleymills/atcons.png

Support is provided for line-based consoles, which send one line at a time, and for character based consoles.

For character based consoles, the following line-editing features are provided:

  • In-line editing (deletion, left/right arrow keys, insertion)
  • Command history (via up/down arrow keys)

Line buffer length, and command history depth, are compile-time options.

--

How to use:

Compile and save to mbed.

Connect PuTTY or GNU screen to serial port.

If you use GNU screen you probably already know what you are doing.

If you use PuTTY, you need to set the options to specify the serial device and, set the baud rate, and set the "Connection Type" to "Serial":

/media/uploads/ashleymills/putty0.png

You need to set the keyboard to send Control-H for backspace, and use "Linux" function keys and keypad:

/media/uploads/ashleymills/putty1.png

Revision:
6:93003e18889c
Parent:
5:6841a01b3a69
Child:
7:f46ec146f3de
--- a/Console.h	Tue Sep 18 09:42:40 2012 +0000
+++ b/Console.h	Tue Sep 18 10:06:07 2012 +0000
@@ -4,43 +4,54 @@
 #define BUFFER_WAIT_TIMEOUT_MS 2000
 
 class Console {
-    private:
-        int _currentLine;
-        int _usedLines;
-        
-        long _bufferWaitTimeout_ms;
-        char **_lines; //< Command history
-
-        int _linePos;
-        int _prevLinePos;
-
-        bool waitForInput();
-        void loadPreviousBuffer();
-        void loadNextBuffer();
-        
-        void printLineBuffer();
-        void printHistory();
-        void printBuffer(int index);
-        void reprintBuffer();
-        void storeBuffer();
-        void updateCharacterBased();
-        void updateLineBased();
-        
-        virtual void processCommand();
-        
-          
-        
-    protected:
-        char *_lineBuffer;
-        int _lineLength;
-        int _numLines;
-        Serial *_terminal;
-        void clearBuffer();
-        bool _characterBased;
-           
+               
     public:
+        /**
+         * Construct an interface to a serial terminal.
+         * @param terminal The serial device to interface to.
+         * @param lineLength The maximum line-length to process.
+         * @param numLines The number of lines to hold in the command-history.
+         * @param characterBased true for character based serial devices, false for line based.
+         */
         Console(Serial *terminal, int lineLength, int numLines, bool characterBased);
         ~Console();
+        /**
+         * This is called by the instantiating program to update the console.
+         */
         virtual void update();
+    
+    protected:
+        char *_lineBuffer;             //< Buffer for current-line.
+        int _lineLength;               //< Length of current-line buffer.
+        int _numLines;                 //< Number of lines in the command history.
+        Serial *_terminal;             //< Pointer to terminal interface.
+        /// Whether or not this console is character based (true) or line based (false).
+        bool _characterBased
+        
+        void clearBuffer();            //< Clears the current-line buffer.
+        
+    private:
+        char **_lines;                 //< Command history
+        int _currentLine;              //< Index of current line in command history.
+        int _usedLines;                //< Number of lines that have been used in the command history.
+        
+        long _bufferWaitTimeout_ms;    //< This is used when multi-byte sequences are predicted.
+      
+        int _linePos;                  //< Keeps track of the cursor in the current-line.
+        int _prevLinePos;              //< Used when a new line is selected from command history, to clear old line.
 
+        bool waitForInput();           //< Waits for _bufferWaitTimeout_ms for input from the console.
+        void loadPreviousBuffer();     //< Load the previous line in the command history.
+        void loadNextBuffer();         //< Load the next line in the command history.
+        
+        void printLineBuffer();        //< Prints the current-line buffer.
+        void printHistory();           //< Print the entire command-history.
+        void printBuffer(int index);   //< Print buffer at index in the command-history.
+        void reprintBuffer();          //< Clears old buffer and reprints it, used for insertion etc.
+        void storeBuffer();            //< Store the current-line in the command history.
+        void updateCharacterBased();   //< Called by update() for character-based consoles.
+        void updateLineBased();        //< Called by update() for line-based consoles.
+    
+        virtual void processCommand(); //< Process a command retrieved from the console.
+          
 };
\ No newline at end of file