Overhaul Lua API

Lua API moved into a tio library table and names adjusted to Lua stdlib style.
Regex in expect() replaced with Lua patterns so binary data can be handled.
New tio.alwaysecho variable allows enabling and disabling echo to console.
Read and write functions now manage complex retry and timeout logic internally,
giving the user a simple "nil if fail" API like the rest of Lua.
exit() was removed, os.exit() already exists in the Lua standard library.
This commit is contained in:
ii8 2025-06-13 15:49:33 +01:00
parent 8f33cff6ea
commit 114b69b68a
9 changed files with 318 additions and 465 deletions

View file

@ -1,17 +1,15 @@
read(1000, 8000) -- read initial config
write("\n")
read(650, 100) -- main menu
write("S") -- S menu
n = 1
while n > 0 do -- while not empty, read more
n, str = read_line(25)
end
tio.read(1000, 8000) -- read initial config
tio.write("\n")
tio.read(650, 100) -- main menu
tio.write("S") -- S menu
repeat
str = tio.readline(25)
until str == nil
while true do
write("t") -- query PV table
msleep(880)
n = 1
while n > 0 do -- while not empty, read more
n, str = read_line(60)
msleep(60)
end
tio.write("t") -- query PV table
tio.msleep(880)
repeat
str = tio.readline(60)
tio.msleep(60)
until str == nil
end