LIRC libraries
LinuxInfraredRemoteControl
|
Classes to send a Command to lircd and parse the reply. More...
Modules | |
Internal parser FSM | |
Internal parser FSM. | |
Classes | |
class | lirc.client.CommandConnection |
Extends the parent with a send() method. More... | |
class | lirc.client.Result |
Public reply parser result, available when completed. More... | |
class | lirc.client.Command |
Command, parser and connection container with a run() method. More... | |
class | lirc.client.Reply |
The status/result from parsing a command reply. More... | |
class | lirc.client.ReplyParser |
Handles the actual parsing of a command reply. More... | |
Classes to send a Command to lircd and parse the reply.
Sending commands is about creating a command and connection. In the simplest form it looks like
import lirc with lirc.CommandConnection(socket_path=...) as conn: reply = lirc.StopRepeatCommand(conn, 'mceusb', 'KEY_1').run() if not reply.success: print(parser.data[0])
See also the list-remotes.py, list-keys.py and simulate.py examples.
The parameters depends on the actual command; there is a Command defined for all known lircd commands. socket_path can often be omitted, see get_default_socket_path() for default locations used.
The returned object is a Reply with various info on the processed command.
To get more control lower-level primitives could be used instead of run() as in this example:
while not command.parser.is_completed(): line = conn.readline(0.1) if line: command.parser.feed(line) else: ... handle timeout if not command.parser.result == lirc.client.Result.OK: print('Cannot get version string') else: print(command.parser.data[0]) ... conn.close()