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