I'm using and ESP8266 with Nodemcu to communicate with a serial terminal using Putty. Using escape sequences like referenced in these questions:
Read ANSI escape from terminal
How do I determine size of ANSI terminal?
List of escape sequences https://vt100.net/docs/vt100-ug/chapter3.html
I am trying to read back an escape sequence that is a reply to find the cursor position using LUA. I don't seem to be getting a visible reply (expected), but I also don't seem to get anything. Everything except the reply seems to work.
What am I doing wrong, how can I capture the response?
-- Clear screen
uart.write(0, "\033[2J")
-- Setup event handler callback to read data from terminal
-- Control sequence is terminated with an 'R'
-- I'm replacing ESC in the reply so that I can hopefully get a visible reply like _[25;80R
uart.on("data", 0, function(data)
if data ~= 'R' then
uart.write(0, data)
end
if data == '\033' then
uart.write(0, "_")
end
end, 0)
-- ESC = \033
-- cursorpos(v,h) CUP Move cursor to screen location v,h ^[[<v>;<h>H
uart.write(0, "\033[20;20H")
uart.write(0, "\033[6n")
-- Response:
-- cursorpos CPR Response: cursor is at v,h ^[<v>;<h>R