Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 1 | .. -*- coding: utf-8; mode: rst -*- |
| 2 | |
Mauro Carvalho Chehab | 4ed030a | 2016-07-12 06:12:32 -0300 | [diff] [blame] | 3 | .. _lirc-read: |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 4 | |
Mauro Carvalho Chehab | 8a6ba5c | 2016-07-09 21:03:57 -0300 | [diff] [blame] | 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 | |
Mauro Carvalho Chehab | 1b81f01 | 2016-08-19 12:00:43 -0300 | [diff] [blame] | 23 | .. c:function:: ssize_t read( int fd, void *buf, size_t count ) |
Mauro Carvalho Chehab | e9de2d8 | 2016-09-08 08:14:10 -0300 | [diff] [blame] | 24 | :name: lirc-read |
Mauro Carvalho Chehab | 8a6ba5c | 2016-07-09 21:03:57 -0300 | [diff] [blame] | 25 | |
| 26 | |
| 27 | Arguments |
| 28 | ========= |
| 29 | |
| 30 | ``fd`` |
| 31 | File descriptor returned by ``open()``. |
| 32 | |
| 33 | ``buf`` |
Mauro Carvalho Chehab | 15c1901 | 2016-08-19 16:59:31 -0300 | [diff] [blame] | 34 | Buffer to be filled |
Mauro Carvalho Chehab | 8a6ba5c | 2016-07-09 21:03:57 -0300 | [diff] [blame] | 35 | |
Mauro Carvalho Chehab | 15c1901 | 2016-08-19 16:59:31 -0300 | [diff] [blame] | 36 | ``count`` |
| 37 | Max number of bytes to read |
Mauro Carvalho Chehab | 8a6ba5c | 2016-07-09 21:03:57 -0300 | [diff] [blame] | 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. |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 46 | |
Sean Young | a8b875a | 2017-02-08 15:10:30 -0200 | [diff] [blame^] | 47 | The exact format of the data depends on what :ref:`lirc_modes` a driver |
| 48 | uses. Use :ref:`lirc_get_features` to get the supported mode. |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 49 | |
Sean Young | a8b875a | 2017-02-08 15:10:30 -0200 | [diff] [blame^] | 50 | The generally preferred mode for receive is |
| 51 | :ref:`LIRC_MODE_MODE2 <lirc-mode-mode2>`, |
| 52 | in which packets containing an int value describing an IR signal are |
| 53 | read from the chardev. |
Mauro Carvalho Chehab | 8a6ba5c | 2016-07-09 21:03:57 -0300 | [diff] [blame] | 54 | |
| 55 | Return Value |
| 56 | ============ |
| 57 | |
| 58 | On success, the number of bytes read is returned. It is not an error if |
| 59 | this number is smaller than the number of bytes requested, or the amount |
| 60 | of data required for one frame. On error, -1 is returned, and the ``errno`` |
| 61 | variable is set appropriately. |