18c2ecf20Sopenharmony_ci.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later 28c2ecf20Sopenharmony_ci.. c:namespace:: RC 38c2ecf20Sopenharmony_ci 48c2ecf20Sopenharmony_ci.. _lirc-read: 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ci*********** 78c2ecf20Sopenharmony_ciLIRC read() 88c2ecf20Sopenharmony_ci*********** 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ciName 118c2ecf20Sopenharmony_ci==== 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_cilirc-read - Read from a LIRC device 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ciSynopsis 168c2ecf20Sopenharmony_ci======== 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci.. code-block:: c 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci #include <unistd.h> 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ci.. c:function:: ssize_t read( int fd, void *buf, size_t count ) 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ciArguments 258c2ecf20Sopenharmony_ci========= 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_ci``fd`` 288c2ecf20Sopenharmony_ci File descriptor returned by ``open()``. 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_ci``buf`` 318c2ecf20Sopenharmony_ci Buffer to be filled 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_ci``count`` 348c2ecf20Sopenharmony_ci Max number of bytes to read 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ciDescription 378c2ecf20Sopenharmony_ci=========== 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ci:c:func:`read()` attempts to read up to ``count`` bytes from file 408c2ecf20Sopenharmony_cidescriptor ``fd`` into the buffer starting at ``buf``. If ``count`` is zero, 418c2ecf20Sopenharmony_ci:c:func:`read()` returns zero and has no other results. If ``count`` 428c2ecf20Sopenharmony_ciis greater than ``SSIZE_MAX``, the result is unspecified. 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ciThe exact format of the data depends on what :ref:`lirc_modes` a driver 458c2ecf20Sopenharmony_ciuses. Use :ref:`lirc_get_features` to get the supported mode, and use 468c2ecf20Sopenharmony_ci:ref:`lirc_set_rec_mode` set the current active mode. 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_ciThe mode :ref:`LIRC_MODE_MODE2 <lirc-mode-mode2>` is for raw IR, 498c2ecf20Sopenharmony_ciin which packets containing an unsigned int value describing an IR signal are 508c2ecf20Sopenharmony_ciread from the chardev. 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_ciAlternatively, :ref:`LIRC_MODE_SCANCODE <lirc-mode-scancode>` can be available, 538c2ecf20Sopenharmony_ciin this mode scancodes which are either decoded by software decoders, or 548c2ecf20Sopenharmony_ciby hardware decoders. The :c:type:`rc_proto` member is set to the 558c2ecf20Sopenharmony_ci:ref:`IR protocol <Remote_controllers_Protocols>` 568c2ecf20Sopenharmony_ciused for transmission, and ``scancode`` to the decoded scancode, 578c2ecf20Sopenharmony_ciand the ``keycode`` set to the keycode or ``KEY_RESERVED``. 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_ciReturn Value 608c2ecf20Sopenharmony_ci============ 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_ciOn success, the number of bytes read is returned. It is not an error if 638c2ecf20Sopenharmony_cithis number is smaller than the number of bytes requested, or the amount 648c2ecf20Sopenharmony_ciof data required for one frame. On error, -1 is returned, and the ``errno`` 658c2ecf20Sopenharmony_civariable is set appropriately. 66