2020-11-26 12:13:36 +01:00
|
|
|
.. SPDX-License-Identifier: GPL-2.0 OR GFDL-1.1-no-invariants-or-later
|
2020-09-25 07:29:25 +02:00
|
|
|
.. c:namespace:: RC
|
2018-08-30 10:15:26 -04:00
|
|
|
|
2016-07-12 06:12:32 -03:00
|
|
|
.. _lirc-write:
|
2016-06-30 15:18:56 +02:00
|
|
|
|
2016-07-09 21:03:57 -03:00
|
|
|
************
|
|
|
|
LIRC write()
|
|
|
|
************
|
|
|
|
|
|
|
|
Name
|
|
|
|
====
|
|
|
|
|
|
|
|
lirc-write - Write to a LIRC device
|
|
|
|
|
|
|
|
Synopsis
|
|
|
|
========
|
|
|
|
|
|
|
|
.. code-block:: c
|
|
|
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
2016-08-19 12:00:43 -03:00
|
|
|
.. c:function:: ssize_t write( int fd, void *buf, size_t count )
|
2016-07-09 21:03:57 -03:00
|
|
|
|
|
|
|
Arguments
|
|
|
|
=========
|
|
|
|
|
|
|
|
``fd``
|
|
|
|
File descriptor returned by ``open()``.
|
|
|
|
|
|
|
|
``buf``
|
2016-08-19 16:59:31 -03:00
|
|
|
Buffer with data to be written
|
2016-07-09 21:03:57 -03:00
|
|
|
|
2016-08-19 16:59:31 -03:00
|
|
|
``count``
|
|
|
|
Number of bytes at the buffer
|
2016-07-09 21:03:57 -03:00
|
|
|
|
|
|
|
Description
|
|
|
|
===========
|
|
|
|
|
2020-09-25 07:29:25 +02:00
|
|
|
:c:func:`write()` writes up to ``count`` bytes to the device
|
2016-07-09 21:03:57 -03:00
|
|
|
referenced by the file descriptor ``fd`` from the buffer starting at
|
|
|
|
``buf``.
|
2016-06-30 15:18:56 +02:00
|
|
|
|
2017-02-25 06:51:34 -05:00
|
|
|
The exact format of the data depends on what mode a driver is in, use
|
|
|
|
:ref:`lirc_get_features` to get the supported modes and use
|
|
|
|
:ref:`lirc_set_send_mode` set the mode.
|
2017-02-08 15:10:30 -02:00
|
|
|
|
|
|
|
When in :ref:`LIRC_MODE_PULSE <lirc-mode-PULSE>` mode, the data written to
|
|
|
|
the chardev is a pulse/space sequence of integer values. Pulses and spaces
|
|
|
|
are only marked implicitly by their position. The data must start and end
|
|
|
|
with a pulse, therefore, the data must always include an uneven number of
|
2017-02-25 06:51:34 -05:00
|
|
|
samples. The write function blocks until the data has been transmitted
|
2017-02-08 15:10:30 -02:00
|
|
|
by the hardware. If more data is provided than the hardware can send, the
|
|
|
|
driver returns ``EINVAL``.
|
2016-07-09 21:03:57 -03:00
|
|
|
|
2017-02-25 06:51:34 -05:00
|
|
|
When in :ref:`LIRC_MODE_SCANCODE <lirc-mode-scancode>` mode, one
|
|
|
|
``struct lirc_scancode`` must be written to the chardev at a time, else
|
|
|
|
``EINVAL`` is returned. Set the desired scancode in the ``scancode`` member,
|
2019-07-25 16:32:31 -03:00
|
|
|
and the :ref:`IR protocol <Remote_controllers_Protocols>` in the
|
|
|
|
:c:type:`rc_proto`: member. All other members must be
|
2017-11-30 08:00:45 -05:00
|
|
|
set to 0, else ``EINVAL`` is returned. If there is no protocol encoder
|
2017-02-25 06:51:34 -05:00
|
|
|
for the protocol or the scancode is not valid for the specified protocol,
|
2017-12-11 17:12:09 -05:00
|
|
|
``EINVAL`` is returned. The write function blocks until the scancode
|
|
|
|
is transmitted by the hardware.
|
2017-02-25 06:51:34 -05:00
|
|
|
|
2016-07-09 21:03:57 -03:00
|
|
|
Return Value
|
|
|
|
============
|
|
|
|
|
2017-02-25 06:51:34 -05:00
|
|
|
On success, the number of bytes written is returned. It is not an error if
|
2016-07-09 21:03:57 -03:00
|
|
|
this number is smaller than the number of bytes requested, or the amount
|
|
|
|
of data required for one frame. On error, -1 is returned, and the ``errno``
|
|
|
|
variable is set appropriately. The generic error codes are described at the
|
|
|
|
:ref:`Generic Error Codes <gen-errors>` chapter.
|