lirc-read.rst 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. .. SPDX-License-Identifier: GPL-2.0 OR GFDL-1.1-no-invariants-or-later
  2. .. c:namespace:: RC
  3. .. _lirc-read:
  4. ***********
  5. LIRC read()
  6. ***********
  7. Name
  8. ====
  9. lirc-read - Read from a LIRC device
  10. Synopsis
  11. ========
  12. .. code-block:: c
  13. #include <unistd.h>
  14. .. c:function:: ssize_t read( int fd, void *buf, size_t count )
  15. Arguments
  16. =========
  17. ``fd``
  18. File descriptor returned by ``open()``.
  19. ``buf``
  20. Buffer to be filled
  21. ``count``
  22. Max number of bytes to read
  23. Description
  24. ===========
  25. :c:func:`read()` attempts to read up to ``count`` bytes from file
  26. descriptor ``fd`` into the buffer starting at ``buf``. If ``count`` is zero,
  27. :c:func:`read()` returns zero and has no other results. If ``count``
  28. is greater than ``SSIZE_MAX``, the result is unspecified.
  29. The exact format of the data depends on what :ref:`lirc_modes` a driver
  30. uses. Use :ref:`lirc_get_features` to get the supported mode, and use
  31. :ref:`lirc_set_rec_mode` set the current active mode.
  32. The mode :ref:`LIRC_MODE_MODE2 <lirc-mode-mode2>` is for raw IR,
  33. in which packets containing an unsigned int value describing an IR signal are
  34. read from the chardev.
  35. Alternatively, :ref:`LIRC_MODE_SCANCODE <lirc-mode-scancode>` can be available,
  36. in this mode scancodes which are either decoded by software decoders, or
  37. by hardware decoders. The :c:type:`rc_proto` member is set to the
  38. :ref:`IR protocol <Remote_controllers_Protocols>`
  39. used for transmission, and ``scancode`` to the decoded scancode,
  40. and the ``keycode`` set to the keycode or ``KEY_RESERVED``.
  41. Return Value
  42. ============
  43. On success, the number of bytes read is returned. It is not an error if
  44. this number is smaller than the number of bytes requested, or the amount
  45. of data required for one frame. On error, -1 is returned, and the ``errno``
  46. variable is set appropriately.