lua-users home
lua-l archive

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


	I was trying to write a simple Lua script to check modem status; for a
test script, I simply wanted to send `AT' and check if I receive `OK' in
return. I have been doing it like this:

tty ="/dev/ttyS0", "rw")
if (tty:read("*line") ~= "OK") then
	print "Modem Failed!\n"
	print "Modem OK!\n"

	However, it just blocks at the read, never receiving anything back.  My
first thought is that it is missing the OK, but I was also wondering if
it were because were not compatible with device nodes: when I
checked liolib.c, I saw that it uses fopen() (and thereby everything
uses FILE*), when I need it to use open().

	Does anyone know if it is possible to do this in Lua?  I would imagine
I would would need to write a different io library set for file
descriptors (in place of the FILE* library currently used), but even if
I did this I am not sure whether that would be enough or not.

	-- Matthew