Commit | Line | Data |
---|---|---|
5377d91f MH |
1 | .. -*- coding: utf-8; mode: rst -*- |
2 | ||
4ed030af | 3 | .. _lirc-read: |
5377d91f | 4 | |
8a6ba5c0 MCC |
5 | *********** |
6 | LIRC read() | |
7 | *********** | |
8 | ||
9 | Name | |
10 | ==== | |
11 | ||
12 | lirc-read - Read from a LIRC device | |
13 | ||
14 | ||
15 | Synopsis | |
16 | ======== | |
17 | ||
18 | .. code-block:: c | |
19 | ||
20 | #include <unistd.h> | |
21 | ||
22 | ||
1b81f010 | 23 | .. c:function:: ssize_t read( int fd, void *buf, size_t count ) |
e9de2d89 | 24 | :name: lirc-read |
8a6ba5c0 MCC |
25 | |
26 | ||
27 | Arguments | |
28 | ========= | |
29 | ||
30 | ``fd`` | |
31 | File descriptor returned by ``open()``. | |
32 | ||
33 | ``buf`` | |
15c19014 | 34 | Buffer to be filled |
8a6ba5c0 | 35 | |
15c19014 MCC |
36 | ``count`` |
37 | Max number of bytes to read | |
8a6ba5c0 MCC |
38 | |
39 | Description | |
40 | =========== | |
41 | ||
42 | :ref:`read() <lirc-read>` attempts to read up to ``count`` bytes from file | |
43 | descriptor ``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`` | |
45 | is greater than ``SSIZE_MAX``, the result is unspecified. | |
5377d91f MH |
46 | |
47 | The lircd userspace daemon reads raw IR data from the LIRC chardev. The | |
48 | exact format of the data depends on what modes a driver supports, and | |
49 | what mode has been selected. lircd obtains supported modes and sets the | |
bd6a63f2 MCC |
50 | active mode via the ioctl interface, detailed at :ref:`lirc_func`. |
51 | The generally preferred mode for receive is | |
52 | :ref:`LIRC_MODE_MODE2 <lirc-mode-mode2>`, in which packets containing an | |
53 | int value describing an IR signal are read from the chardev. | |
5377d91f MH |
54 | |
55 | See also | |
56 | `http://www.lirc.org/html/technical.html <http://www.lirc.org/html/technical.html>`__ | |
57 | for more info. | |
8a6ba5c0 MCC |
58 | |
59 | Return Value | |
60 | ============ | |
61 | ||
62 | On success, the number of bytes read is returned. It is not an error if | |
63 | this number is smaller than the number of bytes requested, or the amount | |
64 | of data required for one frame. On error, -1 is returned, and the ``errno`` | |
65 | variable is set appropriately. |