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

Committer:
ashleymills
Date:
Tue Sep 18 12:05:34 2012 +0000
Revision:
7:f46ec146f3de
Parent:
6:93003e18889c
Child:
9:578003606ccc
Removed debug statements. Fixed typo.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ashleymills 0:6c831cc49d22 1 #pragma once
ashleymills 0:6c831cc49d22 2 #include "mbed.h"
ashleymills 0:6c831cc49d22 3
ashleymills 5:6841a01b3a69 4 #define BUFFER_WAIT_TIMEOUT_MS 2000
ashleymills 0:6c831cc49d22 5
ashleymills 0:6c831cc49d22 6 class Console {
ashleymills 6:93003e18889c 7
ashleymills 0:6c831cc49d22 8 public:
ashleymills 6:93003e18889c 9 /**
ashleymills 6:93003e18889c 10 * Construct an interface to a serial terminal.
ashleymills 6:93003e18889c 11 * @param terminal The serial device to interface to.
ashleymills 6:93003e18889c 12 * @param lineLength The maximum line-length to process.
ashleymills 6:93003e18889c 13 * @param numLines The number of lines to hold in the command-history.
ashleymills 6:93003e18889c 14 * @param characterBased true for character based serial devices, false for line based.
ashleymills 6:93003e18889c 15 */
ashleymills 4:6971bded3ebd 16 Console(Serial *terminal, int lineLength, int numLines, bool characterBased);
ashleymills 0:6c831cc49d22 17 ~Console();
ashleymills 6:93003e18889c 18 /**
ashleymills 6:93003e18889c 19 * This is called by the instantiating program to update the console.
ashleymills 6:93003e18889c 20 */
ashleymills 2:8cc63f7a24cf 21 virtual void update();
ashleymills 6:93003e18889c 22
ashleymills 6:93003e18889c 23 protected:
ashleymills 6:93003e18889c 24 char *_lineBuffer; //< Buffer for current-line.
ashleymills 6:93003e18889c 25 int _lineLength; //< Length of current-line buffer.
ashleymills 6:93003e18889c 26 int _numLines; //< Number of lines in the command history.
ashleymills 6:93003e18889c 27 Serial *_terminal; //< Pointer to terminal interface.
ashleymills 6:93003e18889c 28 /// Whether or not this console is character based (true) or line based (false).
ashleymills 7:f46ec146f3de 29 bool _characterBased;
ashleymills 6:93003e18889c 30
ashleymills 6:93003e18889c 31 void clearBuffer(); //< Clears the current-line buffer.
ashleymills 6:93003e18889c 32
ashleymills 6:93003e18889c 33 private:
ashleymills 6:93003e18889c 34 char **_lines; //< Command history
ashleymills 6:93003e18889c 35 int _currentLine; //< Index of current line in command history.
ashleymills 6:93003e18889c 36 int _usedLines; //< Number of lines that have been used in the command history.
ashleymills 6:93003e18889c 37
ashleymills 6:93003e18889c 38 long _bufferWaitTimeout_ms; //< This is used when multi-byte sequences are predicted.
ashleymills 6:93003e18889c 39
ashleymills 6:93003e18889c 40 int _linePos; //< Keeps track of the cursor in the current-line.
ashleymills 6:93003e18889c 41 int _prevLinePos; //< Used when a new line is selected from command history, to clear old line.
ashleymills 0:6c831cc49d22 42
ashleymills 6:93003e18889c 43 bool waitForInput(); //< Waits for _bufferWaitTimeout_ms for input from the console.
ashleymills 6:93003e18889c 44 void loadPreviousBuffer(); //< Load the previous line in the command history.
ashleymills 6:93003e18889c 45 void loadNextBuffer(); //< Load the next line in the command history.
ashleymills 6:93003e18889c 46
ashleymills 6:93003e18889c 47 void printLineBuffer(); //< Prints the current-line buffer.
ashleymills 6:93003e18889c 48 void printHistory(); //< Print the entire command-history.
ashleymills 6:93003e18889c 49 void printBuffer(int index); //< Print buffer at index in the command-history.
ashleymills 6:93003e18889c 50 void reprintBuffer(); //< Clears old buffer and reprints it, used for insertion etc.
ashleymills 6:93003e18889c 51 void storeBuffer(); //< Store the current-line in the command history.
ashleymills 6:93003e18889c 52 void updateCharacterBased(); //< Called by update() for character-based consoles.
ashleymills 6:93003e18889c 53 void updateLineBased(); //< Called by update() for line-based consoles.
ashleymills 6:93003e18889c 54
ashleymills 6:93003e18889c 55 virtual void processCommand(); //< Process a command retrieved from the console.
ashleymills 6:93003e18889c 56
ashleymills 0:6c831cc49d22 57 };