mirror of
https://github.com/tio/tio.git
synced 2026-05-01 14:57:59 +02:00
Add documentation and examples for new features.
This commit is contained in:
parent
1b0ef08d95
commit
2316c0216a
7 changed files with 702 additions and 73 deletions
21
examples/lua/expects.lua
Normal file
21
examples/lua/expects.lua
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
--
|
||||
-- example of intaction with AT modem.
|
||||
--
|
||||
tio.write("AT\r")
|
||||
local matches, all = tio.expect("OK", 1000)
|
||||
if matches == nil then
|
||||
tio.echo("no response 1\r\n")
|
||||
os.exit(0)
|
||||
end
|
||||
msleep(200)
|
||||
tio.read(1000, tio.C.NOWAIT)
|
||||
tio.write("ATFANTASYCMD\r")
|
||||
local idx, matches, all = tio.expects({"OK", "ERROR", "BUSY"}, 1000)
|
||||
if idx == nil then
|
||||
tio.echo("no response 2\r\n")
|
||||
os.exit(0)
|
||||
end
|
||||
|
||||
-- this display 2, ERROR
|
||||
print(idx, matches[1])
|
||||
os.exit(0)
|
||||
Loading…
Add table
Add a link
Reference in a new issue