lua-users home
lua-l archive

Re: Lua, and accessing nodes in /dev/ (Lua in Linux)...

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


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

AltStyle によって変換されたページ (->オリジナル) /