diff options
| author | Eugene Triguba <eugenetriguba@gmail.com> | 2020-10-03 22:48:04 -0500 |
|---|---|---|
| committer | Eugene Triguba <eugenetriguba@gmail.com> | 2020-10-03 22:48:04 -0500 |
| commit | f9c60014ede3edda8569745b725f1b458bb400ff (patch) | |
| tree | c5dc6edeb0518b234139afb832dc81f17303cf53 /docs/source | |
| parent | Add napoleon for Sphinx (diff) | |
| download | lirc-f9c60014ede3edda8569745b725f1b458bb400ff.zip | |
Update usage for Client
Diffstat (limited to '')
| -rw-r--r-- | docs/source/usage.rst | 48 |
1 files changed, 22 insertions, 26 deletions
diff --git a/docs/source/usage.rst b/docs/source/usage.rst index ef9aa96..9898459 100644 --- a/docs/source/usage.rst +++ b/docs/source/usage.rst @@ -6,32 +6,26 @@ of things you can now import from it to get started. .. code-block:: python - from lirc import ( - Lirc, - LircResponse, - LircError, - LircSocketError, - LircSocketTimeoutError, - InvalidReplyPacketFormatError - ) + from lirc import Client, LircdConnection -The most relevant of these is ``Lirc``, since this is the main class -you will be using. ``LircResponse`` is the response object that is returned -when you send a command. All the others are just errors. +The most relevant of these is ``Client``, since this is the main class +you will be using. ``LircdConnection`` is the object that is used to configure +the connection to LIRC when you initialize the ``Client``. Initializing Lirc ----------------- -The ``Lirc`` class takes in three separate options: ``address``, ``socket``, -and ``timeout``. These all have default values that depend on the operating -system you are on. So the simplest way to construct ``Lirc`` is with no +The ``Client`` class takes in one optional keyword argument: connection. +This connection must be a ``LircdConnection``. This connection, if not +specified manuall, will have default values that depend on the operating +system you are on. So the simplest way to construct ``Client`` is with no arguments at all. .. code-block:: python - from lirc import Lirc + from lirc import Client - lirc = Lirc() + lirc_client = Client() Overriding LIRC Defaults on Initialization ------------------------------------------ @@ -45,20 +39,22 @@ just to show that we can, these are already the defaults on Windows. .. code-block:: python import socket - from lirc import Lirc - - lirc = Lirc( - address=("10.16.30.2", 8765), - socket=socket.socket(socket.AF_INET, socket.SOCK_STREAM), - timeout=5 + from lirc import Client, LircdConnection + + client = Client( + connection=LircdConnection( + address=("10.16.30.2", 8765), + socket=socket.socket(socket.AF_INET, socket.SOCK_STREAM), + timeout=5.0 + ) ) LIRC Initialization Defaults per Operating System ----------------------------------------------- -From the options we may pass into ``Lirc``, ``address`` and ``socket`` will -change depending on the operating system you are using. The ``timeout`` always -defaults to 5 (seconds). +From the options we may pass into the ``LircdConnection``, ``address`` +and ``socket`` will change depending on the operating system you are using. +The ``timeout`` always defaults to 5.0 (seconds). On Linux, this will attempt to connect to the lircd socket at ``/var/run/lirc/lircd`` and create a socket using ``AF_UNIX`` and @@ -74,4 +70,4 @@ WinLIRC uses TCP to communicate with the lirc daemon. So instead of a string for the address, it defaults to a tuple of ("localhost", 8765), the default on WinLIRC. The first part contains the address whereas the second is the port. Furthermore, the socket that is created uses ``AF_INET`` and ``SOCK_STREAM`` -instead now. +instead so we can connect over TCP. |