Compare commits

...
6 Commits
Author SHA1 Message Date
MightyPork 6f32a6ef1a fix messed up insert/delete with region 2017-09-02 01:04:30 +02:00
MightyPork d3468a109c fix bug with hanging flag left set after GoTo col 80 2017-09-02 00:40:08 +02:00
MightyPorkandGitHub 8f82b81434 Update README.md 2017-08-25 15:19:26 +02:00
MightyPorkandGitHub 653dc55d85 Update README.md 2017-08-25 15:18:55 +02:00
MightyPork dda469ff21 Updated the xterm comparison page 2017-08-25 15:07:16 +02:00
MightyPork 3515e178cb Updated readme 2017-08-25 15:06:54 +02:00
3 changed files with 93 additions and 72 deletions
+69 -43
View File
@@ -1,76 +1,100 @@
# ESPTerm
ESP8266 Wireless Terminal Emulator project
ESPTerm is a terminal emulator running on the ESP8266 WiFi chip.
The firmware emulates VT102 with some additional features based on `xterm` and later VT models, and the terminal screen can be accessed using any web browser, even on a phone or tablet. It works with ESP-01, ESP-01S, ESP-12 and likely many other modules (I use ESP-12 on a NodeMCU board for development).
This project is based on SpriteTM's esphttpd and libesphttpd, forked by MightyPork to
[MightyPork/esphttpd](https://github.com/MightyPork/esphttpd) and
[MightyPork/libesphttpd](https://github.com/MightyPork/libesphttpd) respectively.
ESPTerm can add remote access via WiFi to any embeded project, all you need is a serial port.
Those forks include improvements not available upstream.
## Screenshots, photos
## Goals
- Look at the [GitHub releases page][releases], there are some pics.
The project aims to be a wireless terminal emulator that'll work with the likes of
Arduino, AVR, PIC, STM8, STM32, mbed etc, anything with UART, even your USB-serial dongle will work.
## ESPTerm features
Connect it to the master device via UART and use the terminal on the built-in web page for debug logging,
remote control etc. It works like a simple LCD screen, in a way.
- **Robust WiFi configuration interface**
- static IP
- DHCP
- AP channel and strength setting
- AP password
- SSID search for finding your existing network
- **Almost complete VT102 emulation** with some extras
- *Sufficient to run most Linux console applications, including ncurses-based ones\**
- All standard SGR (text style attributes) supported
- Full UTF-8 support
- Alternate character sets support
- 16 colors
- Scrolling Region, Origin Mode
- Tab Stops
- Cursor save/restore
- Character/Line insert, delete, clear operations
- Audible BEL (ASCII 7 beep)
- Most standard queries (get cursor position, get SGR, get screen size...)
- All DEC private options either implemented or safely consumed by the parser
- **Other features:**
- Screen size up to 80x25
- Real-time screen update via WebSocket
- Button to open Android software keyboard
- 5 buttons under the screen for quick commands
- Button labels can be changed (by OSC commands or via settings)
- Screen title can be changed (by OSC commands or via settings)
- Built-in help page with basic troubleshooting and command reference
It lets you make simple UI (manipulating the screen with ANSI sequences) and receive input from buttons on
the webpage (and keyboard on PC). There is some rudimentary touch input as well.
\*) Linux console applications run via agetty at ttyUSB0 were used for testing, obviously you'll be better off using SSH for remote shell
The screen size is adjustable up to 25x80 (via a special control sequence) and uses 16 standard colors
(8 dark and 8 bright). Both default size and colors can be configured in the settings.
ESPTerm firmware is written in C and is based on SpriteTM's `libesphttpd` http server library, forked by MightyPork to
[MightyPork/libesphttpd](https://github.com/MightyPork/libesphttpd) respectively. This fork includes various improvements and changes required by the project.
## Project status
## Running ESPTerm
*A little buggy, but mostly okay! There are many features and fixes planned, but it should be fairly usable already.*
To run ESPTerm on your ESP8266, either build it yourself from source using `xtensa-lx106-elf-gcc` (and the included Makefile), or download pre-built binaries from the [GitHub releases section][releases]. Flash the binaries using [esptool](https://github.com/espressif/esptool).
- We have a working **2-way terminal** (UART->ESP->Browser and vice versa) with real-time update via websocket.
This means that what you type in the browser is sent to UART0 and what's received on UART0 is processed by the
ANSI parser and applied to the internal screen buffer. You'll also immediately see the changes in your browser.
There's a filter in the way that discards garbage characters (like unicode and most ASCII outside 32-126).
For a quick test, try connecting the UART0 Rx and Tx with a piece of wire to make a loopback interface.
*NOTE: Use the bare module, not something like LoLin or NodeMCU with a FTDI, it'll interfere*.
You should then directly see what you type & can even try some ANSI sequences, right from the browser.
- All ANSI sequences that make sense, as well as control codes like Backspace and CR / LF are implemented.
Set colors with your usual `\e[31;1m` etc (see Wikipedia). `\e` is the ASCII code 27 (ESC).
Arrow keys generate ANSI sequences, ESC sends literal ASCII code 27 etc. Almost everything can be input
straight from the browser.
### Pins
- Buttons pressed in the browser UI send ASCII codes 1..5. Mouse clicks are sent as `\e[<row>;<col>M`.
- Pin GPIO2 is used for debug messages at 115200 baud, 8 bit, no parity.
- Pins Rx and Tx are used for the main communication UART. Connect your USB-serial dongle or application microcontroller here.
- There's a built-in WiFi config page and a Help page with a list of all supported ANSI sequences and other details.
### Console commands - escape sequences
- A list of most supported commands can be found here: http://bits.ondrovo.com/espterm-xterm.html
- To set the screen title, use `OSC 0 ; title ST` (`OSC` = `ESC ]`, `ST` = `ESC \` or ASCII 7)
- To set buttons text, use `OSC 8 1 ; text ST` with 81 through 85.
- Mouse clicks (as of v0.6.9) generate `CSI row ; col M` at the Tx pin (`CSI` = `ESC [`)
- For more info, look eg. on Wikipedia or here: http://ascii-table.com/ansi-escape-sequences-vt-100.php
### Setup
- When flashed for the first time, ESPTerm wipes any possible previous WiFi configuration, because it implements its own WiFi config manager with many additional features.
- It should start in AP mode, the default SSID being `TERM-MACADR` with `MACADR` being three unique bytes from the MAC address / Device ID.
- Connect to it via a smartphone or laptop and configure WiFi as desired.
- To re-enable the built-in AP, hold the BOOT (GPIO0) button for about 1 s, until the blue LED starts slowly flashing. Then release the button!
- To reset all settings to defaults, hold the BOOT (GPIO0) button until the blue LED flashes rapidly, then release the button.
- When you accidentally make the blue LED flash, you can cancel the operation by pressing Reset or disconnecting its power supply. The wipe is done on the button's release.
### Config files
ESPTerm has two config "files", one for defaults and one for the currently used settings. In the case of the terminal config, there is also a third, temporary file for changes done via ESC commands.
When you get your settings *just right*, you can store them as defaults, which can then be at any time restored by holding the BOOT (GPIO0) button. You can do this on the System Settings page. This asks for an "admin password", which you can define when building the firmware in the `esphttpdconfig.mk` file. The default password is `19738426`. This password can't presently be changed without re-flashing the firmware.
You can also restore everything (except the saved defaults) to "factory defaults", there is a button for this on the System Settings page. Those are the initial values in the config files.
## Development
### Installation for development
- Clone this project with `--recursive`, or afterwards run `git submodule init` and `git submodule update`.
- Install [esp-open-sdk](https://github.com/pfalcon/esp-open-sdk/) and build it with
`make toolchain esptool libhal STANDALONE=n`.
`make toolchain esptool libhal STANDALONE=n`.
Make sure the `xtensa-lx106-elf/bin` folder is on $PATH.
- Install [esptool](https://github.com/espressif/esptool) (it's in the Arch community repo and on AUR, too)
- Set up udev rules so you have access to ttyUSB0 without root, eg:
```
KERNEL=="tty[A-Z]*[0-9]*", GROUP="uucp", MODE="0666"
```
- Install Ragel if you wish to make modifications to the ANSI sequence parser.
If not, comment out its call in `build_parser.sh`. The `.rl` file is the actual source, the `.c` is generated.
- Install Ruby and then the `sass` package with `gem install sass` (or try some other implementation, such as
`sassc`)
- Make sure your `esphttpdconfig.mk` is set up properly - link to the SDK etc.
The IoT SDK is now included in the project due to problems with obtaining the correct version and patching it.
@@ -80,7 +104,7 @@ than welcome!
### Web resources
The web resources are in `html_orig`. To prepare for a build, run `build_web.sh`, which packs them and
copies over to `html`. The compression and minification is handled by scripts in libesphttpd, specifically
copies over to `html`. The compression and minification is handled by scripts in libesphttpd, specifically,
it runs yuicompressor on js and css and gzip or heatshrink on the other files. The `html` folder is
then embedded in the firmware image.
@@ -97,3 +121,5 @@ Sometimes it does not, particularly with `make -B`. Try just plain `make`. You c
build scripts manually, too.
To flash, just run `make flash`.
[releases]: https://github.com/MightyPork/esp-vt100-firmware/releases
+7 -4
View File
@@ -671,10 +671,11 @@ CSI ? <i>Pm</i> h
<i>Ps</i> = 1 -&gt; Application Cursor Keys (DECCKM).
<i>Ps</i> = 2 -&gt; Designate USASCII for character sets G0-G3
(DECANM), <del>and set VT100 mode.</del>
<del><i>Ps</i> = 3 -&gt; 132 Column Mode (DECCOLM).</del>
<i>Ps</i> = 3 -&gt; 132 Column Mode (DECCOLM). <ins>ESPTerm doesn't have enough RAM for 132x25,
but it implements the side effects of clearing the screen and resetting the scolling region.</ins>
<del><i>Ps</i> = 4 -&gt; Smooth (Slow) Scroll (DECSCLM).</del>
<i>Ps</i> = 5 -&gt; Reverse Video (DECSCNM).
<i>Ps</i> = 6 -&gt; Origin Mode (DECOM). <ins><b>TODO implement</b></ins>
<i>Ps</i> = 6 -&gt; Origin Mode (DECOM).
<i>Ps</i> = 7 -&gt; Wraparound Mode (DECAWM).
<del><i>Ps</i> = 8 -&gt; Auto-repeat Keys (DECARM).</del>
<del><i>Ps</i> = 9 -&gt; Send Mouse X &amp; Y on button press. See the sec-
@@ -1078,7 +1079,7 @@ CSI ! p Soft terminal reset (DECSTR).
<i>Ps</i> = 2 -&gt; DECSED and DECSEL can erase.</del>
CSI <i>Ps</i> ; <i>Ps</i> r
Set Scrolling Region [top;bottom] (default = full size of win-
dow) (DECSTBM). <ins><b>TODO</b> implement</ins>
dow) (DECSTBM).
CSI ? <i>Pm</i> r
Restore DEC Private Mode Values. The value of <i>Ps</i> previously
saved is restored. <i>Ps</i> values are the same as for DECSET. <ins><b>TODO</b> implement</ins>
@@ -1304,10 +1305,12 @@ OSC <i>Ps</i> ; <i>Pt</i> ST
and window title.
<i>Ps</i> = 0 -&gt; Change <del>Icon Name and</del> Window Title to <i>Pt</i>.
<del><i>Ps</i> = 1 -&gt; Change Icon Name to <i>Pt</i>.</del>
<i>Ps</i> = 2 -&gt; Change Window Title to <i>Pt</i>.
<i>Ps</i> = 2 -&gt; Change Window Title to <i>Pt</i>. <ins>(same as 0)</ins>
<del><i>Ps</i> = 3 -&gt; Set X property on top-level window. <i>Pt</i> should be
in the form "<i>prop=value</i>", or just "<i>prop</i>" to delete the prop-
erty</del>
<ins><i>Ps</i> = 81-85 -&gt; Change text of button 1 through 5. Empty string
makes the button appear disabled (grayed out).</ins>
<del><i>Ps</i> = 4 ; <i>c</i>; <i>spec</i> -&gt; Change Color Number <i>c</i> to the color spec-
ified by <i>spec</i>. This can be a name or RGB specification as per
<i>XParseColor</i>. Any number of <i>c</i>/<i>spec</i> pairs may be given. The
+17 -25
View File
@@ -123,7 +123,8 @@ static volatile int notifyLock = 0;
/**
* Restore hard defaults
*/
void terminal_restore_defaults(void)
void ICACHE_FLASH_ATTR
terminal_restore_defaults(void)
{
termconf->default_bg = 0;
termconf->default_fg = 7;
@@ -141,14 +142,16 @@ void terminal_restore_defaults(void)
/**
* Apply settings after eg. restore from defaults
*/
void terminal_apply_settings(void)
void ICACHE_FLASH_ATTR
terminal_apply_settings(void)
{
terminal_apply_settings_noclear();
screen_init();
}
/** this is used when changing terminal settings that do not affect the screen size */
void terminal_apply_settings_noclear(void)
void ICACHE_FLASH_ATTR
terminal_apply_settings_noclear(void)
{
bool changed = false;
@@ -513,7 +516,7 @@ void screen_delete_lines(unsigned int lines)
NOTIFY_LOCK();
// shift lines up
int targetEnd = H - 1 - lines;
int targetEnd = R1 - lines - 1;
if (targetEnd <= cursor.y) {
targetEnd = cursor.y;
} else {
@@ -632,7 +635,7 @@ screen_scroll_up(unsigned int lines)
{
NOTIFY_LOCK();
if (lines >= RH) {
clear_range(R0*W, (R1+1)*H-1);
clear_range(R0*W, (R1+1)*W-1);
goto done;
}
@@ -660,7 +663,7 @@ screen_scroll_down(unsigned int lines)
{
NOTIFY_LOCK();
if (lines >= RH) {
clear_range(R0*W, (R1+1)*H-1);
clear_range(R0*W, (R1+1)*W-1);
goto done;
}
@@ -709,21 +712,8 @@ void ICACHE_FLASH_ATTR
screen_cursor_set(int y, int x)
{
NOTIFY_LOCK();
if (cursor.origin_mode) {
y += R0;
if (y > R1) y = R1;
if (y < R0) y = R0;
}
else {
if (y > H-1) y = H-1;
if (y < 0) y = 0;
}
if (x >= W) x = W - 1;
if (x < 0) x = 0;
cursor.x = x;
cursor.y = y;
clear_invalid_hanging();
screen_cursor_set_x(x);
screen_cursor_set_y(y);
NOTIFY_DONE();
}
@@ -745,8 +735,12 @@ screen_cursor_set_x(int x)
{
NOTIFY_LOCK();
if (x >= W) x = W - 1;
if (x < 0) x = 0;
cursor.x = x;
clear_invalid_hanging();
// Always clear hanging on cursor set
// hanging happens when the cursor is virtually at col=81, which
// cannot be set using the cursor-set commands.
cursor.hanging = false;
NOTIFY_DONE();
}
@@ -1039,9 +1033,7 @@ screen_putchar(const char *ch)
case BS:
if (cursor.x > 0) {
// backspace should go to col 79 if "hanging" after 80 (as if it never actually left the 80th col)
if (cursor.hanging) {
cursor.hanging = false;
}
cursor.hanging = false;
cursor.x--;
}
// we should not wrap around, and backspace should not even clear the cell (verified in xterm)