Something went wrong. Try again.
(I'm so sorry!) Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
Something went wrong. Try again.
2.3 kB · 72 lines
at master
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273.. SPDX-License-Identifier: GPL-2.0 OR GFDL-1.1-no-invariants-or-later.. c:namespace:: RC
.. _lirc-write:
************LIRC write()************
Name====
lirc-write - Write to a LIRC device
Synopsis========
.. code-block:: c
#include <unistd.h>
.. c:function:: ssize_t write( int fd, void *buf, size_t count )
Arguments=========
``fd`` File descriptor returned by ``open()``.
``buf`` Buffer with data to be written
``count`` Number of bytes at the buffer
Description===========
:c:func:`write()` writes up to ``count`` bytes to the devicereferenced by the file descriptor ``fd`` from the buffer starting at``buf``.
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.
When in :ref:`LIRC_MODE_PULSE <lirc-mode-PULSE>` mode, the data written tothe chardev is a pulse/space sequence of integer values. Pulses and spacesare only marked implicitly by their position. The data must start and endwith a pulse, therefore, the data must always include an uneven number ofsamples. The write function blocks until the data has been transmittedby the hardware. If more data is provided than the hardware can send, thedriver returns ``EINVAL``.
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,and the :ref:`IR protocol <Remote_controllers_Protocols>` in the:c:type:`rc_proto`: member. All other members must beset to 0, else ``EINVAL`` is returned. If there is no protocol encoderfor the protocol or the scancode is not valid for the specified protocol,``EINVAL`` is returned. The write function blocks until the scancodeis transmitted by the hardware.
Return Value============
On success, the number of bytes written is returned. It is not an error ifthis number is smaller than the number of bytes requested, or the amountof 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.