lua-users home
lua-l archive

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


Of course I have already read in the mailing list but anyway I could not get success, so I wrote in the lua mailing list, I think I would find a quickly solution, but nobody answer about it, althought it's a very common task I think (comm with a serial device).
Well now I can write a solution to the problem: yes it isn't necessary to use any addon, with the lua IO library I finally can to communicate with a modem, this is the correct code:
---------
local file="/dev/ttyS1"
local fd_r=assert(io.open(file,"r"))
local fd_w=assert(io.open(file,"w"))
fd_w:setvbuf("no")  --no buffering
fd_r:flush()
fd_w:flush()

cmd="at\r"
print("writing: ",cmd)
fd_w:write(cmd)
r = fd_r:read("*l")
print("reading1: ",r)  --read that I've write
r = fd_r:read("*l")
print("reading2: ",r)  --real answer

fd_w:close()
fd_r:close()
---------
Thanks for all.

----- Mensaje original ----
De: Asko Kauppi <askok@dnainternet.net>
Para: Lua list <lua@bazar2.conectiva.com.br>
Enviado: miércoles, 24 de octubre, 2007 18:23:17
Asunto: Re: How to use serial port to communications


Lua mailing list search:  

http://lua-users.org/lists/lua-l/

"serial interface" ->

http://lua-users.org/cgi-bin/namazu.cgi?query=serial+interface&sort=score&idxname=lua-l&max=20


Super Macho kirjoitti 24.10.2007 kello 16:55:

Hi,
I know and use lua certain time ago, but until now I have not need the use of serial port to communicate with for example a modem device. I have tried to use io library and to use io.open and file:write and file:read but there is not ok communication.
Is possible with this library? or is it necesary some kind of extension or addon?
Help me please, thanks.



Sé un Mejor Amante del Cine
¿Quieres saber cómo? ¡Deja que otras personas te ayuden! .





Sé un Mejor Amante del Cine
¿Quieres saber cómo? ¡Deja que otras personas te ayuden! .