1059b1c5bSMauro Carvalho Chehab.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later 2*5f536f4aSMauro Carvalho Chehab.. c:namespace:: RC 354f38fcaSMauro Carvalho Chehab 454f38fcaSMauro Carvalho Chehab.. _lirc-read: 554f38fcaSMauro Carvalho Chehab 654f38fcaSMauro Carvalho Chehab*********** 754f38fcaSMauro Carvalho ChehabLIRC read() 854f38fcaSMauro Carvalho Chehab*********** 954f38fcaSMauro Carvalho Chehab 1054f38fcaSMauro Carvalho ChehabName 1154f38fcaSMauro Carvalho Chehab==== 1254f38fcaSMauro Carvalho Chehab 1354f38fcaSMauro Carvalho Chehablirc-read - Read from a LIRC device 1454f38fcaSMauro Carvalho Chehab 1554f38fcaSMauro Carvalho ChehabSynopsis 1654f38fcaSMauro Carvalho Chehab======== 1754f38fcaSMauro Carvalho Chehab 1854f38fcaSMauro Carvalho Chehab.. code-block:: c 1954f38fcaSMauro Carvalho Chehab 2054f38fcaSMauro Carvalho Chehab #include <unistd.h> 2154f38fcaSMauro Carvalho Chehab 2254f38fcaSMauro Carvalho Chehab.. c:function:: ssize_t read( int fd, void *buf, size_t count ) 2354f38fcaSMauro Carvalho Chehab 2454f38fcaSMauro Carvalho ChehabArguments 2554f38fcaSMauro Carvalho Chehab========= 2654f38fcaSMauro Carvalho Chehab 2754f38fcaSMauro Carvalho Chehab``fd`` 2854f38fcaSMauro Carvalho Chehab File descriptor returned by ``open()``. 2954f38fcaSMauro Carvalho Chehab 3054f38fcaSMauro Carvalho Chehab``buf`` 3154f38fcaSMauro Carvalho Chehab Buffer to be filled 3254f38fcaSMauro Carvalho Chehab 3354f38fcaSMauro Carvalho Chehab``count`` 3454f38fcaSMauro Carvalho Chehab Max number of bytes to read 3554f38fcaSMauro Carvalho Chehab 3654f38fcaSMauro Carvalho ChehabDescription 3754f38fcaSMauro Carvalho Chehab=========== 3854f38fcaSMauro Carvalho Chehab 39*5f536f4aSMauro Carvalho Chehab:c:func:`read()` attempts to read up to ``count`` bytes from file 4054f38fcaSMauro Carvalho Chehabdescriptor ``fd`` into the buffer starting at ``buf``. If ``count`` is zero, 41*5f536f4aSMauro Carvalho Chehab:c:func:`read()` returns zero and has no other results. If ``count`` 4254f38fcaSMauro Carvalho Chehabis greater than ``SSIZE_MAX``, the result is unspecified. 4354f38fcaSMauro Carvalho Chehab 4454f38fcaSMauro Carvalho ChehabThe exact format of the data depends on what :ref:`lirc_modes` a driver 4554f38fcaSMauro Carvalho Chehabuses. Use :ref:`lirc_get_features` to get the supported mode, and use 4654f38fcaSMauro Carvalho Chehab:ref:`lirc_set_rec_mode` set the current active mode. 4754f38fcaSMauro Carvalho Chehab 4854f38fcaSMauro Carvalho ChehabThe mode :ref:`LIRC_MODE_MODE2 <lirc-mode-mode2>` is for raw IR, 4954f38fcaSMauro Carvalho Chehabin which packets containing an unsigned int value describing an IR signal are 5054f38fcaSMauro Carvalho Chehabread from the chardev. 5154f38fcaSMauro Carvalho Chehab 5254f38fcaSMauro Carvalho ChehabAlternatively, :ref:`LIRC_MODE_SCANCODE <lirc-mode-scancode>` can be available, 5354f38fcaSMauro Carvalho Chehabin this mode scancodes which are either decoded by software decoders, or 5454f38fcaSMauro Carvalho Chehabby hardware decoders. The :c:type:`rc_proto` member is set to the 5554f38fcaSMauro Carvalho Chehab:ref:`IR protocol <Remote_controllers_Protocols>` 5654f38fcaSMauro Carvalho Chehabused for transmission, and ``scancode`` to the decoded scancode, 5754f38fcaSMauro Carvalho Chehaband the ``keycode`` set to the keycode or ``KEY_RESERVED``. 5854f38fcaSMauro Carvalho Chehab 5954f38fcaSMauro Carvalho ChehabReturn Value 6054f38fcaSMauro Carvalho Chehab============ 6154f38fcaSMauro Carvalho Chehab 6254f38fcaSMauro Carvalho ChehabOn success, the number of bytes read is returned. It is not an error if 6354f38fcaSMauro Carvalho Chehabthis number is smaller than the number of bytes requested, or the amount 6454f38fcaSMauro Carvalho Chehabof data required for one frame. On error, -1 is returned, and the ``errno`` 6554f38fcaSMauro Carvalho Chehabvariable is set appropriately. 66