blob: ff14a69104e54f373a963eddacb259ffd4fc025d [file] [log] [blame]
Markus Heiser5377d912016-06-30 15:18:56 +02001.. -*- coding: utf-8; mode: rst -*-
2
Mauro Carvalho Chehab4ed030a2016-07-12 06:12:32 -03003.. _lirc-read:
Markus Heiser5377d912016-06-30 15:18:56 +02004
Mauro Carvalho Chehab8a6ba5c2016-07-09 21:03:57 -03005***********
6LIRC read()
7***********
8
9Name
10====
11
12lirc-read - Read from a LIRC device
13
14
15Synopsis
16========
17
18.. code-block:: c
19
20 #include <unistd.h>
21
22
Mauro Carvalho Chehab1b81f012016-08-19 12:00:43 -030023.. c:function:: ssize_t read( int fd, void *buf, size_t count )
Mauro Carvalho Chehabe9de2d82016-09-08 08:14:10 -030024 :name: lirc-read
Mauro Carvalho Chehab8a6ba5c2016-07-09 21:03:57 -030025
26
27Arguments
28=========
29
30``fd``
31 File descriptor returned by ``open()``.
32
33``buf``
Mauro Carvalho Chehab15c19012016-08-19 16:59:31 -030034 Buffer to be filled
Mauro Carvalho Chehab8a6ba5c2016-07-09 21:03:57 -030035
Mauro Carvalho Chehab15c19012016-08-19 16:59:31 -030036``count``
37 Max number of bytes to read
Mauro Carvalho Chehab8a6ba5c2016-07-09 21:03:57 -030038
39Description
40===========
41
42:ref:`read() <lirc-read>` attempts to read up to ``count`` bytes from file
43descriptor ``fd`` into the buffer starting at ``buf``. If ``count`` is zero,
44:ref:`read() <lirc-read>` returns zero and has no other results. If ``count``
45is greater than ``SSIZE_MAX``, the result is unspecified.
Markus Heiser5377d912016-06-30 15:18:56 +020046
Sean Younga8b875a2017-02-08 15:10:30 -020047The exact format of the data depends on what :ref:`lirc_modes` a driver
48uses. Use :ref:`lirc_get_features` to get the supported mode.
Markus Heiser5377d912016-06-30 15:18:56 +020049
Sean Younga8b875a2017-02-08 15:10:30 -020050The generally preferred mode for receive is
51:ref:`LIRC_MODE_MODE2 <lirc-mode-mode2>`,
52in which packets containing an int value describing an IR signal are
53read from the chardev.
Mauro Carvalho Chehab8a6ba5c2016-07-09 21:03:57 -030054
55Return Value
56============
57
58On success, the number of bytes read is returned. It is not an error if
59this number is smaller than the number of bytes requested, or the amount
60of data required for one frame. On error, -1 is returned, and the ``errno``
61variable is set appropriately.