LIRC libraries
 All Classes Files Functions Variables Typedefs Enumerations Macros Modules Pages
Classes to send commands

Classes to send a Command to lircd and parse the reply. More...


 Internal parser FSM
 Internal parser FSM.


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...

Detailed Description

Classes to send a Command to lircd and parse the reply.

Sending data

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:

See also the, and 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:
        ... handle timeout
if not command.parser.result == lirc.client.Result.OK:
    print('Cannot get version string')