[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Lua, and accessing nodes in /dev/ (Lua in Linux)...
- From: Matthew Percival <matthew@...>
- Date: Thu, 09 Feb 2006 10:25:25 +1100
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 = io.open("/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 io.open 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.