[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua, and accessing nodes in /dev/ (Lua in Linux)...
- From: Matthew Percival <matthew@...>
- Date: Thu, 09 Feb 2006 16:27:28 +1100
G'Day,
> https://robotics.umr.edu:7651/svn/lua/gps.lua
> https://robotics.umr.edu:7651/svn/lua/com.lua
Thanks a lot for those examples! They gave me some ideas to try out,
and eventually I got it to work. I first noticed you had separate in
and out streams: I do not understand why, but when I did that too I was
suddenly able to write --- if someone could point me to something that
would help me to understand this, it would be most appreciated! Now I
can write, I read back an '\r' (unfortunately); if I pass over this and
read again, I get a response from the modem! My final code is as below:
os.execute("stty -F /dev/ttyS0 115200 cread min 0 time 3")
ttyin = assert(io.open("/dev/ttyS0", "r"))
ttyout = assert(io.open("/dev/ttyS0", "w"))
ttyout:write("AT\r")
ttyout:flush()
ttyin:flush()
reply = ttyin:read("*line")
while (reply == "\r") do
ttyin:flush()
reply = ttyin:read("*line")
end
if (reply ~= "OK\r") then
print "Modem Failed!\n"
else
print "Modem OK!\n"
end
ttyin:close()
ttyout:close()
There is probably a better way to do some of this, but this works at
least.
Thank you for taking the time to lend me a hand: it has helped me a
great deal!
-- Matthew
- References:
- Lua, and accessing nodes in /dev/ (Lua in Linux)..., Matthew Percival
- Re: Lua, and accessing nodes in /dev/ (Lua in Linux)..., David Given
- Re: Lua, and accessing nodes in /dev/ (Lua in Linux)..., Matthew Percival
- Re: Lua, and accessing nodes in /dev/ (Lua in Linux)..., Ryanne Thomas Dolan
- Re: Lua, and accessing nodes in /dev/ (Lua in Linux)..., Matthew Percival
- Re: Lua, and accessing nodes in /dev/ (Lua in Linux)..., Ryanne Thomas Dolan