![]() |
LIRC libraries
LinuxInfraredRemoteControl
|
Interface to read raw code strings like irw(1) or translated application strings like ircat(1). More...
Classes | |
| class | lirc.async_client.AsyncConnection |
| Asynchronous read interface on top of an AbstractConnection. More... | |
| class | lirc.client.AbstractConnection |
| Abstract interface for all connections. More... | |
| class | lirc.client.RawConnection |
| Interface to receive code strings as described in lircd(8). More... | |
| class | lirc.client.LircdConnection |
| Interface to receive lircrc-translated keypresses. More... | |
Interface to read raw code strings like irw(1) or translated application strings like ircat(1).
Asynchronous interfaces to read lirc data on tóp of client.py.
Reading raw data direct from the lircd socket can be done with the RawConnection object using something like
from lirc import RawConnnection
with RawConnection(socket_path) as conn:
while True:
keypress = conn.readline()
... do something with keypress
The optional socket_path argument is the path to the lircd socket. Refer to get_default_socket_path() for defaults if omitted.
See also the irw.py example.
Reading application strings translated with lircrc can be achieved using
from lirc import LircdConnection
with LircdConnection(program, lircrc_path, socket_path) as conn:
while True:
string = conn.readline()
... do domething with string
The arguments:
See also the ircat.py example
Asynchronous read of raw data direct from the lircd socket can be done with the RawConnection class using something like:
import asyncio
from lirc import RawConnection, AsyncConnection
async def main(raw_conn, loop):
async with AsyncConnection(raw_conn, loop) as conn:
async for keypress in conn:
print(keypress)
if __name__ == "__main__":
socket_path = .....
loop = asyncio.get_event_loop()
with RawConnection(socket_path) as raw_conn:
loop.run_until_complete(main(raw_conn, loop))
loop.close()
Using a LircdConnection with translated values works the same way. The API is unstable.