162306a36Sopenharmony_ci.. SPDX-License-Identifier: GPL-2.0 OR GFDL-1.1-no-invariants-or-later 262306a36Sopenharmony_ci.. c:namespace:: RC 362306a36Sopenharmony_ci 462306a36Sopenharmony_ci.. _lirc-read: 562306a36Sopenharmony_ci 662306a36Sopenharmony_ci*********** 762306a36Sopenharmony_ciLIRC read() 862306a36Sopenharmony_ci*********** 962306a36Sopenharmony_ci 1062306a36Sopenharmony_ciName 1162306a36Sopenharmony_ci==== 1262306a36Sopenharmony_ci 1362306a36Sopenharmony_cilirc-read - Read from a LIRC device 1462306a36Sopenharmony_ci 1562306a36Sopenharmony_ciSynopsis 1662306a36Sopenharmony_ci======== 1762306a36Sopenharmony_ci 1862306a36Sopenharmony_ci.. code-block:: c 1962306a36Sopenharmony_ci 2062306a36Sopenharmony_ci #include <unistd.h> 2162306a36Sopenharmony_ci 2262306a36Sopenharmony_ci.. c:function:: ssize_t read( int fd, void *buf, size_t count ) 2362306a36Sopenharmony_ci 2462306a36Sopenharmony_ciArguments 2562306a36Sopenharmony_ci========= 2662306a36Sopenharmony_ci 2762306a36Sopenharmony_ci``fd`` 2862306a36Sopenharmony_ci File descriptor returned by ``open()``. 2962306a36Sopenharmony_ci 3062306a36Sopenharmony_ci``buf`` 3162306a36Sopenharmony_ci Buffer to be filled 3262306a36Sopenharmony_ci 3362306a36Sopenharmony_ci``count`` 3462306a36Sopenharmony_ci Max number of bytes to read 3562306a36Sopenharmony_ci 3662306a36Sopenharmony_ciDescription 3762306a36Sopenharmony_ci=========== 3862306a36Sopenharmony_ci 3962306a36Sopenharmony_ci:c:func:`read()` attempts to read up to ``count`` bytes from file 4062306a36Sopenharmony_cidescriptor ``fd`` into the buffer starting at ``buf``. If ``count`` is zero, 4162306a36Sopenharmony_ci:c:func:`read()` returns zero and has no other results. If ``count`` 4262306a36Sopenharmony_ciis greater than ``SSIZE_MAX``, the result is unspecified. 4362306a36Sopenharmony_ci 4462306a36Sopenharmony_ciThe exact format of the data depends on what :ref:`lirc_modes` a driver 4562306a36Sopenharmony_ciuses. Use :ref:`lirc_get_features` to get the supported mode, and use 4662306a36Sopenharmony_ci:ref:`lirc_set_rec_mode` set the current active mode. 4762306a36Sopenharmony_ci 4862306a36Sopenharmony_ciThe mode :ref:`LIRC_MODE_MODE2 <lirc-mode-mode2>` is for raw IR, 4962306a36Sopenharmony_ciin which packets containing an unsigned int value describing an IR signal are 5062306a36Sopenharmony_ciread from the chardev. 5162306a36Sopenharmony_ci 5262306a36Sopenharmony_ciAlternatively, :ref:`LIRC_MODE_SCANCODE <lirc-mode-scancode>` can be available, 5362306a36Sopenharmony_ciin this mode scancodes which are either decoded by software decoders, or 5462306a36Sopenharmony_ciby hardware decoders. The :c:type:`rc_proto` member is set to the 5562306a36Sopenharmony_ci:ref:`IR protocol <Remote_controllers_Protocols>` 5662306a36Sopenharmony_ciused for transmission, and ``scancode`` to the decoded scancode, 5762306a36Sopenharmony_ciand the ``keycode`` set to the keycode or ``KEY_RESERVED``. 5862306a36Sopenharmony_ci 5962306a36Sopenharmony_ciReturn Value 6062306a36Sopenharmony_ci============ 6162306a36Sopenharmony_ci 6262306a36Sopenharmony_ciOn success, the number of bytes read is returned. It is not an error if 6362306a36Sopenharmony_cithis number is smaller than the number of bytes requested, or the amount 6462306a36Sopenharmony_ciof data required for one frame. On error, -1 is returned, and the ``errno`` 6562306a36Sopenharmony_civariable is set appropriately. 66