lirc-write.rst 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. .. -*- coding: utf-8; mode: rst -*-
  2. .. _lirc-write:
  3. ************
  4. LIRC write()
  5. ************
  6. Name
  7. ====
  8. lirc-write - Write to a LIRC device
  9. Synopsis
  10. ========
  11. .. code-block:: c
  12. #include <unistd.h>
  13. .. c:function:: ssize_t write( int fd, void *buf, size_t count )
  14. :name: lirc-write
  15. Arguments
  16. =========
  17. ``fd``
  18. File descriptor returned by ``open()``.
  19. ``buf``
  20. Buffer with data to be written
  21. ``count``
  22. Number of bytes at the buffer
  23. Description
  24. ===========
  25. :ref:`write() <lirc-write>` writes up to ``count`` bytes to the device
  26. referenced by the file descriptor ``fd`` from the buffer starting at
  27. ``buf``.
  28. The data written to the chardev is a pulse/space sequence of integer
  29. values. Pulses and spaces are only marked implicitly by their position.
  30. The data must start and end with a pulse, therefore, the data must
  31. always include an uneven number of samples. The write function must
  32. block until the data has been transmitted by the hardware. If more data
  33. is provided than the hardware can send, the driver returns ``EINVAL``.
  34. Return Value
  35. ============
  36. On success, the number of bytes read is returned. It is not an error if
  37. this number is smaller than the number of bytes requested, or the amount
  38. of data required for one frame. On error, -1 is returned, and the ``errno``
  39. variable is set appropriately. The generic error codes are described at the
  40. :ref:`Generic Error Codes <gen-errors>` chapter.