[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Lua, and accessing nodes in /dev/ (Lua in Linux)...
- From: Ryanne Thomas Dolan <rtdmr6@...>
- Date: Wed, 08 Feb 2006 21:52:18 -0600
I use Lua with the UMR Robotics Team to interface with several different devices such as GPS receivers, microcontrollers, etc. So long as you don't want it to be portable, it is easy in Linux with stty:
file = "/dev/ttyUSB0";
baud = "4800";
timeout = "3";
os.execute ("stty -F " .. file .. " " .. baud .. " cread min 0 time " .. timeout);
fdin = io.open (file, "r");
On Thu, 2006-02-09 at 12:12 +1100, Matthew Percival wrote:
Thanks for the responses.
1) I tried tty:setvbuf("no"), but that seems to be 5.1 (I am using 5.0
until 5.1 stable is released)
2) luafs. I checked this out, but it does not seem like it would help
much for this.
3) I tried with \r, but there was no change. You could well be right
(I suspect you may be), but there seems to be another problem in the
4) I know this is easy in Python, so I do not think I should have to
fall back to C. If it were anything more complicated, I probably would,
but I just want a quick "check this one thing" script.
5) I checked with stty -F /dev/ttyS0 -a, and have made a couple of
6) tty:flush() does not seem to solve the problem.
It is still not reading back an `OK' (though if I run minicom and type
`AT' I get back an `OK'). The script now looks like this:
os.execute("stty -F /dev/ttyS0 115200 cols 80 rows 24")
tty = io.open("/dev/ttyS0", "rw")
--tty:setvbuf("no") Lua 5.1 only
if (tty:read("*line") ~= "OK") then
print "Modem Failed!\n"
print "Modem OK!\n"