Pārlūkot izejas kodu

Rewrite documentation with Material for mkdocs

- remove doc build from autotools
- don't depend anymore on asciidoc
- don't provide man pages anymore
- new illustrations
- provide mkdocs instructions
Stéphane Raimbault 2 gadi atpakaļ
vecāks
revīzija
da87669697
100 mainītis faili ar 2719 papildinājumiem un 2809 dzēšanām
  1. 7 13
      .gitignore
  2. 2 2
      CONTRIBUTING.md
  3. 1 1
      ISSUE_TEMPLATE.md
  4. 1 1
      Makefile.am
  5. 16 28
      README.md
  6. 0 29
      acinclude.m4
  7. 0 5
      configure.ac
  8. 0 88
      doc/Makefile.am
  9. 0 51
      doc/asciidoc.conf
  10. 0 279
      doc/libmodbus.txt
  11. 0 33
      doc/modbus_free.txt
  12. 0 35
      doc/modbus_get_byte_from_bits.txt
  13. 0 50
      doc/modbus_get_byte_timeout.txt
  14. 0 39
      doc/modbus_get_float.txt
  15. 0 39
      doc/modbus_get_float_abcd.txt
  16. 0 39
      doc/modbus_get_float_badc.txt
  17. 0 39
      doc/modbus_get_float_cdab.txt
  18. 0 39
      doc/modbus_get_float_dcba.txt
  19. 0 35
      doc/modbus_get_header_length.txt
  20. 0 53
      doc/modbus_get_indication_timeout.txt
  21. 0 52
      doc/modbus_get_response_timeout.txt
  22. 0 41
      doc/modbus_get_slave.txt
  23. 0 35
      doc/modbus_get_socket.txt
  24. 0 34
      doc/modbus_mapping_free.txt
  25. 0 69
      doc/modbus_mapping_new.txt
  26. 0 81
      doc/modbus_mapping_new_start_address.txt
  27. 0 41
      doc/modbus_mask_write_register.txt
  28. 0 91
      doc/modbus_new_rtu.txt
  29. 0 77
      doc/modbus_new_tcp_pi.txt
  30. 0 48
      doc/modbus_read_bits.txt
  31. 0 47
      doc/modbus_read_input_bits.txt
  32. 0 51
      doc/modbus_read_input_registers.txt
  33. 0 42
      doc/modbus_receive.txt
  34. 0 52
      doc/modbus_reply.txt
  35. 0 57
      doc/modbus_reply_exception.txt
  36. 0 61
      doc/modbus_report_slave_id.txt
  37. 0 47
      doc/modbus_rtu_get_rts.txt
  38. 0 46
      doc/modbus_rtu_get_rts_delay.txt
  39. 0 53
      doc/modbus_rtu_get_serial_mode.txt
  40. 0 45
      doc/modbus_rtu_set_custom_rts.txt
  41. 0 46
      doc/modbus_rtu_set_rts_delay.txt
  42. 0 56
      doc/modbus_rtu_set_serial_mode.txt
  43. 0 36
      doc/modbus_set_bits_from_byte.txt
  44. 0 36
      doc/modbus_set_bits_from_bytes.txt
  45. 0 36
      doc/modbus_set_float.txt
  46. 0 38
      doc/modbus_set_float_abcd.txt
  47. 0 38
      doc/modbus_set_float_badc.txt
  48. 0 39
      doc/modbus_set_float_cdab.txt
  49. 0 37
      doc/modbus_set_float_dcba.txt
  50. 0 48
      doc/modbus_set_indication_timeout.txt
  51. 0 51
      doc/modbus_write_and_read_registers.txt
  52. 0 38
      doc/modbus_write_bit.txt
  53. 0 45
      doc/modbus_write_bits.txt
  54. 0 38
      doc/modbus_write_register.txt
  55. 0 38
      doc/modbus_write_registers.txt
  56. 606 0
      docs/assets/client-sensors.excalidraw
  57. BIN
      docs/assets/client-sensors.webp
  58. 483 0
      docs/assets/server-grafana.excalidraw
  59. BIN
      docs/assets/server-grafana.webp
  60. 263 0
      docs/index.md
  61. 13 24
      docs/modbus_close.md
  62. 13 25
      docs/modbus_connect.md
  63. 8 17
      docs/modbus_flush.md
  64. 19 0
      docs/modbus_free.md
  65. 26 0
      docs/modbus_get_byte_from_bits.md
  66. 38 0
      docs/modbus_get_byte_timeout.md
  67. 31 0
      docs/modbus_get_float.md
  68. 29 0
      docs/modbus_get_float_abcd.md
  69. 29 0
      docs/modbus_get_float_badc.md
  70. 29 0
      docs/modbus_get_float_cdab.md
  71. 29 0
      docs/modbus_get_float_dcba.md
  72. 21 0
      docs/modbus_get_header_length.md
  73. 39 0
      docs/modbus_get_indication_timeout.md
  74. 40 0
      docs/modbus_get_response_timeout.md
  75. 29 0
      docs/modbus_get_slave.md
  76. 25 0
      docs/modbus_get_socket.md
  77. 24 0
      docs/modbus_mapping_free.md
  78. 60 0
      docs/modbus_mapping_new.md
  79. 85 0
      docs/modbus_mapping_new_start_address.md
  80. 30 0
      docs/modbus_mask_write_register.md
  81. 77 0
      docs/modbus_new_rtu.md
  82. 20 35
      docs/modbus_new_tcp.md
  83. 62 0
      docs/modbus_new_tcp_pi.md
  84. 36 0
      docs/modbus_read_bits.md
  85. 35 0
      docs/modbus_read_input_bits.md
  86. 39 0
      docs/modbus_read_input_registers.md
  87. 21 35
      docs/modbus_read_registers.md
  88. 32 0
      docs/modbus_receive.md
  89. 20 30
      docs/modbus_receive_confirmation.md
  90. 39 0
      docs/modbus_reply.md
  91. 45 0
      docs/modbus_reply_exception.md
  92. 52 0
      docs/modbus_report_slave_id.md
  93. 35 0
      docs/modbus_rtu_get_rts.md
  94. 31 0
      docs/modbus_rtu_get_rts_delay.md
  95. 41 0
      docs/modbus_rtu_get_serial_mode.md
  96. 32 0
      docs/modbus_rtu_set_custom_rts.md
  97. 17 29
      docs/modbus_rtu_set_rts.md
  98. 31 0
      docs/modbus_rtu_set_rts_delay.md
  99. 43 0
      docs/modbus_rtu_set_serial_mode.md
  100. 15 26
      docs/modbus_send_raw_request.md

+ 7 - 13
.gitignore

@@ -10,11 +10,10 @@
 .libs
 .DS_Store
 
-# Emacs
-GPATH
-GRTAGS
-GSYMS
-GTAGS
+# Editors
+/*.sublime-*
+/.vscode
+/.venv
 
 # Generated by Autotools
 INSTALL
@@ -28,17 +27,17 @@ Makefile.in
 /configure.scan
 /depcomp
 /install-sh
+/libmodbus.pc
 /libtool
 /ltmain.sh
 /missing
-/libmodbus.pc
 /stamp-h1
 src/modbus-version.h
 src/win32/modbus.dll.manifest
 tests/unit-test.h
 
-/*.sublime-*
-/.vscode
+# mkdocs
+/site
 
 # Binary
 tests/bandwidth-client
@@ -50,8 +49,3 @@ tests/unit-test-client
 tests/unit-test-server
 tests/version
 tests/stamp-h2
-
-# Documentation
-doc/*.html
-doc/*.3
-doc/*.7

+ 2 - 2
CONTRIBUTING.md

@@ -4,7 +4,7 @@ How Do I Submit A Good Bug Report?
 Please, don't send direct emails to Stéphane Raimbault unless you want
 commercial support.
 
-Take care to read the documentation at http://libmodbus.org/documentation/.
+Take care to read the documentation at http://libmodbus.org/.
 
 - *Be sure it's a bug before creating an issue*, in doubt, post a message on
   https://groups.google.com/forum/#!forum/libmodbus or send an email to
@@ -24,6 +24,6 @@ the clients are connected (TCP, RTU, ASCII) and the source code you are using.
 
 - *Enable the debug mode*, libmodbus provides a function to display the content
 of the Modbus messages and it's very convenient to analyze issues
-(http://libmodbus.org/docs/latest/modbus_set_debug.html).
+(http://libmodbus.org/docs/modbus_set_debug/).
 
 Good bug reports provide right and quick fixes!

+ 1 - 1
ISSUE_TEMPLATE.md

@@ -34,7 +34,7 @@ When you get here and you are still convinced that you want to report a bug:
 
 - *Enable the debug mode*, libmodbus provides a function to display the content
    of the Modbus messages and it's very convenient to analyze issues
-   (<http://libmodbus.org/docs/latest/modbus_set_debug.html>).
+   (<http://libmodbus.org/docs/modbus_set_debug/>).
 
 Good bug reports provide right and quick fixes!
 

+ 1 - 1
Makefile.am

@@ -9,7 +9,7 @@ CLEANFILES += libmodbus.pc
 
 dist_doc_DATA = MIGRATION README.md AUTHORS NEWS
 
-SUBDIRS = src doc
+SUBDIRS = src
 
 if BUILD_TESTS
 SUBDIRS += tests

+ 16 - 28
README.md

@@ -1,10 +1,8 @@
-A groovy modbus library
-=======================
+# A groovy modbus library
 
 ![Build Status](https://github.com/stephane/libmodbus/actions/workflows/build.yml/badge.svg)
 
-Overview
---------
+## Overview
 
 libmodbus is a free software library to send/receive data with a device which
 respects the Modbus protocol. This library can use a serial port or an Ethernet
@@ -15,21 +13,15 @@ Protocol Reference Guide which can be obtained from [www.modbus.org](http://www.
 
 The license of libmodbus is *LGPL v2.1 or later*.
 
-The documentation is available as manual pages (`man libmodbus` to read general
-description and list of available functions) or Web pages
-[www.libmodbus.org/documentation/](http://libmodbus.org/documentation/). The
-documentation is licensed under the Creative Commons Attribution-ShareAlike
-License 3.0 (Unported) (<http://creativecommons.org/licenses/by-sa/3.0/>).
-
-The official website is [www.libmodbus.org](http://www.libmodbus.org).
+The official website is [www.libmodbus.org](http://www.libmodbus.org). The
+website contains the latest version of the documentation.
 
 The library is written in C and designed to run on Linux, Mac OS X, FreeBSD, Embox,
 QNX and Windows.
 
 You can use the library on MCUs with Embox RTOS.
 
-Installation
-------------
+## Installation
 
 You will only need to install automake, autoconf, libtool and a C compiler (gcc
 or clang) to compile the library and asciidoc and xmlto to generate the
@@ -59,19 +51,7 @@ automake libtool`.
 
 To build under Embox, you have to use its build system.
 
-Documentation
--------------
-
-The documentation is available [online](http://libmodbus.org/documentation) or
-as manual pages after installation.
-
-The documentation is based on
-[AsciiDoc](http://www.methods.co.nz/asciidoc/).  Only man pages are built
-by default with `make` command, you can run `make htmldoc` in *doc* directory
-to generate HTML files.
-
-Testing
--------
+## Testing
 
 Some tests are provided in *tests* directory, you can freely edit the source
 code to fit your needs (it's Free Software :).
@@ -87,7 +67,15 @@ By default, all TCP unit tests will be executed (see --help for options).
 
 It's also possible to run the unit tests with `make check`.
 
-To report a bug or to contribute
---------------------------------
+## To report a bug or to contribute
 
 See [CONTRIBUTING](CONTRIBUTING.md) document.
+
+## Documentation
+
+You can serve the local documentation with:
+
+```shell
+pip install mkdocs-material
+mkdocs serve
+```

+ 0 - 29
acinclude.m4

@@ -1,29 +0,0 @@
-dnl ##############################################################################
-dnl # AC_LIBMODBUS_CHECK_BUILD_DOC                                               #
-dnl # Check whether to build documentation and install man-pages                 #
-dnl ##############################################################################
-AC_DEFUN([AC_LIBMODBUS_CHECK_BUILD_DOC], [{
-    # Allow user to disable doc build
-    AC_ARG_WITH([documentation], [AS_HELP_STRING([--without-documentation],
-        [disable documentation build even if asciidoc and xmlto are present [default=no]])])
-
-    if test "x$with_documentation" = "xno"; then
-        ac_libmodbus_build_doc="no"
-    else
-        # Determine whether or not documentation should be built and installed.
-        ac_libmodbus_build_doc="yes"
-        # Check for asciidoc and xmlto and don't build the docs if these are not installed.
-        AC_CHECK_PROG(ac_libmodbus_have_asciidoc, asciidoc, yes, no)
-        AC_CHECK_PROG(ac_libmodbus_have_xmlto, xmlto, yes, no)
-        if test "x$ac_libmodbus_have_asciidoc" = "xno" -o "x$ac_libmodbus_have_xmlto" = "xno"; then
-           ac_libmodbus_build_doc="no"
-        fi
-    fi
-
-    AC_MSG_CHECKING([whether to build documentation])
-    AC_MSG_RESULT([$ac_libmodbus_build_doc])
-    if test "x$ac_libmodbus_build_doc" = "xno"; then
-        AC_MSG_WARN([The tools to build the documentation aren't installed])
-    fi
-    AM_CONDITIONAL(BUILD_DOC, test "x$ac_libmodbus_build_doc" = "xyes")
-}])

+ 0 - 5
configure.ac

@@ -94,9 +94,6 @@ AC_CHECK_HEADERS([ \
     unistd.h \
 ])
 
-# Check whether to build docs / install man pages
-AC_LIBMODBUS_CHECK_BUILD_DOC
-
 # Cygwin defines IPTOS_LOWDELAY but can't handle that flag so it's necessary to
 # workaround that problem and Cygwin doesn't define MSG_DONTWAIT.
 AC_CHECK_DECLS([__CYGWIN__])
@@ -161,7 +158,6 @@ AC_CONFIG_FILES([
         src/modbus-version.h
         src/win32/modbus.dll.manifest
         tests/Makefile
-        doc/Makefile
         libmodbus.pc
 ])
 
@@ -179,6 +175,5 @@ AC_MSG_RESULT([
         cflags:                 ${CFLAGS}
         ldflags:                ${LDFLAGS}
 
-        documentation:          ${ac_libmodbus_build_doc}
         tests:                  ${enable_tests}
 ])

+ 0 - 88
doc/Makefile.am

@@ -1,88 +0,0 @@
-TXT3 = \
-        modbus_close.txt \
-        modbus_connect.txt \
-        modbus_flush.txt \
-        modbus_free.txt \
-        modbus_get_indication_timeout.txt \
-        modbus_get_slave.txt \
-        modbus_get_byte_from_bits.txt \
-        modbus_get_byte_timeout.txt \
-        modbus_get_float.txt \
-        modbus_get_float_abcd.txt \
-        modbus_get_float_badc.txt \
-        modbus_get_float_cdab.txt \
-        modbus_get_float_dcba.txt \
-        modbus_get_header_length.txt \
-        modbus_get_response_timeout.txt \
-        modbus_get_socket.txt \
-        modbus_mapping_free.txt \
-        modbus_mapping_new.txt \
-        modbus_mapping_new_start_address.txt \
-        modbus_mask_write_register.txt \
-        modbus_new_rtu.txt \
-        modbus_new_tcp_pi.txt \
-        modbus_new_tcp.txt \
-        modbus_read_bits.txt \
-        modbus_read_input_bits.txt \
-        modbus_read_input_registers.txt \
-        modbus_read_registers.txt \
-        modbus_receive_confirmation.txt \
-        modbus_receive.txt \
-        modbus_reply_exception.txt \
-        modbus_reply.txt \
-        modbus_report_slave_id.txt \
-        modbus_rtu_get_serial_mode.txt \
-        modbus_rtu_set_serial_mode.txt \
-        modbus_rtu_get_rts.txt \
-        modbus_rtu_set_rts.txt \
-        modbus_rtu_set_custom_rts.txt \
-        modbus_rtu_get_rts_delay.txt \
-        modbus_rtu_set_rts_delay.txt \
-        modbus_send_raw_request.txt \
-        modbus_set_bits_from_bytes.txt \
-        modbus_set_bits_from_byte.txt \
-        modbus_set_byte_timeout.txt \
-        modbus_set_debug.txt \
-        modbus_set_error_recovery.txt \
-        modbus_set_float.txt \
-        modbus_set_float_abcd.txt \
-        modbus_set_float_badc.txt \
-        modbus_set_float_cdab.txt \
-        modbus_set_float_dcba.txt \
-        modbus_set_indication_timeout.txt \
-        modbus_set_response_timeout.txt \
-        modbus_set_slave.txt \
-        modbus_set_socket.txt \
-        modbus_strerror.txt \
-        modbus_tcp_accept.txt \
-        modbus_tcp_pi_accept.txt \
-        modbus_tcp_listen.txt \
-        modbus_tcp_pi_listen.txt \
-        modbus_write_and_read_registers.txt \
-        modbus_write_bits.txt \
-        modbus_write_bit.txt \
-        modbus_write_registers.txt \
-        modbus_write_register.txt
-TXT7 = libmodbus.txt
-
-EXTRA_DIST = asciidoc.conf $(TXT3) $(TXT7)
-
-MAN3 = $(TXT3:%.txt=%.3)
-MAN7 = $(TXT7:%.txt=%.7)
-
-if BUILD_DOC
-man3_MANS = $(MAN3)
-man7_MANS = $(MAN7)
-endif
-
-HTML = $(TXT3:%.txt=%.html) $(TXT7:%.txt=%.html)
-
-htmldoc: $(HTML)
-
-.txt.html:
-	asciidoc -d manpage -b xhtml11 -f asciidoc.conf -alibmodbus_version=@LIBMODBUS_VERSION@ $<
-
-.txt.3 .txt.7:
-	a2x --doctype manpage --format manpage -alibmodbus_version=@LIBMODBUS_VERSION@ $<
-
-CLEANFILES = *.3 *.7 *.html

+ 0 - 51
doc/asciidoc.conf

@@ -1,51 +0,0 @@
-[paradef-default]
-literal-style=template="literalparagraph"
-
-[macros]
-(?su)[\\]?(?P<name>linkmb):(?P<target>\S*?)\[(?P<attrlist>.*?)\]=
-
-ifdef::backend-docbook[]
-[linkmb-inlinemacro]
-{0%{target}}
-{0#<citerefentry>}
-{0#<refentrytitle>{target}</refentrytitle><manvolnum>{0}</manvolnum>}
-{0#</citerefentry>}
-endif::backend-docbook[]
-
-ifdef::backend-xhtml11[]
-[linkmb-inlinemacro]
-<a href="{target}.html">{target}{0?({0})}</a>
-endif::backend-xhtml11[]
-
-ifdef::doctype-manpage[]
-ifdef::backend-docbook[]
-[header]
-template::[header-declarations]
-<refentry>
-<refmeta>
-<refentrytitle>{mantitle}</refentrytitle>
-<manvolnum>{manvolnum}</manvolnum>
-<refmiscinfo class="source">libmodbus</refmiscinfo>
-<refmiscinfo class="version">v{libmodbus_version}</refmiscinfo>
-<refmiscinfo class="manual">libmodbus Manual</refmiscinfo>
-</refmeta>
-<refnamediv>
-  <refname>{manname}</refname>
-  <refpurpose>{manpurpose}</refpurpose>
-</refnamediv>
-endif::backend-docbook[]
-endif::doctype-manpage[]
-
-ifdef::backend-xhtml11[]
-[footer]
-</div>
-{disable-javascript%<div id="footnotes"><hr /></div>}
-<div id="footer">
-<div id="footer-text">
-libmodbus {libmodbus_version}<br />
-Last updated {docdate} {doctime}
-</div>
-</div>
-</body>
-</html>
-endif::backend-xhtml11[]

+ 0 - 279
doc/libmodbus.txt

@@ -1,279 +0,0 @@
-libmodbus(7)
-============
-
-
-NAME
-----
-libmodbus - a fast and portable Modbus library
-
-
-SYNOPSIS
---------
-*#include <modbus.h>*
-
-*cc* 'files' \`pkg-config --cflags --libs libmodbus`
-
-DESCRIPTION
------------
-libmodbus is a library to send/receive data with a device which respects the
-Modbus protocol. This library contains various backends to communicate over
-different networks (eg. serial in RTU mode or Ethernet in TCP/IPv6). The
-http://www.modbus.org site provides documentation about the protocol at
-http://www.modbus.org/specs.php.
-
-libmodbus provides an abstraction of the lower communication layers and offers
-the same API on all supported platforms.
-
-This documentation presents an overview of libmodbus concepts, describes how
-libmodbus abstracts Modbus communication with different hardware and platforms
-and provides a reference manual for the functions provided by the libmodbus
-library.
-
-
-Contexts
-~~~~~~~~
-The Modbus protocol contains many variants (eg. serial RTU or Ethernet TCP), to
-ease the implementation of a variant, the library was designed to use a backend
-for each variant. The backends are also a convenient way to fulfill other
-requirements (eg. real-time operations). Each backend offers a specific function
-to create a new 'modbus_t' context. The 'modbus_t' context is an opaque
-structure containing all necessary information to establish a connection with
-other Modbus devices according to the selected variant.
-
-You can choose the best context for your needs among:
-
-RTU Context
-^^^^^^^^^^^
-The RTU backend (Remote Terminal Unit) is used in serial communication and makes
-use of a compact, binary representation of the data for protocol
-communication. The RTU format follows the commands/data with a cyclic redundancy
-check checksum as an error check mechanism to ensure the reliability of
-data. Modbus RTU is the most common implementation available for Modbus. A
-Modbus RTU message must be transmitted continuously without inter-character
-hesitations (extract from Wikipedia, Modbus, http://en.wikipedia.org/wiki/Modbus
-(as of Mar. 13, 2011, 20:51 GMT).
-
-The Modbus RTU framing calls a slave, a device/service which handle Modbus
-requests, and a master, a client which send requests. The communication is
-always initiated by the master.
-
-Many Modbus devices can be connected together on the same physical link so
-before sending a message, you must set the slave (receiver) with
-linkmb:modbus_set_slave[3]. If you're running a slave, its slave number will be
-used to filter received messages.
-
-The libmodbus implementation of RTU isn't time based as stated in original
-Modbus specification, instead all bytes are sent as fast as possible and a
-response or an indication is considered complete when all expected characters
-have been received. This implementation offers very fast communication but you
-must take care to set a response timeout of slaves less than response timeout of
-master (ortherwise other slaves may ignore master requests when one of the slave
-is not responding).
-
-Create a Modbus RTU context::
-    - linkmb:modbus_new_rtu[3]
-
-
-Set the serial mode::
-    -  linkmb:modbus_rtu_get_serial_mode[3]
-    -  linkmb:modbus_rtu_set_serial_mode[3]
-    -  linkmb:modbus_rtu_get_rts[3]
-    -  linkmb:modbus_rtu_set_rts[3]
-    -  linkmb:modbus_rtu_set_custom_rts[3]
-    -  linkmb:modbus_rtu_get_rts_delay[3]
-    -  linkmb:modbus_rtu_set_rts_delay[3]
-
-
-TCP (IPv4) Context
-^^^^^^^^^^^^^^^^^^
-The TCP backend implements a Modbus variant used for communications over
-TCP/IPv4 networks. It does not require a checksum calculation as lower layer
-takes care of the same.
-
-Create a Modbus TCP context::
-    - linkmb:modbus_new_tcp[3]
-
-
-TCP PI (IPv4 and IPv6) Context
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-The TCP PI (Protocol Independent) backend implements a Modbus variant used for
-communications over TCP IPv4 and IPv6 networks. It does not require a checksum
-calculation as lower layer takes care of the same.
-
-Contrary to the TCP IPv4 only backend, the TCP PI backend offers hostname
-resolution but it consumes about 1Kb of additional memory.
-
-Create a Modbus TCP context::
-    - linkmb:modbus_new_tcp_pi[3]
-
-
-Common
-^^^^^^
-Before using any libmodbus functions, the caller must allocate and initialize a
-'modbus_t' context with functions explained above, then the following functions
-are provided to modify and free a 'context':
-
-Free libmodbus context::
-    - linkmb:modbus_free[3]
-
-Set slave ID::
-    - linkmb:modbus_set_slave[3]
-
-Enable debug mode::
-    - linkmb:modbus_set_debug[3]
-
-Timeout settings::
-    - linkmb:modbus_get_byte_timeout[3]
-    - linkmb:modbus_set_byte_timeout[3]
-    - linkmb:modbus_get_response_timeout[3]
-    - linkmb:modbus_set_response_timeout[3]
-
-Error recovery mode::
-    - linkmb:modbus_set_error_recovery[3]
-
-Setter/getter of internal socket::
-    - linkmb:modbus_set_socket[3]
-    - linkmb:modbus_get_socket[3]
-
-Information about header::
-    - linkmb:modbus_get_header_length[3]
-
-Macros for data manipulation::
-
-    - MODBUS_GET_HIGH_BYTE(data), extracts the high byte from a byte
-    - MODBUS_GET_LOW_BYTE(data), extracts the low byte from a byte
-    - MODBUS_GET_INT64_FROM_INT16(tab_int16, index), builds an int64 from the four
-      first int16 starting at tab_int16[index]
-    - MODBUS_GET_INT32_FROM_INT16(tab_int16, index), builds an int32 from the two
-      first int16 starting at tab_int16[index]
-    - MODBUS_GET_INT16_FROM_INT8(tab_int8, index), builds an int16 from the two
-      first int8 starting at tab_int8[index]
-    - MODBUS_SET_INT16_TO_INT8(tab_int8, index, value), set an int16 value into
-      the two first bytes starting at tab_int8[index]
-    - MODBUS_SET_INT32_TO_INT16(tab_int16, index, value), set an int32 value into
-      the two first int16 starting at tab_int16[index]
-    - MODBUS_SET_INT64_TO_INT16(tab_int16, index, value), set an int64 value into
-      the four first int16 starting at tab_int16[index]
-
-Handling of bits and bytes::
-    - linkmb:modbus_set_bits_from_byte[3]
-    - linkmb:modbus_set_bits_from_bytes[3]
-    - linkmb:modbus_get_byte_from_bits[3]
-
-Set or get float numbers::
-    - linkmb:modbus_get_float_abcd[3]
-    - linkmb:modbus_set_float_abcd[3]
-    - linkmb:modbus_get_float_badc[3]
-    - linkmb:modbus_set_float_badc[3]
-    - linkmb:modbus_get_float_cdab[3]
-    - linkmb:modbus_set_float_cdab[3]
-    - linkmb:modbus_get_float_dcba[3]
-    - linkmb:modbus_set_float_dcba[3]
-    - linkmb:modbus_get_float[3] (deprecated)
-    - linkmb:modbus_set_float[3] (deprecated)
-
-
-
-Connection
-~~~~~~~~~~
-The following functions are provided to establish and close a connection with
-Modbus devices:
-
-Establish a connection::
-    - linkmb:modbus_connect[3]
-
-Close a connection::
-    - linkmb:modbus_close[3]
-
-Flush a connection::
-    - linkmb:modbus_flush[3]
-
-
-Client
-~~~~~~
-The Modbus protocol defines different data types and functions to read and write
-them from/to remote devices. The following functions are used by the clients to
-send Modbus requests:
-
-Read data::
-    -  linkmb:modbus_read_bits[3]
-    -  linkmb:modbus_read_input_bits[3]
-    -  linkmb:modbus_read_registers[3]
-    -  linkmb:modbus_read_input_registers[3]
-    -  linkmb:modbus_report_slave_id[3]
-
-Write data::
-    -  linkmb:modbus_write_bit[3]
-    -  linkmb:modbus_write_register[3]
-    -  linkmb:modbus_write_bits[3]
-    -  linkmb:modbus_write_registers[3]
-
-Write and read data::
-    -   linkmb:modbus_write_and_read_registers[3]
-
-Raw requests::
-    - linkmb:modbus_send_raw_request[3]
-    - linkmb:modbus_receive_confirmation[3]
-
-Reply an exception::
-    - linkmb:modbus_reply_exception[3]
-
-
-Server
-~~~~~~
-The server is waiting for request from clients and must answer when it is
-concerned by the request. The libmodbus offers the following functions to
-handle requests:
-
-Data mapping::
-    -  linkmb:modbus_mapping_new[3]
-    -  linkmb:modbus_mapping_free[3]
-
-Receive::
-    -  linkmb:modbus_receive[3]
-
-Reply::
-    -  linkmb:modbus_reply[3]
-    -  linkmb:modbus_reply_exception[3]
-
-
-ERROR HANDLING
---------------
-The libmodbus functions handle errors using the standard conventions found on
-POSIX systems. Generally, this means that upon failure a libmodbus function
-shall return either a NULL value (if returning a pointer) or a negative value
-(if returning an integer), and the actual error code shall be stored in the
-'errno' variable.
-
-The *modbus_strerror()* function is provided to translate libmodbus-specific
-error codes into error message strings; for details refer to
-linkmb:modbus_strerror[3].
-
-
-MISCELLANEOUS
--------------
-The _LIBMODBUS_VERSION_STRING_ constant indicates the libmodbus version the
-program has been compiled against. The variables 'libmodbus_version_major',
-'libmodbus_version_minor', 'libmodbus_version_micro' give the version the
-program is linked against.
-
-
-AUTHORS
--------
-The libmodbus documentation was written by Stéphane Raimbault
-<stephane.raimbault@gmail.com>
-
-
-RESOURCES
----------
-Main web site: <http://www.libmodbus.org/>
-
-Report bugs on the issue tracker at
-<http://github.com/stephane/libmodbus/issues>.
-
-
-COPYING
--------
-Free use of this software is granted under the terms of the GNU Lesser General
-Public License (LGPL v2.1+). For details see the file `COPYING.LESSER` included
-with the libmodbus distribution.

+ 0 - 33
doc/modbus_free.txt

@@ -1,33 +0,0 @@
-modbus_free(3)
-==============
-
-
-NAME
-----
-modbus_free - free a libmodbus context
-
-
-SYNOPSIS
---------
-*void modbus_free(modbus_t *'ctx');*
-
-
-DESCRIPTION
------------
-The *modbus_free()* function shall free an allocated modbus_t structure.
-
-
-RETURN VALUE
-------------
-There is no return values.
-
-
-SEE ALSO
---------
-linkmb:libmodbus[3]
-
-
-AUTHORS
--------
-The libmodbus documentation was written by Stéphane Raimbault
-<stephane.raimbault@gmail.com>

+ 0 - 35
doc/modbus_get_byte_from_bits.txt

@@ -1,35 +0,0 @@
-modbus_get_byte_from_bits(3)
-============================
-
-NAME
-----
-modbus_get_byte_from_bits - get the value from many bits
-
-
-SYNOPSIS
---------
-*uint8_t modbus_get_byte_from_bits(const uint8_t *'src', int 'index', unsigned int 'nb_bits');*
-
-
-DESCRIPTION
------------
-The *modbus_get_byte_from_bits()* function shall extract a value from many
-bits. All _nb_bits_ bits from _src_ at position _index_ will be read as a
-single value. To obtain a full byte, set nb_bits to 8.
-
-
-RETURN VALUE
-------------
-The function shall return a byte containing the bits read.
-
-
-SEE ALSO
---------
-linkmb:modbus_set_bits_from_byte[3]
-linkmb:modbus_set_bits_from_bytes[3]
-
-
-AUTHORS
--------
-The libmodbus documentation was written by Stéphane Raimbault
-<stephane.raimbault@gmail.com>

+ 0 - 50
doc/modbus_get_byte_timeout.txt

@@ -1,50 +0,0 @@
-modbus_get_byte_timeout(3)
-==========================
-
-
-NAME
-----
-modbus_get_byte_timeout - get timeout between bytes
-
-
-SYNOPSIS
---------
-*int modbus_get_byte_timeout(modbus_t *'ctx', uint32_t *'to_sec', uint32_t *'to_usec');*
-
-
-DESCRIPTION
------------
-The *modbus_get_byte_timeout()* function shall store the timeout interval
-between two consecutive bytes of the same message in the _to_sec_ and _to_usec_
-arguments.
-
-
-RETURN VALUE
-------------
-The function shall return 0 if successful. Otherwise it shall return -1 and set
-errno.
-
-
-EXAMPLE
--------
-[source,c]
--------------------
-uint32_t to_sec;
-uint32_t to_usec;
-
-/* Save original timeout */
-modbus_get_byte_timeout(ctx, &to_sec, &to_usec);
--------------------
-
-
-SEE ALSO
---------
-linkmb:modbus_set_byte_timeout[3]
-linkmb:modbus_get_response_timeout[3]
-linkmb:modbus_set_response_timeout[3]
-
-
-AUTHORS
--------
-The libmodbus documentation was written by Stéphane Raimbault
-<stephane.raimbault@gmail.com>

+ 0 - 39
doc/modbus_get_float.txt

@@ -1,39 +0,0 @@
-modbus_get_float(3)
-===================
-
-
-NAME
-----
-modbus_get_float - get a float value from 2 registers
-
-
-SYNOPSIS
---------
-*float modbus_get_float(const uint16_t *'src');*
-
-Warning, this function is *deprecated* since libmodbus v3.2.0 and has been
-replaced by *modbus_get_float_dcba()*.
-
-DESCRIPTION
------------
-The *modbus_get_float()* function shall get a float from 4 bytes in Modbus
-format (DCBA byte order). The _src_ array must be a pointer on two 16 bits
-values, for example, if the first word is set to 0x4465 and the second to
-0x229a, the float value will be 916.540649.
-
-
-RETURN VALUE
-------------
-The function shall return a float.
-
-
-SEE ALSO
---------
-linkmb:modbus_set_float[3]
-linkmb:modbus_set_float_dcba[3]
-linkmb:modbus_get_float_dcba[3]
-
-AUTHORS
--------
-The libmodbus documentation was written by Stéphane Raimbault
-<stephane.raimbault@gmail.com>

+ 0 - 39
doc/modbus_get_float_abcd.txt

@@ -1,39 +0,0 @@
-modbus_get_float_abcd(3)
-========================
-
-
-NAME
-----
-modbus_get_float_abcd - get a float value from 2 registers in ABCD byte order
-
-
-SYNOPSIS
---------
-*float modbus_get_float_abcd(const uint16_t *'src');*
-
-
-DESCRIPTION
------------
-The *modbus_get_float_abcd()* function shall get a float from 4 bytes in usual
-Modbus format. The _src_ array must be a pointer on two 16 bits values, for
-example, if the first word is set to 0x0020 and the second to 0xF147, the float
-value will be read as 123456.0.
-
-
-RETURN VALUE
-------------
-The function shall return a float.
-
-
-SEE ALSO
---------
-linkmb:modbus_set_float_abcd[3]
-linkmb:modbus_get_float_badc[3]
-linkmb:modbus_get_float_cdab[3]
-linkmb:modbus_get_float_dcba[3]
-
-
-AUTHORS
--------
-The libmodbus documentation was written by Stéphane Raimbault
-<stephane.raimbault@gmail.com>

+ 0 - 39
doc/modbus_get_float_badc.txt

@@ -1,39 +0,0 @@
-modbus_get_float_badc(3)
-========================
-
-
-NAME
-----
-modbus_get_float_badc - get a float value from 2 registers in BADC byte order
-
-
-SYNOPSIS
---------
-*float modbus_get_float_badc(const uint16_t *'src');*
-
-
-DESCRIPTION
------------
-The *modbus_get_float_badc()* function shall get a float from 4 bytes with
-swapped bytes (BADC instead of ABCD). The _src_ array must be a pointer on two
-16 bits values, for example, if the first word is set to 0x2000 and the second
-to 0x47F1, the float value will be read as 123456.0.
-
-
-RETURN VALUE
-------------
-The function shall return a float.
-
-
-SEE ALSO
---------
-linkmb:modbus_set_float_badc[3]
-linkmb:modbus_get_float_abcd[3]
-linkmb:modbus_get_float_cdab[3]
-linkmb:modbus_get_float_dcba[3]
-
-
-AUTHORS
--------
-The libmodbus documentation was written by Stéphane Raimbault
-<stephane.raimbault@gmail.com>

+ 0 - 39
doc/modbus_get_float_cdab.txt

@@ -1,39 +0,0 @@
-modbus_get_float_cdab(3)
-========================
-
-
-NAME
-----
-modbus_get_float_cdab - get a float value from 2 registers in CDAB byte order
-
-
-SYNOPSIS
---------
-*float modbus_get_float_cdab(const uint16_t *'src');*
-
-
-DESCRIPTION
------------
-The *modbus_get_float_cdab()* function shall get a float from 4 bytes with
-swapped words (CDAB order instead of ABCD). The _src_ array must be a pointer on
-two 16 bits values, for example, if the first word is set to F147 and the second
-to 0x0020, the float value will be read as 123456.0.
-
-
-RETURN VALUE
-------------
-The function shall return a float.
-
-
-SEE ALSO
---------
-linkmb:modbus_set_float_cdab[3]
-linkmb:modbus_get_float_abcd[3]
-linkmb:modbus_get_float_badc[3]
-linkmb:modbus_get_float_dcba[3]
-
-
-AUTHORS
--------
-The libmodbus documentation was written by Stéphane Raimbault
-<stephane.raimbault@gmail.com>

+ 0 - 39
doc/modbus_get_float_dcba.txt

@@ -1,39 +0,0 @@
-modbus_get_float_dcba(3)
-========================
-
-
-NAME
-----
-modbus_get_float_dcba - get a float value from 2 registers in DCBA byte order
-
-
-SYNOPSIS
---------
-*float modbus_get_float_dcba(const uint16_t *'src');*
-
-
-DESCRIPTION
------------
-The *modbus_get_float_dcba()* function shall get a float from 4 bytes in
-inversed Modbus format (DCBA order instead of ABCD). The _src_ array must be a
-pointer on two 16 bits values, for example, if the first word is set to 0x47F1
-and the second to 0x2000, the float value will be read as 123456.0.
-
-
-RETURN VALUE
-------------
-The function shall return a float.
-
-
-SEE ALSO
---------
-linkmb:modbus_set_float_dcba[3]
-linkmb:modbus_get_float_abcd[3]
-linkmb:modbus_get_float_badc[3]
-linkmb:modbus_get_float_cdab[3]
-
-
-AUTHORS
--------
-The libmodbus documentation was written by Stéphane Raimbault
-<stephane.raimbault@gmail.com>

+ 0 - 35
doc/modbus_get_header_length.txt

@@ -1,35 +0,0 @@
-modbus_get_header_length(3)
-===========================
-
-
-NAME
-----
-modbus_get_header_length - retrieve the current header length
-
-
-SYNOPSIS
---------
-*int modbus_get_header_length(modbus_t *'ctx');*
-
-
-DESCRIPTION
------------
-The *modbus_get_header_length()* function shall retrieve the current header
-length from the backend. This function is convenient to manipulate a message and
-so its limited to low-level operations.
-
-
-RETURN VALUE
-------------
-The header length as integer value.
-
-
-SEE ALSO
---------
-linkmb:libmodbus[7]
-
-
-AUTHORS
--------
-The libmodbus documentation was written by Stéphane Raimbault
-<stephane.raimbault@gmail.com>

+ 0 - 53
doc/modbus_get_indication_timeout.txt

@@ -1,53 +0,0 @@
-modbus_get_indication_timeout(3)
-================================
-
-
-NAME
-----
-modbus_get_indication_timeout - get timeout used to wait for an indication (request received by a server).
-
-SYNOPSIS
---------
-*int modbus_get_indication_timeout(modbus_t *'ctx', uint32_t *'to_sec', uint32_t *'to_usec');*
-
-
-DESCRIPTION
------------
-
-The *modbus_get_indication_timeout()* function shall store the timeout interval
-used to wait for an indication in the _to_sec_ and _to_usec_ arguments.
-Indication is the term used by the Modbus protocol to designate a request
-received by the server.
-
-The default value is zero, it means the server will wait forever.
-
-
-RETURN VALUE
-------------
-The function shall return 0 if successful. Otherwise it shall return -1 and set
-errno.
-
-
-EXAMPLE
--------
-[source,c]
--------------------
-uint32_t to_sec;
-uint32_t to_usec;
-
-/* Save original timeout */
-modbus_get_indication_timeout(ctx, &to_sec, &to_usec);
--------------------
-
-
-SEE ALSO
---------
-linkmb:modbus_set_indication_timeout[3]
-linkmb:modbus_get_response_timeout[3]
-linkmb:modbus_set_response_timeout[3]
-
-
-AUTHORS
--------
-The libmodbus documentation was written by Stéphane Raimbault
-<stephane.raimbault@gmail.com>

+ 0 - 52
doc/modbus_get_response_timeout.txt

@@ -1,52 +0,0 @@
-modbus_get_response_timeout(3)
-==============================
-
-
-NAME
-----
-modbus_get_response_timeout - get timeout for response
-
-
-SYNOPSIS
---------
-*int modbus_get_response_timeout(modbus_t *'ctx', uint32_t *'to_sec', uint32_t *'to_usec');*
-
-
-DESCRIPTION
------------
-The *modbus_get_response_timeout()* function shall return the timeout interval
-used to wait for a response in the _to_sec_ and _to_usec_ arguments.
-
-
-RETURN VALUE
-------------
-The function shall return 0 if successful. Otherwise it shall return -1 and set
-errno.
-
-
-EXAMPLE
--------
-[source,c]
--------------------
-uint32_t old_response_to_sec;
-uint32_t old_response_to_usec;
-
-/* Save original timeout */
-modbus_get_response_timeout(ctx, &old_response_to_sec, &old_response_to_usec);
-
-/* Define a new and too short timeout! */
-modbus_set_response_timeout(ctx, 0, 0);
--------------------
-
-
-SEE ALSO
---------
-linkmb:modbus_set_response_timeout[3]
-linkmb:modbus_get_byte_timeout[3]
-linkmb:modbus_set_byte_timeout[3]
-
-
-AUTHORS
--------
-The libmodbus documentation was written by Stéphane Raimbault
-<stephane.raimbault@gmail.com>

+ 0 - 41
doc/modbus_get_slave.txt

@@ -1,41 +0,0 @@
-modbus_get_slave(3)
-===================
-
-
-NAME
-----
-modbus_get_slave - get slave number in the context
-
-
-SYNOPSIS
---------
-*int modbus_get_slave(modbus_t *'ctx');*
-
-
-DESCRIPTION
------------
-The *modbus_get_slave()* function shall get the slave number in the libmodbus
-context.
-
-
-RETURN VALUE
-------------
-The function shall return the slave number if successful. Otherwise it shall return -1
-and set errno to one of the values defined below.
-
-
-ERRORS
-------
-*EINVAL*::
-The libmodbus context is undefined.
-
-
-SEE ALSO
---------
-linkmb:modbus_set_slave[3]
-
-
-AUTHORS
--------
-The libmodbus documentation was written by Stéphane Raimbault
-<stephane.raimbault@gmail.com>

+ 0 - 35
doc/modbus_get_socket.txt

@@ -1,35 +0,0 @@
-modbus_get_socket(3)
-====================
-
-
-NAME
-----
-modbus_get_socket - get the current socket of the context
-
-
-SYNOPSIS
---------
-*int modbus_get_socket(modbus_t *'ctx');*
-
-
-DESCRIPTION
------------
-The *modbus_get_socket()* function shall return the current socket or file
-descriptor of the libmodbus context.
-
-
-RETURN VALUE
-------------
-The function returns the current socket or file descriptor of the context if
-successful. Otherwise it shall return -1 and set errno.
-
-
-SEE ALSO
---------
-linkmb:modbus_set_socket[3]
-
-
-AUTHORS
--------
-The libmodbus documentation was written by Stéphane Raimbault
-<stephane.raimbault@gmail.com>

+ 0 - 34
doc/modbus_mapping_free.txt

@@ -1,34 +0,0 @@
-modbus_mapping_free(3)
-=====================
-
-
-NAME
-----
-modbus_mapping_free - free a modbus_mapping_t structure
-
-
-SYNOPSIS
---------
-*void modbus_mapping_free(modbus_mapping_t *'mb_mapping');*
-
-
-DESCRIPTION
------------
-The function shall free the four arrays of mb_mapping_t structure and finally
-the mb_mapping_t referenced by _mb_mapping_.
-
-
-RETURN VALUE
-------------
-There is no return values.
-
-
-SEE ALSO
---------
-linkmb:modbus_mapping_new[3]
-
-
-AUTHORS
--------
-The libmodbus documentation was written by Stéphane Raimbault
-<stephane.raimbault@gmail.com>

+ 0 - 69
doc/modbus_mapping_new.txt

@@ -1,69 +0,0 @@
-modbus_mapping_new(3)
-=====================
-
-
-NAME
-----
-modbus_mapping_new - allocate four arrays of bits and registers
-
-
-SYNOPSIS
---------
-*modbus_mapping_t* modbus_mapping_new(int 'nb_bits', int 'nb_input_bits', int 'nb_registers', int 'nb_input_registers');*
-
-
-DESCRIPTION
------------
-The *modbus_mapping_new()* function shall allocate four arrays to store bits,
-input bits, registers and inputs registers. The pointers are stored in
-modbus_mapping_t structure. All values of the arrays are initialized to zero.
-
-This function is equivalent to a call of the
-linkmb:modbus_mapping_new_start_address[3] function with all start addresses to
-`0`.
-
-If it isn't necessary to allocate an array for a specific type of data, you can
-pass the zero value in argument, the associated pointer will be NULL.
-
-This function is convenient to handle requests in a Modbus server/slave.
-
-
-RETURN VALUE
-------------
-The function shall return the new allocated structure if successful. Otherwise
-it shall return NULL and set errno.
-
-
-ERRORS
-------
-*ENOMEM*::
-Not enough memory
-
-
-EXAMPLE
--------
-[source,c]
--------------------
-/* The first value of each array is accessible from the 0 address. */
-mb_mapping = modbus_mapping_new(BITS_ADDRESS + BITS_NB,
-                                INPUT_BITS_ADDRESS + INPUT_BITS_NB,
-                                REGISTERS_ADDRESS + REGISTERS_NB,
-                                INPUT_REGISTERS_ADDRESS + INPUT_REGISTERS_NB);
-if (mb_mapping == NULL) {
-    fprintf(stderr, "Failed to allocate the mapping: %s\n",
-            modbus_strerror(errno));
-    modbus_free(ctx);
-    return -1;
-}
--------------------
-
-SEE ALSO
---------
-linkmb:modbus_mapping_free[3]
-linkmb:modbus_mapping_new_start_address[3]
-
-
-AUTHORS
--------
-The libmodbus documentation was written by Stéphane Raimbault
-<stephane.raimbault@gmail.com>

+ 0 - 81
doc/modbus_mapping_new_start_address.txt

@@ -1,81 +0,0 @@
-modbus_mapping_new_start_address(3)
-===================================
-
-
-NAME
-----
-modbus_mapping_new_start_address - allocate four arrays of bits and registers accessible from their starting addresses
-
-
-SYNOPSIS
---------
-*modbus_mapping_t* modbus_mapping_new_start_address(int 'start_bits', int 'nb_bits',
-                                                    int 'start_input_bits', int 'nb_input_bits',
-                                                    int 'start_registers', int 'nb_registers',
-                                                    int 'start_input_registers', int 'nb_input_registers');*
-
-
-DESCRIPTION
------------
-The _modbus_mapping_new_start_address()_ function shall allocate four arrays to
-store bits, input bits, registers and inputs registers. The pointers are stored
-in modbus_mapping_t structure. All values of the arrays are initialized to zero.
-
-The different starting addresses make it possible to place the mapping at any
-address in each address space. This way, you can give access to values stored
-at high addresses without allocating memory from the address zero, for eg. to
-make available registers from 10000 to 10009, you can use:
-
-[source,c]
--------------------
-mb_mapping = modbus_mapping_new_start_address(0, 0, 0, 0, 10000, 10, 0, 0);
--------------------
-
-With this code, only 10 registers (`uint16_t`) are allocated.
-
-If it isn't necessary to allocate an array for a specific type of data, you can
-pass the zero value in argument, the associated pointer will be NULL.
-
-This function is convenient to handle requests in a Modbus server/slave.
-
-
-RETURN VALUE
-------------
-The _modbus_mapping_new_start_address()_ function shall return the new allocated structure if
-successful. Otherwise it shall return NULL and set errno.
-
-
-ERRORS
-------
-ENOMEM::
-Not enough memory
-
-
-EXAMPLE
--------
-[source,c]
--------------------
-/* The first value of each array is accessible at the defined address.
-   The end address is ADDRESS + NB - 1. */
-mb_mapping = modbus_mapping_new_start_address(BITS_ADDRESS, BITS_NB,
-                                INPUT_BITS_ADDRESS, INPUT_BITS_NB,
-                                REGISTERS_ADDRESS, REGISTERS_NB,
-                                INPUT_REGISTERS_ADDRESS, INPUT_REGISTERS_NB);
-if (mb_mapping == NULL) {
-    fprintf(stderr, "Failed to allocate the mapping: %s\n",
-            modbus_strerror(errno));
-    modbus_free(ctx);
-    return -1;
-}
--------------------
-
-SEE ALSO
---------
-linkmb:modbus_mapping_new[3]
-linkmb:modbus_mapping_free[3]
-
-
-AUTHORS
--------
-The libmodbus documentation was written by Stéphane Raimbault
-<stephane.raimbault@gmail.com>

+ 0 - 41
doc/modbus_mask_write_register.txt

@@ -1,41 +0,0 @@
-modbus_mask_write_register(3)
-=============================
-
-
-NAME
-----
-modbus_mask_write_register - mask a single register
-
-
-SYNOPSIS
---------
-*int modbus_mask_write_register(modbus_t *'ctx', int 'addr', uint16_t 'and', uint16_t 'or');*
-
-
-DESCRIPTION
------------
-The *modbus_mask_write_register()* function shall modify the value of the
-holding register at the address 'addr' of the remote device using the algorithm:
-
-  new value = (current value AND 'and') OR ('or' AND (NOT 'and'))
-
-The function uses the Modbus function code 0x16 (mask single register).
-
-
-RETURN VALUE
-------------
-The function shall return 1 if successful. Otherwise it shall return -1 and set
-errno.
-
-
-SEE ALSO
---------
-linkmb:modbus_read_registers[3]
-linkmb:modbus_write_registers[3]
-
-
-AUTHORS
--------
-Martijn de Gouw <martijn.de.gouw@prodrive.nl>
-The libmodbus documentation was written by Stéphane Raimbault
-<stephane.raimbault@gmail.com>

+ 0 - 91
doc/modbus_new_rtu.txt

@@ -1,91 +0,0 @@
-modbus_new_rtu(3)
-=================
-
-
-NAME
-----
-modbus_new_rtu - create a libmodbus context for RTU
-
-
-SYNOPSIS
---------
-*modbus_t *modbus_new_rtu(const char *'device', int 'baud', char 'parity', int 'data_bit', int 'stop_bit');*
-
-
-
-DESCRIPTION
------------
-The *modbus_new_rtu()* function shall allocate and initialize a _modbus_t_
-structure to communicate in RTU mode on a serial line.
-
-The _device_ argument specifies the name of the serial port handled by the OS,
-eg. "/dev/ttyS0" or "/dev/ttyUSB0". On Windows, it's necessary to prepend COM
-name with "\\.\" for COM number greater than 9, eg. "\\\\.\\COM10". See
-http://msdn.microsoft.com/en-us/library/aa365247(v=vs.85).aspx for details
-
-The _baud_ argument specifies the baud rate of the communication, eg. 9600,
-19200, 57600, 115200, etc.
-
-The _parity_ argument can have one of the following values:::
-* _N_ for none
-* _E_ for even
-* _O_ for odd
-
-The _data_bits_ argument specifies the number of bits of data, the allowed
-values are 5, 6, 7 and 8.
-
-The _stop_bits_ argument specifies the bits of stop, the allowed values are 1
-and 2.
-
-Once the _modbus_t_ structure is initialized, you must set the slave of your
-device with linkmb:modbus_set_slave[3] and connect to the serial bus with
-linkmb:modbus_connect[3].
-
-RETURN VALUE
-------------
-The function shall return a pointer to a _modbus_t_ structure if
-successful. Otherwise it shall return NULL and set errno to one of the values
-defined below.
-
-
-ERRORS
-------
-*EINVAL*::
-An invalid argument was given.
-
-*ENOMEM*::
-Out of memory. Possibly, the application hits its memory limit and/or whole
-system is running out of memory.
-
-
-EXAMPLE
--------
-[source,c]
--------------------
-modbus_t *ctx;
-
-ctx = modbus_new_rtu("/dev/ttyUSB0", 115200, 'N', 8, 1);
-if (ctx == NULL) {
-    fprintf(stderr, "Unable to create the libmodbus context\n");
-    return -1;
-}
-
-modbus_set_slave(ctx, YOUR_DEVICE_ID);
-
-if (modbus_connect(ctx) == -1) {
-    fprintf(stderr, "Connection failed: %s\n", modbus_strerror(errno));
-    modbus_free(ctx);
-    return -1;
-}
--------------------
-
-SEE ALSO
---------
-linkmb:modbus_new_tcp[3]
-linkmb:modbus_free[3]
-
-
-AUTHORS
--------
-The libmodbus documentation was written by Stéphane Raimbault
-<stephane.raimbault@gmail.com>

+ 0 - 77
doc/modbus_new_tcp_pi.txt

@@ -1,77 +0,0 @@
-modbus_new_tcp_pi(3)
-====================
-
-
-NAME
-----
-modbus_new_tcp_pi - create a libmodbus context for TCP Protocol Independent
-
-
-SYNOPSIS
---------
-*modbus_t *modbus_new_tcp_pi(const char *'node', const char *'service');*
-
-
-DESCRIPTION
------------
-The *modbus_new_tcp_pi()* function shall allocate and initialize a modbus_t
-structure to communicate with a Modbus TCP IPv4 or IPv6 server.
-
-The _node_ argument specifies the host name or IP address of the host to connect
-to, eg. "192.168.0.5" , "::1" or "server.com". A NULL value can be used to
-listen any addresses in server mode.
-
-The _service_ argument is the service name/port number to connect to. To use the
-default Modbus port use the string "502". On many Unix systems, it’s
-convenient to use a port number greater than or equal to 1024 because it’s not
-necessary to have administrator privileges.
-
-
-RETURN VALUE
-------------
-The function shall return a pointer to a *modbus_t* structure if
-successful. Otherwise it shall return NULL and set errno to one of the values
-defined below.
-
-
-ERRORS
-------
-*EINVAL*::
-The node string is empty or has been truncated. The service string is empty or
-has been truncated.
-
-*ENOMEM*::
-Out of memory. Possibly, the application hits its memory limit and/or whole
-system is running out of memory.
-
-
-EXAMPLE
--------
-[source,c]
--------------------
-modbus_t *ctx;
-
-ctx = modbus_new_tcp_pi("::1", "1502");
-if (ctx == NULL) {
-    fprintf(stderr, "Unable to allocate libmodbus context\n");
-    return -1;
-}
-
-if (modbus_connect(ctx) == -1) {
-    fprintf(stderr, "Connection failed: %s\n", modbus_strerror(errno));
-    modbus_free(ctx);
-    return -1;
-}
--------------------
-
-SEE ALSO
---------
-linkmb:modbus_new_tcp[3]
-linkmb:modbus_tcp_pi_listen[3]
-linkmb:modbus_free[3]
-
-
-AUTHORS
--------
-The libmodbus documentation was written by Stéphane Raimbault
-<stephane.raimbault@gmail.com>

+ 0 - 48
doc/modbus_read_bits.txt

@@ -1,48 +0,0 @@
-modbus_read_bits(3)
-===================
-
-
-NAME
-----
-modbus_read_bits - read many bits
-
-
-SYNOPSIS
---------
-*int modbus_read_bits(modbus_t *'ctx', int 'addr', int 'nb', uint8_t *'dest');*
-
-
-DESCRIPTION
------------
-The *modbus_read_bits()* function shall read the status of the _nb_ bits (coils)
-to the address _addr_ of the remote device. The result of reading is stored in
-_dest_ array as unsigned bytes (8 bits) set to `TRUE` or `FALSE`.
-
-You must take care to allocate enough memory to store the results in _dest_
-(at least _nb_ * sizeof(uint8_t)).
-
-The function uses the Modbus function code 0x01 (read coil status).
-
-
-RETURN VALUE
-------------
-The function shall return the number of read bits if successful. Otherwise it
-shall return -1 and set errno.
-
-
-ERRORS
-------
-*EMBMDATA*::
-Too many bits requested
-
-
-SEE ALSO
---------
-linkmb:modbus_write_bit[3]
-linkmb:modbus_write_bits[3]
-
-
-AUTHORS
--------
-The libmodbus documentation was written by Stéphane Raimbault
-<stephane.raimbault@gmail.com>

+ 0 - 47
doc/modbus_read_input_bits.txt

@@ -1,47 +0,0 @@
-modbus_read_input_bits(3)
-=========================
-
-
-NAME
-----
-modbus_read_input_bits - read many input bits
-
-
-SYNOPSIS
---------
-*int modbus_read_input_bits(modbus_t *'ctx', int 'addr', int 'nb', uint8_t *'dest');*
-
-
-DESCRIPTION
------------
-The *modbus_read_input_bits()* function shall read the content of the _nb_ input
-bits to the address _addr_ of the remote device.  The result of reading is stored
-in _dest_ array as unsigned bytes (8 bits) set to _TRUE_ or _FALSE_.
-
-You must take care to allocate enough memory to store the results in _dest_
-(at least _nb_ * sizeof(uint8_t)).
-
-The function uses the Modbus function code 0x02 (read input status).
-
-
-RETURN VALUE
-------------
-The function shall return the number of read input status if
-successful. Otherwise it shall return -1 and set errno.
-
-
-ERRORS
-------
-*EMBMDATA*::
-Too many discrete inputs requested
-
-
-SEE ALSO
---------
-linkmb:modbus_read_input_registers[3]
-
-
-AUTHORS
--------
-The libmodbus documentation was written by Stéphane Raimbault
-<stephane.raimbault@gmail.com>

+ 0 - 51
doc/modbus_read_input_registers.txt

@@ -1,51 +0,0 @@
-modbus_read_input_registers(3)
-==============================
-
-
-NAME
-----
-modbus_read_input_registers - read many input registers
-
-
-SYNOPSIS
---------
-*int modbus_read_input_registers(modbus_t *'ctx', int 'addr', int 'nb', uint16_t *'dest');*
-
-
-DESCRIPTION
------------
-The *modbus_read_input_registers()* function shall read the content of the _nb_
-input registers to address _addr_ of the remote device. The result of the
-reading is stored in _dest_ array as word values (16 bits).
-
-You must take care to allocate enough memory to store the results in _dest_ (at
-least _nb_ * sizeof(uint16_t)).
-
-The function uses the Modbus function code 0x04 (read input registers). The
-holding registers and input registers have different historical meaning, but
-nowadays it's more common to use holding registers only.
-
-
-RETURN VALUE
-------------
-The function shall return the number of read input registers if
-successful. Otherwise it shall return -1 and set errno.
-
-
-ERRORS
-------
-*EMBMDATA*::
-Too many bits requested
-
-
-SEE ALSO
---------
-linkmb:modbus_read_input_bits[3]
-linkmb:modbus_write_register[3]
-linkmb:modbus_write_registers[3]
-
-
-AUTHORS
--------
-The libmodbus documentation was written by Stéphane Raimbault
-<stephane.raimbault@gmail.com>

+ 0 - 42
doc/modbus_receive.txt

@@ -1,42 +0,0 @@
-modbus_receive(3)
-=================
-
-
-NAME
-----
-modbus_receive - receive an indication request
-
-
-SYNOPSIS
---------
-*int modbus_receive(modbus_t *'ctx', uint8_t *'req');*
-
-
-DESCRIPTION
------------
-The *modbus_receive()* function shall receive an indication request from the
-socket of the context _ctx_. This function is used by Modbus slave/server to
-receive and analyze indication request sent by the masters/clients.
-
-If you need to use another socket or file descriptor than the one defined in the
-context _ctx_, see the function linkmb:modbus_set_socket[3].
-
-
-RETURN VALUE
-------------
-The function shall store the indication request in _req_ and return the request
-length if successful. The returned request length can be zero if the indication
-request is ignored (eg. a query for another slave in RTU mode). Otherwise it
-shall return -1 and set errno.
-
-
-SEE ALSO
---------
-linkmb:modbus_set_socket[3]
-linkmb:modbus_reply[3]
-
-
-AUTHORS
--------
-The libmodbus documentation was written by Stéphane Raimbault
-<stephane.raimbault@gmail.com>

+ 0 - 52
doc/modbus_reply.txt

@@ -1,52 +0,0 @@
-modbus_reply(3)
-===============
-
-NAME
-----
-modbus_reply - send a response to the received request
-
-
-SYNOPSIS
---------
-*int modbus_reply(modbus_t *'ctx', const uint8_t *'req', int 'req_length', modbus_mapping_t *'mb_mapping');
-
-
-DESCRIPTION
------------
-The *modbus_reply()* function shall send a response to received request. The
-request _req_ given in argument is analyzed, a response is then built and sent
-by using the information of the modbus context _ctx_.
-
-If the request indicates to read or write a value the operation will done in the
-modbus mapping _mb_mapping_ according to the type of the manipulated data.
-
-If an error occurs, an exception response will be sent.
-
-This function is designed for Modbus server.
-
-
-RETURN VALUE
-------------
-The function shall return the length of the response sent if
-successful. Otherwise it shall return -1 and set errno.
-
-
-ERRORS
-------
-*EMBMDATA*::
-Sending has failed
-
-See also the errors returned by the syscall used to send the response (eg. send
-or write).
-
-
-SEE ALSO
---------
-linkmb:modbus_reply_exception[3]
-linkmb:libmodbus[7]
-
-
-AUTHORS
--------
-The libmodbus documentation was written by Stéphane Raimbault
-<stephane.raimbault@gmail.com>

+ 0 - 57
doc/modbus_reply_exception.txt

@@ -1,57 +0,0 @@
-modbus_reply_exception(3)
-=========================
-
-NAME
-----
-modbus_reply_exception - send an exception response
-
-
-SYNOPSIS
---------
-*int modbus_reply_exception(modbus_t *'ctx', const uint8_t *'req', unsigned int 'exception_code');
-
-
-DESCRIPTION
------------
-The *modbus_reply_exception()* function shall send an exception response based
-on the 'exception_code' in argument.
-
-The libmodbus provides the following exception codes:
-
-* MODBUS_EXCEPTION_ILLEGAL_FUNCTION (1)
-* MODBUS_EXCEPTION_ILLEGAL_DATA_ADDRESS (2)
-* MODBUS_EXCEPTION_ILLEGAL_DATA_VALUE (3)
-* MODBUS_EXCEPTION_SLAVE_OR_SERVER_FAILURE (4)
-* MODBUS_EXCEPTION_ACKNOWLEDGE (5)
-* MODBUS_EXCEPTION_SLAVE_OR_SERVER_BUSY (6)
-* MODBUS_EXCEPTION_NEGATIVE_ACKNOWLEDGE (7)
-* MODBUS_EXCEPTION_MEMORY_PARITY (8)
-* MODBUS_EXCEPTION_NOT_DEFINED (9)
-* MODBUS_EXCEPTION_GATEWAY_PATH (10)
-* MODBUS_EXCEPTION_GATEWAY_TARGET (11)
-
-The initial request _req_ is required to build a valid response.
-
-
-RETURN VALUE
-------------
-The function shall return the length of the response sent if
-successful. Otherwise it shall return -1 and set errno.
-
-
-ERRORS
-------
-*EINVAL*::
-The exception code is invalid
-
-
-SEE ALSO
---------
-linkmb:modbus_reply[3]
-linkmb:libmodbus[7]
-
-
-AUTHORS
--------
-The libmodbus documentation was written by Stéphane Raimbault
-<stephane.raimbault@gmail.com>

+ 0 - 61
doc/modbus_report_slave_id.txt

@@ -1,61 +0,0 @@
-modbus_report_slave_id(3)
-=========================
-
-
-NAME
-----
-modbus_report_slave_id - returns a description of the controller
-
-
-SYNOPSIS
---------
-*int modbus_report_slave_id(modbus_t *'ctx', int 'max_dest', uint8_t *'dest');*
-
-
-DESCRIPTION
------------
-The *modbus_report_slave_id()* function shall send a request to the controller
-to obtain a description of the controller.
-
-The response stored in _dest_ contains:
-
-* the slave ID, this unique ID is in reality not unique at all so it's not
-  possible to depend on it to know how the information are packed in the
-  response.
-* the run indicator status (0x00 = OFF, 0xFF = ON)
-* additional data specific to each controller. For example, libmodbus returns
-  the version of the library as a string.
-
-The function writes at most _max_dest_ bytes from the response to _dest_ so
-you must ensure that _dest_ is large enough.
-
-RETURN VALUE
-------------
-The function shall return the number of read data if successful.
-
-If the output was truncated due to the _max_dest_ limit then the return value is
-the number of bytes which would have been written to _dest_ if enough space had
-been available. Thus, a return value greater than _max_dest_ means that the
-response data was truncated.
-
-Otherwise it shall return -1 and set errno.
-
-EXAMPLE
--------
-[source,c]
--------------------
-uint8_t tab_bytes[MODBUS_MAX_PDU_LENGTH];
-
-...
-
-rc = modbus_report_slave_id(ctx, MODBUS_MAX_PDU_LENGTH, tab_bytes);
-if (rc > 1) {
-    printf("Run Status Indicator: %s\n", tab_bytes[1] ? "ON" : "OFF");
-}
--------------------
-
-
-AUTHORS
--------
-The libmodbus documentation was written by Stéphane Raimbault
-<stephane.raimbault@gmail.com>

+ 0 - 47
doc/modbus_rtu_get_rts.txt

@@ -1,47 +0,0 @@
-modbus_rtu_get_rts(3)
-=====================
-
-
-NAME
-----
-modbus_rtu_get_rts - get the current RTS mode in RTU
-
-
-SYNOPSIS
---------
-*int modbus_rtu_get_rts(modbus_t *'ctx');*
-
-
-DESCRIPTION
------------
-The *modbus_rtu_get_rts()* function shall get the current Request To Send mode
-of the libmodbus context _ctx_. The possible returned values are:
-
-* MODBUS_RTU_RTS_NONE
-* MODBUS_RTU_RTS_UP
-* MODBUS_RTU_RTS_DOWN
-
-This function can only be used with a context using a RTU backend.
-
-
-RETURN VALUE
-------------
-The function shall return the current RTS mode if successful. Otherwise it shall
-return -1 and set errno.
-
-
-ERRORS
-------
-*EINVAL*::
-The libmodbus backend is not RTU.
-
-
-SEE ALSO
---------
-linkmb:modbus_rtu_set_rts[3]
-
-
-AUTHORS
--------
-The libmodbus documentation was written by Stéphane Raimbault
-<stephane.raimbault@gmail.com>

+ 0 - 46
doc/modbus_rtu_get_rts_delay.txt

@@ -1,46 +0,0 @@
-modbus_rtu_get_rts_delay(3)
-===========================
-
-
-NAME
-----
-modbus_rtu_get_rts_delay - get the current RTS delay in RTU
-
-
-SYNOPSIS
---------
-*int modbus_rtu_get_rts_delay(modbus_t *'ctx');*
-
-
-DESCRIPTION
------------
-
-The _modbus_rtu_get_rts_delay()_ function shall get the current Request To Send
-delay period of the libmodbus context 'ctx'.
-
-This function can only be used with a context using a RTU backend.
-
-
-RETURN VALUE
-------------
-The _modbus_rtu_get_rts_delay()_ function shall return the current RTS delay in
-microseconds if successful. Otherwise it shall return -1 and set errno.
-
-
-ERRORS
-------
-*EINVAL*::
-The libmodbus backend is not RTU.
-
-
-SEE ALSO
---------
-linkmb:modbus_rtu_set_rts_delay[3]
-
-
-AUTHORS
--------
-Jimmy Bergström <jimmy@ekontroll.com>
-
-The libmodbus documentation was written by Stéphane Raimbault
-<stephane.raimbault@gmail.com>

+ 0 - 53
doc/modbus_rtu_get_serial_mode.txt

@@ -1,53 +0,0 @@
-modbus_rtu_get_serial_mode(3)
-=============================
-
-
-NAME
-----
-modbus_rtu_get_serial_mode - get the current serial mode
-
-
-SYNOPSIS
---------
-*int modbus_rtu_get_serial_mode(modbus_t *'ctx');*
-
-
-DESCRIPTION
------------
-The *modbus_rtu_get_serial_mode()* function shall return the serial mode
-currently used by the libmodbus context:
-
-*MODBUS_RTU_RS232*:: the serial line is set for RS232 communication. RS-232
- (Recommended Standard 232) is the traditional name for a series of standards
- for serial binary single-ended data and control signals connecting between a
- DTE (Data Terminal Equipment) and a DCE (Data Circuit-terminating
- Equipment). It is commonly used in computer serial ports
-
-*MODBUS_RTU_RS485*:: the serial line is set for RS485 communication. EIA-485,
- also known as TIA/EIA-485 or RS-485, is a standard defining the electrical
- characteristics of drivers and receivers for use in balanced digital multipoint
- systems. This standard is widely used for communications in industrial
- automation because it can be used effectively over long distances and in
- electrically noisy environments.
-
-This function is only available on Linux kernels 2.6.28 onwards and can only be
-used with a context using a RTU backend.
-
-
-RETURN VALUE
-------------
-The function shall return `MODBUS_RTU_RS232` or `MODBUS_RTU_RS485` if
-successful. Otherwise it shall return -1 and set errno to one of the values
-defined below.
-
-
-ERRORS
-------
-*EINVAL*::
-The current libmodbus backend is not RTU.
-
-
-AUTHORS
--------
-The libmodbus documentation was written by Stéphane Raimbault
-<stephane.raimbault@gmail.com>

+ 0 - 45
doc/modbus_rtu_set_custom_rts.txt

@@ -1,45 +0,0 @@
-modbus_rtu_set_custom_rts(3)
-============================
-
-
-NAME
-----
-modbus_rtu_set_custom_rts - set a function to be used for custom RTS implementation
-
-
-SYNOPSIS
---------
-*int modbus_rtu_set_custom_rts(modbus_t *'ctx', void (*'set_rts') (modbus_t *ctx, int on))*
-
-
-DESCRIPTION
------------
-The _modbus_rtu_set_custom_rts()_ function shall set a custom function to be
-called when the RTS pin is to be set before and after a transmission. By default
-this is set to an internal function that toggles the RTS pin using an ioctl
-call.
-
-Note that this function adheres to the RTS mode, the values MODBUS_RTU_RTS_UP or
-MODBUS_RTU_RTS_DOWN must be used for the function to be called.
-
-This function can only be used with a context using a RTU backend.
-
-
-RETURN VALUE
-------------
-The _modbus_rtu_set_custom_rts()_ function shall return 0 if successful.
-Otherwise it shall return -1 and set errno to one of the values defined below.
-
-
-ERRORS
-------
-*EINVAL*::
-The libmodbus backend is not RTU.
-
-
-AUTHORS
--------
-Jimmy Bergström <jimmy@ekontroll.com>
-
-The libmodbus documentation was written by Stéphane Raimbault
-<stephane.raimbault@gmail.com>

+ 0 - 46
doc/modbus_rtu_set_rts_delay.txt

@@ -1,46 +0,0 @@
-modbus_rtu_set_rts_delay(3)
-===========================
-
-
-NAME
-----
-modbus_rtu_set_rts_delay - set the RTS delay in RTU
-
-
-SYNOPSIS
---------
-*int modbus_rtu_set_rts_delay(modbus_t *'ctx', int 'us');*
-
-
-DESCRIPTION
------------
-
-The _modbus_rtu_set_rts_delay()_ function shall set the Request To Send delay
-period of the libmodbus context 'ctx'.
-
-This function can only be used with a context using a RTU backend.
-
-
-RETURN VALUE
-------------
-The _modbus_rtu_set_rts_delay()_ function shall return 0 if successful.
-Otherwise it shall return -1 and set errno.
-
-
-ERRORS
-------
-*EINVAL*::
-The libmodbus backend is not RTU or a negative delay was specified.
-
-
-SEE ALSO
---------
-linkmb:modbus_rtu_get_rts_delay[3]
-
-
-AUTHORS
--------
-Jimmy Bergström <jimmy@ekontroll.com>
-
-The libmodbus documentation was written by Stéphane Raimbault
-<stephane.raimbault@gmail.com>

+ 0 - 56
doc/modbus_rtu_set_serial_mode.txt

@@ -1,56 +0,0 @@
-modbus_rtu_set_serial_mode(3)
-=============================
-
-
-NAME
-----
-modbus_rtu_set_serial_mode - set the serial mode
-
-
-SYNOPSIS
---------
-*int modbus_rtu_set_serial_mode(modbus_t *'ctx', int 'mode');*
-
-
-DESCRIPTION
------------
-The *modbus_rtu_set_serial_mode()* function shall set the selected serial
-mode:
-
-*MODBUS_RTU_RS232*:: the serial line is set for RS232 communication. RS-232
- (Recommended Standard 232) is the traditional name for a series of standards
- for serial binary single-ended data and control signals connecting between a
- DTE (Data Terminal Equipment) and a DCE (Data Circuit-terminating
- Equipment). It is commonly used in computer serial ports
-
-*MODBUS_RTU_RS485*:: the serial line is set for RS485 communication. EIA-485,
- also known as TIA/EIA-485 or RS-485, is a standard defining the electrical
- characteristics of drivers and receivers for use in balanced digital multipoint
- systems. This standard is widely used for communications in industrial
- automation because it can be used effectively over long distances and in
- electrically noisy environments.
-
-This function is only supported on Linux kernels 2.6.28 onwards.
-
-
-RETURN VALUE
-------------
-The function shall return 0 if successful. Otherwise it shall return -1 and set
-errno to one of the values defined below.
-
-
-ERRORS
-------
-*EINVAL*::
-The current libmodbus backend is not RTU.
-
-*ENOTSUP*::
-The function is not supported on your platform.
-
-If the call to ioctl() fails, the error code of ioctl will be returned.
-
-
-AUTHORS
--------
-The libmodbus documentation was written by Stéphane Raimbault
-<stephane.raimbault@gmail.com>

+ 0 - 36
doc/modbus_set_bits_from_byte.txt

@@ -1,36 +0,0 @@
-modbus_set_bits_from_byte(3)
-============================
-
-
-NAME
-----
-modbus_set_bits_from_byte - set many bits from a single byte value
-
-
-SYNOPSIS
---------
-*void modbus_set_bits_from_byte(uint8_t *'dest', int 'index', const uint8_t 'value');*
-
-
-DESCRIPTION
------------
-The *modbus_set_bits_from_byte()* function shall set many bits from a single byte.
-All 8 bits from the byte _value_ will be written to _dest_ array starting at
-_index_ position.
-
-
-RETURN VALUE
-------------
-There is no return values.
-
-
-SEE ALSO
---------
-linkmb:modbus_set_bits_from_byte[3]
-linkmb:modbus_set_bits_from_bytes[3]
-
-
-AUTHORS
--------
-The libmodbus documentation was written by Stéphane Raimbault
-<stephane.raimbault@gmail.com>

+ 0 - 36
doc/modbus_set_bits_from_bytes.txt

@@ -1,36 +0,0 @@
-modbus_set_bits_from_bytes(3)
-============================
-
-
-NAME
-----
-modbus_set_bits_from_bytes - set many bits from an array of bytes
-
-
-SYNOPSIS
---------
-*void modbus_set_bits_from_bytes(uint8_t *'dest', int 'index', unsigned int 'nb_bits', const uint8_t *'tab_byte');*
-
-
-DESCRIPTION
------------
-The *modbus_set_bits_from_bytes* function shall set bits by reading an array of
-bytes. All the bits of the bytes read from the first position of the array
-_tab_byte_ are written as bits in the _dest_ array starting at position _index_.
-
-
-RETURN VALUE
-------------
-There is no return values.
-
-
-SEE ALSO
---------
-linkmb:modbus_set_bits_from_byte[3]
-linkmb:modbus_get_byte_from_bits[3]
-
-
-AUTHORS
--------
-The libmodbus documentation was written by Stéphane Raimbault
-<stephane.raimbault@gmail.com>

+ 0 - 36
doc/modbus_set_float.txt

@@ -1,36 +0,0 @@
-modbus_set_float(3)
-===================
-
-NAME
-----
-modbus_set_float - set a float value from 2 registers
-
-
-SYNOPSIS
---------
-*void modbus_set_float(float 'f', uint16_t *'dest');*
-
-Warning, this function is *deprecated* since libmodbus v3.2.0 and has been
-replaced by *modbus_set_float_dcba()*.
-
-DESCRIPTION
------------
-The *modbus_set_float()* function shall set a float to 4 bytes in Modbus format
-(ABCD). The _dest_ array must be pointer on two 16 bits values to be able to
-store the full result of the conversion.
-
-
-RETURN VALUE
-------------
-There is no return values.
-
-
-SEE ALSO
---------
-linkmb:modbus_get_float[3]
-linkmb:modbus_set_float_dcba[3]
-
-AUTHORS
--------
-The libmodbus documentation was written by Stéphane Raimbault
-<stephane.raimbault@gmail.com>

+ 0 - 38
doc/modbus_set_float_abcd.txt

@@ -1,38 +0,0 @@
-modbus_set_float_abcd(3)
-========================
-
-
-NAME
-----
-modbus_set_float_abcd - set a float value in 2 registers using ABCD byte order
-
-
-SYNOPSIS
---------
-*void modbus_set_float_abcd(float 'f', uint16_t *'dest');*
-
-
-DESCRIPTION
------------
-The *modbus_set_float_abcd()* function shall set a float to 4 bytes in usual
-Modbus format. The _dest_ array must be pointer on two 16 bits values to be able
-to store the full result of the conversion.
-
-
-RETURN VALUE
-------------
-There is no return values.
-
-
-SEE ALSO
---------
-linkmb:modbus_get_float_abcd[3]
-linkmb:modbus_set_float_badc[3]
-linkmb:modbus_set_float_cdab[3]
-linkmb:modbus_set_float_dcba[3]
-
-
-AUTHORS
--------
-The libmodbus documentation was written by Stéphane Raimbault
-<stephane.raimbault@gmail.com>

+ 0 - 38
doc/modbus_set_float_badc.txt

@@ -1,38 +0,0 @@
-modbus_set_float_badc(3)
-========================
-
-
-NAME
-----
-modbus_set_float_badc - set a float value in 2 registers using BADC byte order
-
-
-SYNOPSIS
---------
-*void modbus_set_float_badc(float 'f', uint16_t *'dest');*
-
-
-DESCRIPTION
------------
-The *modbus_set_float_badc()* function shall set a float to 4 bytes in swapped
-bytes Modbus format (BADC instead of ABCD). The _dest_ array must be pointer on
-two 16 bits values to be able to store the full result of the conversion.
-
-
-RETURN VALUE
-------------
-There is no return values.
-
-
-SEE ALSO
---------
-linkmb:modbus_get_float_badc[3]
-linkmb:modbus_set_float_abcd[3]
-linkmb:modbus_set_float_cdab[3]
-linkmb:modbus_set_float_dcba[3]
-
-
-AUTHORS
--------
-The libmodbus documentation was written by Stéphane Raimbault
-<stephane.raimbault@gmail.com>

+ 0 - 39
doc/modbus_set_float_cdab.txt

@@ -1,39 +0,0 @@
-modbus_set_float_cdab(3)
-========================
-
-
-NAME
-----
-modbus_set_float_cdab - set a float value in 2 registers using CDAB byte order
-
-
-SYNOPSIS
---------
-*void modbus_set_float_cdab(float 'f', uint16_t *'dest');*
-
-
-DESCRIPTION
------------
-The *modbus_set_float_cdab()* function shall set a float to 4 bytes in swapped
-words Modbus format (CDAB order instead of ABCD). The _dest_ array must be
-pointer on two 16 bits values to be able to store the full result of the
-conversion.
-
-
-RETURN VALUE
-------------
-There is no return values.
-
-
-SEE ALSO
---------
-linkmb:modbus_get_float_cdab[3]
-linkmb:modbus_set_float_abcd[3]
-linkmb:modbus_set_float_badc[3]
-linkmb:modbus_set_float_dcba[3]
-
-
-AUTHORS
--------
-The libmodbus documentation was written by Stéphane Raimbault
-<stephane.raimbault@gmail.com>

+ 0 - 37
doc/modbus_set_float_dcba.txt

@@ -1,37 +0,0 @@
-modbus_set_float_dcba(3)
-========================
-
-
-NAME
-----
-modbus_set_float_dcba - set a float value in 2 registers using DCBA byte order
-
-
-SYNOPSIS
---------
-*void modbus_set_float_dcba(float 'f', uint16_t *'dest');*
-
-
-DESCRIPTION
------------
-The *modbus_set_float_dcba()* function shall set a float to 4 bytes in inverted
-Modbus format (DCBA order). The _dest_ array must be pointer on two 16 bits
-values to be able to store the full result of the conversion.
-
-
-RETURN VALUE
-------------
-There is no return values.
-
-
-SEE ALSO
---------
-linkmb:modbus_get_float_dcba[3]
-linkmb:modbus_set_float[3]
-linkmb:modbus_get_float[3]
-
-
-AUTHORS
--------
-The libmodbus documentation was written by Stéphane Raimbault
-<stephane.raimbault@gmail.com>

+ 0 - 48
doc/modbus_set_indication_timeout.txt

@@ -1,48 +0,0 @@
-modbus_set_indication_timeout(3)
-================================
-
-
-NAME
-----
-modbus_set_indication_timeout - set timeout between indications
-
-
-SYNOPSIS
---------
-*void modbus_set_indication_timeout(modbus_t *'ctx', uint32_t 'to_sec', uint32_t 'to_usec');*
-
-
-DESCRIPTION
------------
-The *modbus_set_indication_timeout()* function shall set the timeout interval used by
-a server to wait for a request from a client.
-
-The value of _to_usec_ argument must be in the range 0 to 999999.
-
-If both _to_sec_ and _to_usec_ are zero, this timeout will not be used at all.
-In this case, the server will wait forever.
-
-
-RETURN VALUE
-------------
-The function shall return 0 if successful. Otherwise it shall return -1 and set
-errno.
-
-
-ERRORS
-------
-*EINVAL*::
-The argument _ctx_ is NULL or _to_usec_ is larger than 1000000.
-
-
-SEE ALSO
---------
-linkmb:modbus_get_indication_timeout[3]
-linkmb:modbus_get_response_timeout[3]
-linkmb:modbus_set_response_timeout[3]
-
-
-AUTHORS
--------
-The libmodbus documentation was written by Stéphane Raimbault
-<stephane.raimbault@gmail.com>

+ 0 - 51
doc/modbus_write_and_read_registers.txt

@@ -1,51 +0,0 @@
-modbus_write_and_read_registers(3)
-==================================
-
-
-NAME
-----
-modbus_write_and_read_registers - write and read many registers in a single transaction
-
-
-SYNOPSIS
---------
-*int modbus_write_and_read_registers(modbus_t *'ctx', int 'write_addr', int 'write_nb', const uint16_t *'src', int 'read_addr', int 'read_nb', const uint16_t *'dest');*
-
-
-DESCRIPTION
------------
-The *modbus_write_and_read_registers()* function shall write the content of the
-_write_nb_ holding registers from the array 'src' to the address _write_addr_ of
-the remote device then shall read the content of the _read_nb_ holding registers
-to the address _read_addr_ of the remote device. The result of reading is stored
-in _dest_ array as word values (16 bits).
-
-You must take care to allocate enough memory to store the results in _dest_
-(at least _nb_ * sizeof(uint16_t)).
-
-The function uses the Modbus function code 0x17 (write/read registers).
-
-
-RETURN VALUE
-------------
-The function shall return the number of read registers if successful. Otherwise
-it shall return -1 and set errno.
-
-
-ERRORS
-------
-*EMBMDATA*::
-Too many registers requested, Too many registers to write
-
-
-SEE ALSO
---------
-linkmb:modbus_read_registers[3]
-linkmb:modbus_write_register[3]
-linkmb:modbus_write_registers[3]
-
-
-AUTHORS
--------
-The libmodbus documentation was written by Stéphane Raimbault
-<stephane.raimbault@gmail.com>

+ 0 - 38
doc/modbus_write_bit.txt

@@ -1,38 +0,0 @@
-modbus_write_bit(3)
-===================
-
-
-NAME
-----
-modbus_write_bit - write a single bit
-
-
-SYNOPSIS
---------
-*int modbus_write_bit(modbus_t *'ctx', int 'addr', int 'status');*
-
-
-DESCRIPTION
------------
-The *modbus_write_bit()* function shall write the status of _status_ at the
-address _addr_ of the remote device. The value must be set to `TRUE` or `FALSE`.
-
-The function uses the Modbus function code 0x05 (force single coil).
-
-
-RETURN VALUE
-------------
-The function shall return 1 if successful. Otherwise it shall return -1 and set
-errno.
-
-
-SEE ALSO
---------
-linkmb:modbus_read_bits[3]
-linkmb:modbus_write_bits[3]
-
-
-AUTHORS
--------
-The libmodbus documentation was written by Stéphane Raimbault
-<stephane.raimbault@gmail.com>

+ 0 - 45
doc/modbus_write_bits.txt

@@ -1,45 +0,0 @@
-modbus_write_bits(3)
-====================
-
-
-NAME
-----
-modbus_write_bits - write many bits
-
-
-SYNOPSIS
---------
-*int modbus_write_bits(modbus_t *'ctx', int 'addr', int 'nb', const uint8_t *'src');*
-
-
-DESCRIPTION
------------
-The *modbus_write_bits()* function shall write the status of the _nb_ bits
-(coils) from _src_ at the address _addr_ of the remote device. The
-_src_ array must contains bytes set to `TRUE` or `FALSE`.
-
-The function uses the Modbus function code 0x0F (force multiple coils).
-
-
-RETURN VALUE
-------------
-The function shall return the number of written bits if successful. Otherwise it
-shall return -1 and set errno.
-
-
-ERRORS
-------
-*EMBMDATA*::
-Writing too many bits
-
-
-SEE ALSO
---------
-linkmb:modbus_read_bits[3]
-linkmb:modbus_write_bit[3]
-
-
-AUTHORS
--------
-The libmodbus documentation was written by Stéphane Raimbault
-<stephane.raimbault@gmail.com>

+ 0 - 38
doc/modbus_write_register.txt

@@ -1,38 +0,0 @@
-modbus_write_register(3)
-========================
-
-
-NAME
-----
-modbus_write_register - write a single register
-
-
-SYNOPSIS
---------
-*int modbus_write_register(modbus_t *'ctx', int 'addr', const uint16_t 'value');*
-
-
-DESCRIPTION
------------
-The *modbus_write_register()* function shall write the value of _value_
-holding registers at the address _addr_ of the remote device.
-
-The function uses the Modbus function code 0x06 (preset single register).
-
-
-RETURN VALUE
-------------
-The function shall return 1 if successful. Otherwise it shall return -1 and set
-errno.
-
-
-SEE ALSO
---------
-linkmb:modbus_read_registers[3]
-linkmb:modbus_write_registers[3]
-
-
-AUTHORS
--------
-The libmodbus documentation was written by Stéphane Raimbault
-<stephane.raimbault@gmail.com>

+ 0 - 38
doc/modbus_write_registers.txt

@@ -1,38 +0,0 @@
-modbus_write_registers(3)
-=========================
-
-
-NAME
-----
-modbus_write_registers - write many registers
-
-
-SYNOPSIS
---------
-*int modbus_write_registers(modbus_t *'ctx', int 'addr', int 'nb', const uint16_t *'src');*
-
-
-DESCRIPTION
------------
-The *modbus_write_registers()* function shall write the content of the _nb_
-holding registers from the array _src_ at address _addr_ of the remote device.
-
-The function uses the Modbus function code 0x10 (preset multiple registers).
-
-
-RETURN VALUE
-------------
-The function shall return the number of written registers if
-successful. Otherwise it shall return -1 and set errno.
-
-
-SEE ALSO
---------
-linkmb:modbus_write_register[3]
-linkmb:modbus_read_registers[3]
-
-
-AUTHORS
--------
-The libmodbus documentation was written by Stéphane Raimbault
-<stephane.raimbault@gmail.com>

+ 606 - 0
docs/assets/client-sensors.excalidraw

@@ -0,0 +1,606 @@
+{
+  "type": "excalidraw",
+  "version": 2,
+  "source": "https://excalidraw.com",
+  "elements": [
+    {
+      "type": "rectangle",
+      "version": 473,
+      "versionNonce": 1256506895,
+      "isDeleted": false,
+      "id": "ox1Blt2bzl0onmQfB7ZAN",
+      "fillStyle": "hachure",
+      "strokeWidth": 1,
+      "strokeStyle": "solid",
+      "roughness": 1,
+      "opacity": 100,
+      "angle": 0,
+      "x": 827.69921875,
+      "y": 210.68359375,
+      "strokeColor": "#000000",
+      "backgroundColor": "transparent",
+      "width": 251.7109375,
+      "height": 259.47265625,
+      "seed": 1508024704,
+      "groupIds": [],
+      "strokeSharpness": "sharp",
+      "boundElements": [
+        {
+          "id": "sE5xq9Fz5VDTWcJGhJizg",
+          "type": "arrow"
+        },
+        {
+          "id": "HZoAI_wR8CyRR9fVaFwSl",
+          "type": "arrow"
+        }
+      ],
+      "updated": 1660298248381,
+      "link": null,
+      "locked": false
+    },
+    {
+      "type": "text",
+      "version": 585,
+      "versionNonce": 720617423,
+      "isDeleted": false,
+      "id": "rjHz2X8U0ZDEyckj_tTSw",
+      "fillStyle": "hachure",
+      "strokeWidth": 1,
+      "strokeStyle": "solid",
+      "roughness": 1,
+      "opacity": 100,
+      "angle": 0,
+      "x": 854.0546875,
+      "y": 287.16015625,
+      "strokeColor": "#000000",
+      "backgroundColor": "transparent",
+      "width": 199,
+      "height": 160,
+      "seed": 2100367744,
+      "groupIds": [],
+      "strokeSharpness": "sharp",
+      "boundElements": [
+        {
+          "id": "vJNRjoY0dZcqOBw5RzuHn",
+          "type": "arrow"
+        }
+      ],
+      "updated": 1660298281789,
+      "link": null,
+      "locked": false,
+      "fontSize": 16,
+      "fontFamily": 1,
+      "text": "Reads temperatures\nfrom various\nModbus sensors (servers)\n\nS1: read index 0 -> 28\nS2: read index 0 -> 26\n...\n",
+      "baseline": 154,
+      "textAlign": "left",
+      "verticalAlign": "top",
+      "containerId": null,
+      "originalText": "Reads temperatures\nfrom various\nModbus sensors (servers)\n\nS1: read index 0 -> 28\nS2: read index 0 -> 26\n...\n"
+    },
+    {
+      "type": "rectangle",
+      "version": 534,
+      "versionNonce": 2127380463,
+      "isDeleted": false,
+      "id": "mDgu1gSg34HbU-NAHPB30",
+      "fillStyle": "hachure",
+      "strokeWidth": 1,
+      "strokeStyle": "solid",
+      "roughness": 1,
+      "opacity": 100,
+      "angle": 0,
+      "x": 420.2109375,
+      "y": 212.580078125,
+      "strokeColor": "#000000",
+      "backgroundColor": "transparent",
+      "width": 216.16406250000006,
+      "height": 172.06640624999997,
+      "seed": 1336837760,
+      "groupIds": [],
+      "strokeSharpness": "sharp",
+      "boundElements": [
+        {
+          "id": "sE5xq9Fz5VDTWcJGhJizg",
+          "type": "arrow"
+        }
+      ],
+      "updated": 1660298020282,
+      "link": null,
+      "locked": false
+    },
+    {
+      "type": "text",
+      "version": 653,
+      "versionNonce": 2127484513,
+      "isDeleted": false,
+      "id": "UxvTnld8qh188IzV4uJ2q",
+      "fillStyle": "hachure",
+      "strokeWidth": 1,
+      "strokeStyle": "solid",
+      "roughness": 1,
+      "opacity": 100,
+      "angle": 0,
+      "x": 443.79296875,
+      "y": 286.3515625,
+      "strokeColor": "#000000",
+      "backgroundColor": "transparent",
+      "width": 178,
+      "height": 80,
+      "seed": 759374208,
+      "groupIds": [],
+      "strokeSharpness": "sharp",
+      "boundElements": [],
+      "updated": 1660298185311,
+      "link": null,
+      "locked": false,
+      "fontSize": 16,
+      "fontFamily": 1,
+      "text": "Measures temperature\nand hygrometry:\n0: 28°C\n1: 32%  ",
+      "baseline": 74,
+      "textAlign": "left",
+      "verticalAlign": "top",
+      "containerId": null,
+      "originalText": "Measures temperature\nand hygrometry:\n0: 28°C\n1: 32%  "
+    },
+    {
+      "type": "text",
+      "version": 349,
+      "versionNonce": 1469666511,
+      "isDeleted": false,
+      "id": "F6UUk6_B6uALmjxcHLYw4",
+      "fillStyle": "hachure",
+      "strokeWidth": 1,
+      "strokeStyle": "solid",
+      "roughness": 1,
+      "opacity": 100,
+      "angle": 0,
+      "x": 488.19921875,
+      "y": 237.921875,
+      "strokeColor": "#000000",
+      "backgroundColor": "transparent",
+      "width": 79,
+      "height": 25,
+      "seed": 354006656,
+      "groupIds": [],
+      "strokeSharpness": "sharp",
+      "boundElements": [],
+      "updated": 1660298032950,
+      "link": null,
+      "locked": false,
+      "fontSize": 20,
+      "fontFamily": 1,
+      "text": "Sensor 1",
+      "baseline": 18,
+      "textAlign": "left",
+      "verticalAlign": "top",
+      "containerId": null,
+      "originalText": "Sensor 1"
+    },
+    {
+      "type": "text",
+      "version": 224,
+      "versionNonce": 864770191,
+      "isDeleted": false,
+      "id": "v7q2uvVFHZBvjr-y_ZJKl",
+      "fillStyle": "hachure",
+      "strokeWidth": 1,
+      "strokeStyle": "solid",
+      "roughness": 1,
+      "opacity": 100,
+      "angle": 0,
+      "x": 884.5546875,
+      "y": 238.328125,
+      "strokeColor": "#000000",
+      "backgroundColor": "transparent",
+      "width": 150,
+      "height": 25,
+      "seed": 2108436864,
+      "groupIds": [],
+      "strokeSharpness": "sharp",
+      "boundElements": [],
+      "updated": 1660299132232,
+      "link": null,
+      "locked": false,
+      "fontSize": 20,
+      "fontFamily": 1,
+      "text": "libmodbus client",
+      "baseline": 18,
+      "textAlign": "left",
+      "verticalAlign": "top",
+      "containerId": null,
+      "originalText": "libmodbus client"
+    },
+    {
+      "type": "arrow",
+      "version": 925,
+      "versionNonce": 27208751,
+      "isDeleted": false,
+      "id": "sE5xq9Fz5VDTWcJGhJizg",
+      "fillStyle": "hachure",
+      "strokeWidth": 1,
+      "strokeStyle": "solid",
+      "roughness": 1,
+      "opacity": 100,
+      "angle": 0,
+      "x": 656.03125,
+      "y": 313.29799967005374,
+      "strokeColor": "#000000",
+      "backgroundColor": "transparent",
+      "width": 154.05078125,
+      "height": 8.294130761394001,
+      "seed": 455209344,
+      "groupIds": [],
+      "strokeSharpness": "round",
+      "boundElements": [],
+      "updated": 1660298248381,
+      "link": null,
+      "locked": false,
+      "startBinding": {
+        "elementId": "mDgu1gSg34HbU-NAHPB30",
+        "focus": 0.08648410639065775,
+        "gap": 19.65625
+      },
+      "endBinding": {
+        "elementId": "ox1Blt2bzl0onmQfB7ZAN",
+        "focus": 0.08133464876815498,
+        "gap": 17.6171875
+      },
+      "lastCommittedPoint": null,
+      "startArrowhead": null,
+      "endArrowhead": "arrow",
+      "points": [
+        [
+          0,
+          0
+        ],
+        [
+          154.05078125,
+          8.294130761394001
+        ]
+      ]
+    },
+    {
+      "type": "text",
+      "version": 709,
+      "versionNonce": 650449167,
+      "isDeleted": false,
+      "id": "Q6P32mRyop5JlKGPB3tei",
+      "fillStyle": "hachure",
+      "strokeWidth": 1,
+      "strokeStyle": "solid",
+      "roughness": 1,
+      "opacity": 100,
+      "angle": 5.552321937284518,
+      "x": 679.345703125,
+      "y": 433.1444738051471,
+      "strokeColor": "#000000",
+      "backgroundColor": "transparent",
+      "width": 79,
+      "height": 15,
+      "seed": 1091054019,
+      "groupIds": [],
+      "strokeSharpness": "sharp",
+      "boundElements": [],
+      "updated": 1660298261423,
+      "link": null,
+      "locked": false,
+      "fontSize": 11.542968749999993,
+      "fontFamily": 1,
+      "text": "TCP or serial",
+      "baseline": 10,
+      "textAlign": "left",
+      "verticalAlign": "top",
+      "containerId": null,
+      "originalText": "TCP or serial"
+    },
+    {
+      "type": "text",
+      "version": 707,
+      "versionNonce": 1999616833,
+      "isDeleted": false,
+      "id": "vETmEnYJoC4MKv7ysqjAv",
+      "fillStyle": "hachure",
+      "strokeWidth": 1,
+      "strokeStyle": "solid",
+      "roughness": 1,
+      "opacity": 100,
+      "angle": 0.06779103263247777,
+      "x": 683.3417968749999,
+      "y": 281.21582031250006,
+      "strokeColor": "#000000",
+      "backgroundColor": "transparent",
+      "width": 79,
+      "height": 15,
+      "seed": 1043479501,
+      "groupIds": [],
+      "strokeSharpness": "sharp",
+      "boundElements": [],
+      "updated": 1660298255264,
+      "link": null,
+      "locked": false,
+      "fontSize": 11.542968749999993,
+      "fontFamily": 1,
+      "text": "TCP or serial",
+      "baseline": 10,
+      "textAlign": "left",
+      "verticalAlign": "top",
+      "containerId": null,
+      "originalText": "TCP or serial"
+    },
+    {
+      "type": "rectangle",
+      "version": 587,
+      "versionNonce": 85990017,
+      "isDeleted": false,
+      "id": "pHhCP3DIU5fE4v3yi3obG",
+      "fillStyle": "hachure",
+      "strokeWidth": 1,
+      "strokeStyle": "solid",
+      "roughness": 1,
+      "opacity": 100,
+      "angle": 0,
+      "x": 426.513671875,
+      "y": 424.2646484375,
+      "strokeColor": "#000000",
+      "backgroundColor": "transparent",
+      "width": 216.16406250000006,
+      "height": 172.06640624999997,
+      "seed": 1733016847,
+      "groupIds": [],
+      "strokeSharpness": "sharp",
+      "boundElements": [
+        {
+          "id": "sE5xq9Fz5VDTWcJGhJizg",
+          "type": "arrow"
+        },
+        {
+          "id": "HZoAI_wR8CyRR9fVaFwSl",
+          "type": "arrow"
+        }
+      ],
+      "updated": 1660298157321,
+      "link": null,
+      "locked": false
+    },
+    {
+      "type": "text",
+      "version": 708,
+      "versionNonce": 1824105825,
+      "isDeleted": false,
+      "id": "3oXICnKHoOzNPyb-PxNbt",
+      "fillStyle": "hachure",
+      "strokeWidth": 1,
+      "strokeStyle": "solid",
+      "roughness": 1,
+      "opacity": 100,
+      "angle": 0,
+      "x": 450.095703125,
+      "y": 498.0361328125,
+      "strokeColor": "#000000",
+      "backgroundColor": "transparent",
+      "width": 178,
+      "height": 80,
+      "seed": 1378197345,
+      "groupIds": [],
+      "strokeSharpness": "sharp",
+      "boundElements": [],
+      "updated": 1660298208836,
+      "link": null,
+      "locked": false,
+      "fontSize": 16,
+      "fontFamily": 1,
+      "text": "Measures temperature\nand hygrometry:\n0: 26°C\n1: 40%  ",
+      "baseline": 74,
+      "textAlign": "left",
+      "verticalAlign": "top",
+      "containerId": null,
+      "originalText": "Measures temperature\nand hygrometry:\n0: 26°C\n1: 40%  "
+    },
+    {
+      "type": "text",
+      "version": 400,
+      "versionNonce": 747588289,
+      "isDeleted": false,
+      "id": "rD_cbOE0Mwz-sfB0YqcaJ",
+      "fillStyle": "hachure",
+      "strokeWidth": 1,
+      "strokeStyle": "solid",
+      "roughness": 1,
+      "opacity": 100,
+      "angle": 0,
+      "x": 494.501953125,
+      "y": 449.6064453125,
+      "strokeColor": "#000000",
+      "backgroundColor": "transparent",
+      "width": 88,
+      "height": 25,
+      "seed": 68109103,
+      "groupIds": [],
+      "strokeSharpness": "sharp",
+      "boundElements": [],
+      "updated": 1660298172011,
+      "link": null,
+      "locked": false,
+      "fontSize": 20,
+      "fontFamily": 1,
+      "text": "Sensor 2",
+      "baseline": 18,
+      "textAlign": "left",
+      "verticalAlign": "top",
+      "containerId": null,
+      "originalText": "Sensor 2"
+    },
+    {
+      "type": "arrow",
+      "version": 1150,
+      "versionNonce": 1550306895,
+      "isDeleted": false,
+      "id": "HZoAI_wR8CyRR9fVaFwSl",
+      "fillStyle": "hachure",
+      "strokeWidth": 1,
+      "strokeStyle": "solid",
+      "roughness": 1,
+      "opacity": 100,
+      "angle": 0,
+      "x": 666.49609375,
+      "y": 532.2655116636315,
+      "strokeColor": "#000000",
+      "backgroundColor": "transparent",
+      "width": 145.8515625,
+      "height": 133.46442554799017,
+      "seed": 1409289601,
+      "groupIds": [],
+      "strokeSharpness": "round",
+      "boundElements": [],
+      "updated": 1660298248381,
+      "link": null,
+      "locked": false,
+      "startBinding": {
+        "elementId": "pHhCP3DIU5fE4v3yi3obG",
+        "focus": 0.7718436212944663,
+        "gap": 23.818359375
+      },
+      "endBinding": {
+        "elementId": "ox1Blt2bzl0onmQfB7ZAN",
+        "focus": 0.28922965891088237,
+        "gap": 15.3515625
+      },
+      "lastCommittedPoint": null,
+      "startArrowhead": null,
+      "endArrowhead": "arrow",
+      "points": [
+        [
+          0,
+          0
+        ],
+        [
+          145.8515625,
+          -133.46442554799017
+        ]
+      ]
+    },
+    {
+      "id": "feq5Rn2_gEHIfIzRPvNu6",
+      "type": "rectangle",
+      "x": 832.283203125,
+      "y": 515.0556640625,
+      "width": 255,
+      "height": 76.1171875,
+      "angle": 0,
+      "strokeColor": "#000000",
+      "backgroundColor": "transparent",
+      "fillStyle": "hachure",
+      "strokeWidth": 1,
+      "strokeStyle": "solid",
+      "roughness": 1,
+      "opacity": 100,
+      "groupIds": [],
+      "strokeSharpness": "sharp",
+      "seed": 826152751,
+      "version": 65,
+      "versionNonce": 19459567,
+      "isDeleted": false,
+      "boundElements": [
+        {
+          "type": "text",
+          "id": "n4_rv3VhjyMXLSFrP52Vw"
+        },
+        {
+          "id": "vJNRjoY0dZcqOBw5RzuHn",
+          "type": "arrow"
+        }
+      ],
+      "updated": 1660298281790,
+      "link": null,
+      "locked": false
+    },
+    {
+      "id": "n4_rv3VhjyMXLSFrP52Vw",
+      "type": "text",
+      "x": 837.283203125,
+      "y": 540.6142578125,
+      "width": 245,
+      "height": 25,
+      "angle": 0,
+      "strokeColor": "#000000",
+      "backgroundColor": "transparent",
+      "fillStyle": "hachure",
+      "strokeWidth": 1,
+      "strokeStyle": "solid",
+      "roughness": 1,
+      "opacity": 100,
+      "groupIds": [],
+      "strokeSharpness": "sharp",
+      "seed": 555916079,
+      "version": 20,
+      "versionNonce": 1538604143,
+      "isDeleted": false,
+      "boundElements": null,
+      "updated": 1660298276528,
+      "link": null,
+      "locked": false,
+      "text": "Database or logs",
+      "fontSize": 20,
+      "fontFamily": 1,
+      "textAlign": "center",
+      "verticalAlign": "middle",
+      "baseline": 18,
+      "containerId": "feq5Rn2_gEHIfIzRPvNu6",
+      "originalText": "Database or logs"
+    },
+    {
+      "id": "vJNRjoY0dZcqOBw5RzuHn",
+      "type": "arrow",
+      "x": 958.509765625,
+      "y": 472.4150390625,
+      "width": 0,
+      "height": 39.33984375,
+      "angle": 0,
+      "strokeColor": "#000000",
+      "backgroundColor": "transparent",
+      "fillStyle": "hachure",
+      "strokeWidth": 1,
+      "strokeStyle": "solid",
+      "roughness": 1,
+      "opacity": 100,
+      "groupIds": [],
+      "strokeSharpness": "round",
+      "seed": 1036508641,
+      "version": 20,
+      "versionNonce": 2130978977,
+      "isDeleted": false,
+      "boundElements": null,
+      "updated": 1660298281790,
+      "link": null,
+      "locked": false,
+      "points": [
+        [
+          0,
+          0
+        ],
+        [
+          0,
+          39.33984375
+        ]
+      ],
+      "lastCommittedPoint": null,
+      "startBinding": {
+        "elementId": "rjHz2X8U0ZDEyckj_tTSw",
+        "focus": -0.04979978015075378,
+        "gap": 25.2548828125
+      },
+      "endBinding": {
+        "elementId": "feq5Rn2_gEHIfIzRPvNu6",
+        "focus": -0.009987745098039217,
+        "gap": 3.30078125
+      },
+      "startArrowhead": null,
+      "endArrowhead": "arrow"
+    }
+  ],
+  "appState": {
+    "gridSize": null,
+    "viewBackgroundColor": "#ffffff"
+  },
+  "files": {}
+}

BIN
docs/assets/client-sensors.webp


Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 483 - 0
docs/assets/server-grafana.excalidraw


BIN
docs/assets/server-grafana.webp


+ 263 - 0
docs/index.md

@@ -0,0 +1,263 @@
+# libmodbus
+
+A featureful and portable Open Source Modbus library.
+
+## Description
+
+libmodbus is a library to send/receive data with a device which respects the
+Modbus protocol. This library contains various backends to communicate over
+different networks (eg. serial in RTU mode or Ethernet in TCP IPv4/IPv6). The
+<http://www.modbus.org> site provides documentation about the [Modbus
+Specifications and Implementation Guides](http://www.modbus.org/specs.php).
+
+libmodbus provides an abstraction of the lower communication layers and offers
+the same API on all supported platforms.
+
+This documentation presents an overview of libmodbus concepts, describes how
+libmodbus abstracts Modbus communication with different hardware and platforms
+and provides a reference manual for the functions provided by the libmodbus
+library.
+
+## Use cases
+
+The library can be used to write a:
+
+- **client**, the application reads/writes data from various devices.
+- **server**, the application provides data to several clients.
+
+<figure markdown>
+  <img src="assets/client-sensors.webp" width="512">
+  <figcaption>A libmodbus client that reads only the temperatures from sensors.</figcaption>
+</figure>
+
+<figure markdown>
+  <img src="assets/server-grafana.webp" width="512">
+  <figcaption>A libmodbus server that exposes data to a Grafana service.</figcaption>
+</figure>
+
+## Contexts
+
+The Modbus protocol supports several transport protocols (eg. serial RTU,
+Ethernet TCP) called backends in *libmodbus*.
+
+The first step is to allocate and set a `modbus_t` context according to the
+required backend (RTU or TCP) with a dedicated function, such as
+[modbus_new_rtu](modbus_new_rtu).
+The function will return an opaque structure called `modbus_t` containing all
+necessary information to establish a connection with other Modbus devices
+according to the selected backend.
+
+Once this context has been created, you can use use the common API provided by
+*libmodbus* to read/write or set the various timeouts. With this common API,
+it's easy to switch the backend of your application from RTU to TCP IPv6 for
+example.
+
+### RTU Context
+
+The RTU backend (Remote Terminal Unit) is used in serial communication and makes
+use of a compact, binary representation of the data for protocol communication.
+The RTU format follows the commands/data with a cyclic redundancy check checksum
+as an error check mechanism to ensure the reliability of data. Modbus RTU is the
+most common implementation available for Modbus. A Modbus RTU message must be
+transmitted continuously without inter-character hesitations (extract from
+Wikipedia, [Modbus](http://en.wikipedia.org/wiki/Modbus) as of Mar. 13, 2011,
+20:51 GMT).
+
+The Modbus RTU framing calls a slave, a device/service which handle Modbus
+requests, and a master, a client which send requests. The communication is
+always initiated by the master.
+
+Many Modbus devices can be connected together on the same physical link so
+before sending a message, you must set the slave (receiver) with
+[modbus_set_slave](mobus_set_slave). If you're running a slave, its slave number
+will be used to filter received messages.
+
+The libmodbus implementation of RTU isn't time based as stated in original
+Modbus specification, instead all bytes are sent as fast as possible and a
+response or an indication is considered complete when all expected characters
+have been received. This implementation offers very fast communication but you
+must take care to set a response timeout of slaves less than response timeout of
+master (ortherwise other slaves may ignore master requests when one of the slave
+is not responding).
+
+To create a Modbus RTU context, you should use [modbus_new_rtu](modbus_new_rtu).
+
+You can tweak the serial mode with the following functions:
+
+- [modbus_rtu_get_serial_mode](modbus_rtu_get_serial_mode)
+- [modbus_rtu_set_serial_mode](modbus_rtu_set_serial_mode)
+- [modbus_rtu_get_rts](modbus_rtu_get_rts)
+- [modbus_rtu_set_rts](modbus_rtu_set_rts)
+- [modbus_rtu_set_custom_rts](modbus_rtu_set_custom_rts)
+- [modbus_rtu_get_rts_delay](modbus_rtu_get_rts_delay)
+- [modbus_rtu_set_rts_delay](modbus_rtu_set_rts_delay)
+
+### TCP (IPv4) Context
+
+The TCP backend implements a Modbus variant used for communications over
+TCP/IPv4 networks. It does not require a checksum calculation as lower layer
+takes care of the same.
+
+To create a Modbus TCP context, you should use [modbus_new_tcp](modbus_new_tcp).
+
+### TCP PI (IPv4 and IPv6) Context
+
+The TCP PI (Protocol Independent) backend implements a Modbus variant used for
+communications over TCP IPv4 and IPv6 networks. It does not require a checksum
+calculation as lower layer takes care of the same.
+
+Contrary to the TCP IPv4 only backend, the TCP PI backend offers hostname
+resolution but it consumes about 1Kb of additional memory.
+
+Create a Modbus TCP PI context, you should use [modbus_new_tcp_pi](modbus_new_tcp_pi).
+
+## Connection
+
+The following functions are provided to establish and close a connection with
+Modbus devices:
+
+- [modbus_connect](modbus_connect) establishes a connection.
+- [modbus_close](modbus_close) closes a connection.
+- [modbus_flush](modbus_flush) flushed a connection.
+
+In RTU, you should define the slave ID of your client with
+[modbus_set_slave](modbus_set_slave).
+
+To analyse the exchanged data, you can enable the debug mode with
+[modbus_set_debug](modbus_set_debug).
+
+Once you have completed the communication or at the end of your program, you
+should free the resources with the common function, [modbus_free](modbus_free)
+
+## Reads and writes from the client
+
+The Modbus protocol defines different data types and functions to read and write
+them from/to remote devices. The following functions are used by the clients to
+send Modbus requests:
+
+To read data:
+
+- [modbus_read_bits](modbus_read_bits)
+- [modbus_read_input_bits](modbus_read_input_bits)
+- [modbus_read_registers](modbus_read_registers)
+- [modbus_read_input_registers](modbus_read_input_registers)
+- [modbus_report_slave_id](modbus_report_slave_id)
+
+To write data:
+
+- [modbus_write_bit](modbus_write_bit)
+- [modbus_write_register](modbus_write_register)
+- [modbus_write_bits](modbus_write_bits)
+- [modbus_write_registers](modbus_write_registers)
+
+To write and read data in a single operation:
+
+- [modbus_write_and_read_registers](modbus_write_and_read_registers)
+
+To send and receive low-level requests:
+
+- [modbus_send_raw_request](modbus_send_raw_request)
+- [modbus_receive_confirmation](modbus_receive_confirmation)
+
+To reply to an exception:
+
+- [modbus_reply_exception](modbus_reply_exception)
+
+## Handling requests from server
+
+The server is waiting for request from clients and must answer when it is
+concerned by the request. The libmodbus offers the following functions to
+handle requests:
+
+Data mapping:
+
+- [modbus_mapping_new](modbus_mapping_new)
+- [modbus_mapping_free](modbus_mapping_free)
+
+Receive:
+
+- [modbus_receive](modbus_receive)
+
+Reply:
+
+- [modbus_reply](modbus_reply)
+- [modbus_reply_exception](modbus_reply_exception)
+
+## Advanced functions
+
+Timeout settings:
+
+- [modbus_get_byte_timeout](modbus_get_byte_timeout)
+- [modbus_set_byte_timeout](modbus_set_byte_timeout)
+- [modbus_get_response_timeout](modbus_get_response_timeout)
+- [modbus_set_response_timeout](modbus_set_response_timeout)
+
+Error recovery mode:
+
+- [modbus_set_error_recovery](modbus_set_error_recovery)
+
+Setter/getter of internal socket:
+
+- [modbus_set_socket](modbus_set_socket)
+- [modbus_get_socket](modbus_get_socket)
+
+Information about header:
+
+- [modbus_get_header_length](modbus_get_header_length)
+
+## Data handling
+
+Macros for data manipulation:
+
+- `MODBUS_GET_HIGH_BYTE(data)`, extracts the high byte from a byte
+- `MODBUS_GET_LOW_BYTE(data)`, extracts the low byte from a byte
+- `MODBUS_GET_INT64_FROM_INT16(tab_int16, index)`, builds an int64 from the four first int16 starting at tab_int16[index]
+- `MODBUS_GET_INT32_FROM_INT16(tab_int16, index)`, builds an int32 from the two first int16 starting at tab_int16[index]
+- `MODBUS_GET_INT16_FROM_INT8(tab_int8, index)`, builds an int16 from the two first int8 starting at tab_int8[index]
+- `MODBUS_SET_INT16_TO_INT8(tab_int8, index, value)`, set an int16 value into the two first bytes starting at tab_int8[index]
+- `MODBUS_SET_INT32_TO_INT16(tab_int16, index, value)`, set an int32 value into the two first int16 starting at tab_int16[index]
+- `MODBUS_SET_INT64_TO_INT16(tab_int16, index, value)`, set an int64 value into the four first int16 starting at tab_int16[index]
+
+Handling of bits and bytes:
+
+- [modbus_set_bits_from_byte](modbus_set_bits_from_byte)
+- [modbus_set_bits_from_bytes](modbus_set_bits_from_bytes)
+- [modbus_get_byte_from_bits](modbus_get_byte_from_bits)
+
+Set or get float numbers:
+
+- [modbus_get_float_abcd](modbus_get_float_abcd)
+- [modbus_set_float_abcd](modbus_set_float_abcd)
+- [modbus_get_float_badc](modbus_get_float_badc)
+- [modbus_set_float_badc](modbus_set_float_badc)
+- [modbus_get_float_cdab](modbus_get_float_cdab)
+- [modbus_set_float_cdab](modbus_set_float_cdab)
+- [modbus_get_float_dcba](modbus_get_float_dcba)
+- [modbus_set_float_dcba](modbus_set_float_dcba)
+- [modbus_get_float](modbus_get_float) **deprecated**
+- [modbus_set_float](modbus_set_float) **deprecated**
+
+## Error handling
+
+The libmodbus functions handle errors using the standard conventions found on
+POSIX systems. Generally, this means that upon failure a libmodbus function
+shall return either a NULL value (if returning a pointer) or a negative value
+(if returning an integer), and the actual error code shall be stored in the
+`errno` variable.
+
+The *modbus_strerror()* function is provided to translate libmodbus-specific
+error codes into error message strings; for details refer to
+[modbus_strerror](modbus_strerror).
+
+## Miscellaneous
+
+The `_LIBMODBUS_VERSION_STRING_` constant indicates the libmodbus version the
+program has been compiled against. The variables 'libmodbus_version_major',
+'libmodbus_version_minor', 'libmodbus_version_micro' give the version the
+program is linked against.
+
+## Copying
+
+Free use of this software is granted under the terms of the GNU Lesser General
+Public License (LGPL v2.1+). For details see the file `COPYING.LESSER` included
+with the libmodbus distribution.

+ 13 - 24
doc/modbus_close.txt → docs/modbus_close.md

@@ -1,32 +1,27 @@
-modbus_close(3)
-===============
+# modbus_close
 
+## Name
 
-NAME
-----
 modbus_close - close a Modbus connection
 
+## Synopsis
 
-SYNOPSIS
---------
-*void modbus_close(modbus_t *'ctx');*
+```c
+void modbus_close(modbus_t *ctx);
+```
 
+## Description
 
-DESCRIPTION
------------
 The *modbus_close()* function shall close the connection established with the
 backend set in the context.
 
+## Return value
 
-RETURN VALUE
-------------
 There is no return value.
 
+## Example
 
-EXAMPLE
--------
-[source,c]
--------------------
+```c
 modbus_t *ctx;
 
 ctx = modbus_new_tcp("127.0.0.1", 502);
@@ -38,14 +33,8 @@ if (modbus_connect(ctx) == -1) {
 
 modbus_close(ctx);
 modbus_free(ctx);
--------------------
+```
 
-SEE ALSO
---------
-linkmb:modbus_connect[3]
+## See also
 
-
-AUTHORS
--------
-The libmodbus documentation was written by Stéphane Raimbault
-<stephane.raimbault@gmail.com>
+- [modbus_connect](modbus_connect)

+ 13 - 25
doc/modbus_connect.txt → docs/modbus_connect.md

@@ -1,35 +1,30 @@
-modbus_connect(3)
-=================
+# modbus_connect
 
+## Name
 
-NAME
-----
 modbus_connect - establish a Modbus connection
 
+## Synopsis
 
-SYNOPSIS
---------
-*int modbus_connect(modbus_t *'ctx');*
+```c
+int modbus_connect(modbus_t *ctx);
+```
 
+## Description
 
-DESCRIPTION
------------
 The *modbus_connect()* function shall establish a connection to a Modbus server,
 a network or a bus using the context information of libmodbus context given in
 argument.
 
+## Return value
 
-RETURN VALUE
-------------
 The function shall return 0 if successful. Otherwise it shall return -1 and set
 errno to one of the values defined by the system calls of the underlying
 platform.
 
+## Example
 
-EXAMPLE
--------
-[source,c]
--------------------
+```c
 modbus_t *ctx;
 
 ctx = modbus_new_tcp("127.0.0.1", 502);
@@ -38,15 +33,8 @@ if (modbus_connect(ctx) == -1) {
     modbus_free(ctx);
     return -1;
 }
--------------------
+```
 
+## See also
 
-SEE ALSO
---------
-linkmb:modbus_close[3]
-
-
-AUTHORS
--------
-The libmodbus documentation was written by Stéphane Raimbault
-<stephane.raimbault@gmail.com>
+- [modbus_close](modbus_close)

+ 8 - 17
doc/modbus_flush.txt → docs/modbus_flush.md

@@ -1,30 +1,21 @@
-modbus_flush(3)
-===============
+# modbus_flush
 
+## Name
 
-NAME
-----
 modbus_flush - flush non-transmitted data
 
+## Synopsis
 
-SYNOPSIS
---------
-*int modbus_flush(modbus_t *'ctx');*
+```c
+int modbus_flush(modbus_t *ctx);
+```
 
+## Description
 
-DESCRIPTION
------------
 The *modbus_flush()* function shall discard data received but not read to the
 socket or file descriptor associated to the context 'ctx'.
 
+## Return value
 
-RETURN VALUE
-------------
 The function shall return 0 or the number of flushed bytes if
 successful. Otherwise it shall return -1 and set errno.
-
-
-AUTHORS
--------
-The libmodbus documentation was written by Stéphane Raimbault
-<stephane.raimbault@gmail.com>

+ 19 - 0
docs/modbus_free.md

@@ -0,0 +1,19 @@
+# modbus_free
+
+## Name
+
+modbus_free - free a libmodbus context
+
+## Synopsis
+
+```c
+void modbus_free(modbus_t *ctx);
+```
+
+## Description
+
+The *modbus_free()* function shall free an allocated modbus_t structure.
+
+## Return value
+
+There is no return values.

+ 26 - 0
docs/modbus_get_byte_from_bits.md

@@ -0,0 +1,26 @@
+# modbus_get_byte_from_bits
+
+## Name
+
+modbus_get_byte_from_bits - get the value from many bits
+
+## Synopsis
+
+```c
+uint8_t modbus_get_byte_from_bits(const uint8_t *src, int index, unsigned int nb_bits);
+```
+
+## Description
+
+The *modbus_get_byte_from_bits()* function shall extract a value from many
+bits. All `nb_bits` bits from `src` at position `index` will be read as a
+single value. To obtain a full byte, set nb_bits to 8.
+
+## Return value
+
+The function shall return a byte containing the bits read.
+
+## See also
+
+- [modbus_set_bits_from_byte](modbus_set_bits_from_byte)
+- [modbus_set_bits_from_bytes](modbus_set_bits_from_bytes)

+ 38 - 0
docs/modbus_get_byte_timeout.md

@@ -0,0 +1,38 @@
+# modbus_get_byte_timeout
+
+## Name
+
+modbus_get_byte_timeout - get timeout between bytes
+
+## Synopsis
+
+```c
+int modbus_get_byte_timeout(modbus_t *ctx, uint32_t *to_sec, uint32_t *to_usec);
+```
+
+## Description
+
+The *modbus_get_byte_timeout()* function shall store the timeout interval
+between two consecutive bytes of the same message in the `to_sec` and `to_usec`
+arguments.
+
+## Return value
+
+The function shall return 0 if successful. Otherwise it shall return -1 and set
+errno.
+
+## Example
+
+```c
+uint32_t to_sec;
+uint32_t to_usec;
+
+/* Save original timeout */
+modbus_get_byte_timeout(ctx, &to_sec, &to_usec);
+```
+
+## See also
+
+- [modbus_set_byte_timeout](modbus_set_byte_timeout)
+- [modbus_get_response_timeout](modbus_get_response_timeout)
+- [modbus_set_response_timeout](modbus_set_response_timeout)

+ 31 - 0
docs/modbus_get_float.md

@@ -0,0 +1,31 @@
+# modbus_get_float
+
+## Name
+
+modbus_get_float - get a float value from 2 registers
+
+## Synopsis
+
+```c
+float modbus_get_float(const uint16_t *src);
+```
+
+Warning, this function is *deprecated* since libmodbus v3.2.0 and has been
+replaced by *modbus_get_float_dcba()*.
+
+## Description
+
+The *modbus_get_float()* function shall get a float from 4 bytes in Modbus
+format (DCBA byte order). The `src` array must be a pointer on two 16 bits
+values, for example, if the first word is set to 0x4465 and the second to
+0x229a, the float value will be 916.540649.
+
+## Return value
+
+The function shall return a float.
+
+## See also
+
+- [modbus_set_float](modbus_set_float)
+- [modbus_set_float_dcba](modbus_set_float_dcba)
+- [modbus_get_float_dcba](modbus_get_float_dcba)

+ 29 - 0
docs/modbus_get_float_abcd.md

@@ -0,0 +1,29 @@
+# modbus_get_float_abcd
+
+## Name
+
+modbus_get_float_abcd - get a float value from 2 registers in ABCD byte order
+
+## Synopsis
+
+```c
+float modbus_get_float_abcd(const uint16_t *src);
+```
+
+## Description
+
+The *modbus_get_float_abcd()* function shall get a float from 4 bytes in usual
+Modbus format. The `src` array must be a pointer on two 16 bits values, for
+example, if the first word is set to 0x0020 and the second to 0xF147, the float
+value will be read as 123456.0.
+
+## Return value
+
+The function shall return a float.
+
+## See also
+
+- [modbus_set_float_abcd](modbus_set_float_abcd)
+- [modbus_get_float_badc](modbus_get_float_badc)
+- [modbus_get_float_cdab](modbus_get_float_cdab)
+- [modbus_get_float_dcba](modbus_get_float_dcba)

+ 29 - 0
docs/modbus_get_float_badc.md

@@ -0,0 +1,29 @@
+# modbus_get_float_badc
+
+## Name
+
+modbus_get_float_badc - get a float value from 2 registers in BADC byte order
+
+## Synopsis
+
+```c
+float modbus_get_float_badc(const uint16_t *src);
+```
+
+## Description
+
+The *modbus_get_float_badc()* function shall get a float from 4 bytes with
+swapped bytes (BADC instead of ABCD). The `src` array must be a pointer on two
+16 bits values, for example, if the first word is set to 0x2000 and the second
+to 0x47F1, the float value will be read as 123456.0.
+
+## Return value
+
+The function shall return a float.
+
+## See also
+
+- [modbus_set_float_badc](modbus_set_float_badc)
+- [modbus_get_float_abcd](modbus_get_float_abcd)
+- [modbus_get_float_cdab](modbus_get_float_cdab)
+- [modbus_get_float_dcba](modbus_get_float_dcba)

+ 29 - 0
docs/modbus_get_float_cdab.md

@@ -0,0 +1,29 @@
+# modbus_get_float_cdab
+
+## Name
+
+modbus_get_float_cdab - get a float value from 2 registers in CDAB byte order
+
+## Synopsis
+
+```c
+float modbus_get_float_cdab(const uint16_t *src);
+```
+
+## Description
+
+The *modbus_get_float_cdab()* function shall get a float from 4 bytes with
+swapped words (CDAB order instead of ABCD). The `src` array must be a pointer on
+two 16 bits values, for example, if the first word is set to F147 and the second
+to 0x0020, the float value will be read as 123456.0.
+
+## Return value
+
+The function shall return a float.
+
+## See also
+
+- [modbus_set_float_cdab](modbus_set_float_cdab)
+- [modbus_get_float_abcd](modbus_get_float_abcd)
+- [modbus_get_float_badc](modbus_get_float_badc)
+- [modbus_get_float_dcba](modbus_get_float_dcba)

+ 29 - 0
docs/modbus_get_float_dcba.md

@@ -0,0 +1,29 @@
+# modbus_get_float_dcba
+
+## Name
+
+modbus_get_float_dcba - get a float value from 2 registers in DCBA byte order
+
+## Synopsis
+
+```c
+float modbus_get_float_dcba(const uint16_t *src);
+```
+
+## Description
+
+The *modbus_get_float_dcba()* function shall get a float from 4 bytes in
+inverted Modbus format (DCBA order instead of ABCD). The `src` array must be a
+pointer on two 16 bits values, for example, if the first word is set to 0x47F1
+and the second to 0x2000, the float value will be read as 123456.0.
+
+## Return value
+
+The function shall return a float.
+
+## See also
+
+- [modbus_set_float_dcba](modbus_set_float_dcba)
+- [modbus_get_float_abcd](modbus_get_float_abcd)
+- [modbus_get_float_badc](modbus_get_float_badc)
+- [modbus_get_float_cdab](modbus_get_float_cdab)

+ 21 - 0
docs/modbus_get_header_length.md

@@ -0,0 +1,21 @@
+# modbus_get_header_length
+
+## Name
+
+modbus_get_header_length - retrieve the current header length
+
+## Synopsis
+
+```c
+int modbus_get_header_length(modbus_t *ctx);
+```
+
+## Description
+
+The *modbus_get_header_length()* function shall retrieve the current header
+length from the backend. This function is convenient to manipulate a message and
+so its limited to low-level operations.
+
+## Return value
+
+The header length as integer value.

+ 39 - 0
docs/modbus_get_indication_timeout.md

@@ -0,0 +1,39 @@
+# modbus_get_indication_timeout
+
+## Name
+
+modbus_get_indication_timeout - get timeout used to wait for an indication (request received by a server).
+
+## Synopsis
+
+```c
+int modbus_get_indication_timeout(modbus_t *ctx, uint32_t *to_sec, uint32_t *to_usec);
+```
+
+## Description
+
+The *modbus_get_indication_timeout()* function shall store the timeout interval
+used to wait for an indication in the `to_sec` and `to_usec` arguments.
+Indication is the term used by the Modbus protocol to designate a request
+received by the server.
+
+The default value is zero, it means the server will wait forever.
+
+## Return value
+
+The function shall return 0 if successful. Otherwise it shall return -1 and set
+errno.
+
+```c
+uint32_t to_sec;
+uint32_t to_usec;
+
+/* Save original timeout */
+modbus_get_indication_timeout(ctx, &to_sec, &to_usec);
+```
+
+## See also
+
+- [modbus_set_indication_timeout](modbus_set_indication_timeout)
+- [modbus_get_response_timeout](modbus_get_response_timeout)
+- [modbus_set_response_timeout](modbus_set_response_timeout)

+ 40 - 0
docs/modbus_get_response_timeout.md

@@ -0,0 +1,40 @@
+# modbus_get_response_timeout
+
+## Name
+
+modbus_get_response_timeout - get timeout for response
+
+## Synopsis
+
+```c
+int modbus_get_response_timeout(modbus_t *ctx, uint32_t *to_sec, uint32_t *to_usec);
+```
+
+## Description
+
+The *modbus_get_response_timeout()* function shall return the timeout interval
+used to wait for a response in the `to_sec` and `to_usec` arguments.
+
+## Return value
+
+The function shall return 0 if successful. Otherwise it shall return -1 and set
+errno.
+
+Example:
+
+```c
+uint32_t old_response_to_sec;
+uint32_t old_response_to_usec;
+
+/* Save original timeout */
+modbus_get_response_timeout(ctx, &old_response_to_sec, &old_response_to_usec);
+
+/* Define a new and too short timeout! */
+modbus_set_response_timeout(ctx, 0, 0);
+```
+
+## See also
+
+- [modbus_set_response_timeout](modbus_set_response_timeout)
+- [modbus_get_byte_timeout](modbus_get_byte_timeout)
+- [modbus_set_byte_timeout](modbus_set_byte_timeout)

+ 29 - 0
docs/modbus_get_slave.md

@@ -0,0 +1,29 @@
+# modbus_get_slave
+
+## Name
+
+modbus_get_slave - get slave number in the context
+
+## Synopsis
+
+```c
+int modbus_get_slave(modbus_t *ctx);
+```
+
+## Description
+
+The *modbus_get_slave()* function shall get the slave number in the libmodbus
+context.
+
+## Return value
+
+The function shall return the slave number if successful. Otherwise it shall
+return -1 and set errno to one of the values defined below.
+
+## Errors
+
+- *EINVAL*, the libmodbus context is undefined.
+
+## See also
+
+- [modbus_set_slave](modbus_set_slave)

+ 25 - 0
docs/modbus_get_socket.md

@@ -0,0 +1,25 @@
+# modbus_get_socket
+
+## Name
+
+modbus_get_socket - get the current socket of the context
+
+## Synopsis
+
+```c
+int modbus_get_socket(modbus_t *'ctx');
+```
+
+## Description
+
+The *modbus_get_socket()* function shall return the current socket or file
+descriptor of the libmodbus context.
+
+## Return value
+
+The function returns the current socket or file descriptor of the context if
+successful. Otherwise it shall return -1 and set errno.
+
+## See also
+
+- [modbus_set_socket](modbus_set_socket)

+ 24 - 0
docs/modbus_mapping_free.md

@@ -0,0 +1,24 @@
+# modbus_mapping_free
+
+## Name
+
+modbus_mapping_free - free a modbus_mapping_t structure
+
+## Synopsis
+
+```c
+void modbus_mapping_free(modbus_mapping_t *mb_mapping);
+```
+
+## Description
+
+The function shall free the four arrays of mb_mapping_t structure and finally
+the mb_mapping_t referenced by `mb_mapping`.
+
+## Return value
+
+There is no return values.
+
+## See also
+
+- [modbus_mapping_new](modbus_mapping_new)

+ 60 - 0
docs/modbus_mapping_new.md

@@ -0,0 +1,60 @@
+# modbus_mapping_new
+
+## Name
+
+modbus_mapping_new - allocate four arrays of bits and registers
+
+## Synopsis
+
+```c
+modbus_mapping_t* modbus_mapping_new(int nb_bits, int nb_input_bits, int nb_registers, int nb_input_registers);
+```
+
+## Description
+
+The *modbus_mapping_new()* function shall allocate four arrays to store bits,
+input bits, registers and inputs registers. The pointers are stored in
+modbus_mapping_t structure. All values of the arrays are initialized to zero.
+
+This function is equivalent to a call of the
+[modbus_mapping_new_start_address](modbus_mapping_new_start_address) function
+with all start addresses to `0`.
+
+If it isn't necessary to allocate an array for a specific type of data, you can
+pass the zero value in argument, the associated pointer will be NULL.
+
+This function is convenient to handle requests in a Modbus server/slave.
+
+## Return value
+
+The function shall return the new allocated structure if successful. Otherwise
+it shall return NULL and set errno.
+
+## Errors
+
+- *ENOMEM*, not enough memory.
+
+## Example
+
+```c
+/* The first value of each array is accessible from the 0 address. */
+mb_mapping = modbus_mapping_new(
+    BITS_ADDRESS + BITS_NB,
+    INPUT_BITS_ADDRESS + INPUT_BITS_NB,
+    REGISTERS_ADDRESS + REGISTERS_NB,
+    INPUT_REGISTERS_ADDRESS + INPUT_REGISTERS_NB
+);
+if (mb_mapping == NULL) {
+    fprintf(
+        stderr, "Failed to allocate the mapping: %s\n",
+        modbus_strerror(errno)
+    );
+    modbus_free(ctx);
+    return -1;
+}
+```
+
+## See also
+
+- [modbus_mapping_free](modbus_mapping_free)
+- [modbus_mapping_new_start_address](modbus_mapping_new_start_address)

+ 85 - 0
docs/modbus_mapping_new_start_address.md

@@ -0,0 +1,85 @@
+# modbus_mapping_new_start_address
+
+## Name
+
+modbus_mapping_new_start_address - allocate four arrays of bits and registers accessible from their starting addresses
+
+## Synopsis
+
+```c
+modbus_mapping_t* modbus_mapping_new_start_address(
+    int start_bits, int nb_bits,
+    int start_input_bits, int nb_input_bits,
+    int start_registers, int nb_registers,
+    int start_input_registers, int nb_input_registers);
+```
+
+## Description
+
+The `modbus_mapping_new_start_address()` function shall allocate four arrays to
+store bits, input bits, registers and inputs registers. The pointers are stored
+in modbus_mapping_t structure. All values of the arrays are initialized to zero.
+
+The different starting addresses make it possible to place the mapping at any
+address in each address space. This way, you can give access to the clients at
+values stored at high addresses without allocating memory from the address zero,
+for eg. to make available registers from 340 to 349, you can use:
+
+```c
+mb_mapping = modbus_mapping_new_start_address(0, 0, 0, 0, 340, 10, 0, 0);
+```
+
+The newly created `mb_mapping` will have the following arrays:
+
+- `tab_bits` set to NULL
+- `tab_input_bits` set to NULL
+- `tab_input_registers` allocated to store 10 registers (`uint16_t`)
+- `tab_registers` set to NULL.
+
+The clients can read the first register by using the address 340 in its request.
+On the server side, you should use the first index of the array to set the value
+at this client address:
+
+```c
+mb_mapping->tab_registers[0] = 42;
+```
+
+If it isn't necessary to allocate an array for a specific type of data, you can
+pass the zero value in argument, the associated pointer will be NULL.
+
+This function is convenient to handle requests in a Modbus server/slave.
+
+## Return value
+
+The `modbus_mapping_new_start_address()` function shall return the new allocated structure if
+successful. Otherwise it shall return NULL and set errno.
+
+## Errors
+
+- *ENOMEM*, not enough memory.
+
+## Example
+
+```c
+/* The first value of each array is accessible at the defined address.
+The end address is ADDRESS + NB - 1. */
+mb_mapping = modbus_mapping_new_start_address(
+    BITS_ADDRESS, BITS_NB,
+    INPUT_BITS_ADDRESS, INPUT_BITS_NB,
+    REGISTERS_ADDRESS, REGISTERS_NB,
+    INPUT_REGISTERS_ADDRESS, INPUT_REGISTERS_NB
+);
+if (mb_mapping == NULL) {
+    fprintf(
+        stderr, "Failed to allocate the mapping: %s\n",
+        modbus_strerror(errno)
+    );
+    modbus_free(ctx);
+    return -1;
+}
+```
+
+## See also
+
+- [modbus_mapping_new](modbus_mapping_new)
+- [modbus_mapping_free](modbus_mapping_free)

+ 30 - 0
docs/modbus_mask_write_register.md

@@ -0,0 +1,30 @@
+# modbus_mask_write_register
+
+## Name
+
+modbus_mask_write_register - mask a single register
+
+## Synopsis
+
+```c
+int modbus_mask_write_register(modbus_t *ctx, int addr, uint16_t and, uint16_t or);
+```
+
+## Description
+
+The *modbus_mask_write_register()* function shall modify the value of the
+holding register at the address 'addr' of the remote device using the algorithm:
+
+  new value = (current value AND 'and') OR ('or' AND (NOT 'and'))
+
+The function uses the Modbus function code 0x16 (mask single register).
+
+## Return value
+
+The function shall return 1 if successful. Otherwise it shall return -1 and set
+errno.
+
+## See also
+
+- [modbus_read_registers](modbus_read_registers)
+- [modbus_write_registers](modbus_write_registers)

+ 77 - 0
docs/modbus_new_rtu.md

@@ -0,0 +1,77 @@
+# modbus_new_rtu
+
+## Name
+
+modbus_new_rtu - create a libmodbus context for RTU
+
+## Synopsis
+
+```c
+modbus_t *modbus_new_rtu(const char *device, int baud, char parity, int data_bit, int stop_bit);
+```
+
+## Description
+
+The *modbus_new_rtu()* function shall allocate and initialize a `modbus_t`
+structure to communicate in RTU mode on a serial line.
+
+The `device` argument specifies the name of the serial port handled by the OS,
+eg. "/dev/ttyS0" or "/dev/ttyUSB0". On Windows, it's necessary to prepend COM
+name with "\\.\" for COM number greater than 9, eg. "\\\\.\\COM10". See
+http://msdn.microsoft.com/en-us/library/aa365247(v=vs.85).aspx for details
+
+The `baud` argument specifies the baud rate of the communication, eg. 9600,
+19200, 57600, 115200, etc.
+
+The `parity` argument can have one of the following values:
+
+- `N` for none
+- `E` for even
+- `O` for odd
+
+The `data_bits` argument specifies the number of bits of data, the allowed
+values are 5, 6, 7 and 8.
+
+The `stop_bits` argument specifies the bits of stop, the allowed values are 1
+and 2.
+
+Once the `modbus_t` structure is initialized, you must set the slave of your
+device with [modbus_set_slave](modbus_set_slave) and connect to the serial bus with
+[modbus_connect](modbus_connect).
+
+## Return value
+
+The function shall return a pointer to a `modbus_t` structure if
+successful. Otherwise it shall return NULL and set errno to one of the values
+defined below.
+
+## Errors
+
+- *EINVAL*, an invalid argument was given.
+- *ENOMEM*, out of memory. Possibly, the application hits its memory limit
+    and/or whole system is running out of memory.
+
+## Example
+
+```c
+modbus_t *ctx;
+
+ctx = modbus_new_rtu("/dev/ttyUSB0", 115200, 'N', 8, 1);
+if (ctx == NULL) {
+    fprintf(stderr, "Unable to create the libmodbus context\n");
+    return -1;
+}
+
+modbus_set_slave(ctx, YOUR_DEVICE_ID);
+
+if (modbus_connect(ctx) == -1) {
+    fprintf(stderr, "Connection failed: %s\n", modbus_strerror(errno));
+    modbus_free(ctx);
+    return -1;
+}
+```
+
+## See also
+
+- [modbus_new_tcp](modbus_new_tcp)
+- [modbus_free](modbus_free)

+ 20 - 35
doc/modbus_new_tcp.txt → docs/modbus_new_tcp.md

@@ -1,53 +1,44 @@
-modbus_new_tcp(3)
-=================
+# modbus_new_tcp
 
+## Name
 
-NAME
-----
 modbus_new_tcp - create a libmodbus context for TCP/IPv4
 
+## Synopsis
 
-SYNOPSIS
---------
-*modbus_t *modbus_new_tcp(const char *'ip', int 'port');*
+```c
+modbus_t *modbus_new_tcp(const char *ip, int port);
+```
 
+## Description
 
-DESCRIPTION
------------
 The *modbus_new_tcp()* function shall allocate and initialize a modbus_t
 structure to communicate with a Modbus TCP IPv4 server.
 
-The _ip_ argument specifies the IP address of the server to which the client
+The `ip` argument specifies the IP address of the server to which the client
 wants to establish a connection. A NULL value can be used to listen any addresses in
 server mode.
 
-The _port_ argument is the TCP port to use. Set the port to
+The `port` argument is the TCP port to use. Set the port to
 `MODBUS_TCP_DEFAULT_PORT` to use the default one (502). It’s convenient to use a
 port number greater than or equal to 1024 because it’s not necessary to have
 administrator privileges.
 
+## Return value
 
-RETURN VALUE
-------------
 The function shall return a pointer to a *modbus_t* structure if
 successful. Otherwise it shall return NULL and set errno to one of the values
 defined below.
 
+## Errors
 
-ERRORS
-------
-*EINVAL*::
-An invalid IP address was given.
+- *EINVAL*, an invalid IP address was given.
+- *ENOMEM*, out of memory. Possibly, the application hits its memory limit
+  and/or whole system is running out of memory.
 
-*ENOMEM*::
-Out of memory. Possibly, the application hits its memory limit and/or whole
-system is running out of memory.
+## Example
 
-
-EXAMPLE
--------
-[source,c]
--------------------
+```c
 modbus_t *ctx;
 
 ctx = modbus_new_tcp("127.0.0.1", 1502);
@@ -61,15 +52,9 @@ if (modbus_connect(ctx) == -1) {
     modbus_free(ctx);
     return -1;
 }
--------------------
-
-SEE ALSO
---------
-linkmb:modbus_tcp_listen[3]
-linkmb:modbus_free[3]
+```
 
+## See also
 
-AUTHORS
--------
-The libmodbus documentation was written by Stéphane Raimbault
-<stephane.raimbault@gmail.com>
+- [modbus_tcp_listen](modbus_tcp_listen)
+- [modbus_free](modbus_free)

+ 62 - 0
docs/modbus_new_tcp_pi.md

@@ -0,0 +1,62 @@
+# modbus_new_tcp_pi
+
+## Name
+
+modbus_new_tcp_pi - create a libmodbus context for TCP Protocol Independent
+
+## Synopsis
+
+```c
+*modbus_t *modbus_new_tcp_pi(const char *node, const char *service);
+```
+
+## Description
+
+The *modbus_new_tcp_pi()* function shall allocate and initialize a modbus_t
+structure to communicate with a Modbus TCP IPv4 or IPv6 server.
+
+The `node` argument specifies the host name or IP address of the host to connect
+to, eg. "192.168.0.5" , "::1" or "server.com". A NULL value can be used to
+listen any addresses in server mode.
+
+The `service` argument is the service name/port number to connect to. To use the
+default Modbus port, you can provide an NULL value or the string "502". On many
+Unix systems, it’s convenient to use a port number greater than or equal to 1024
+because it’s not necessary to have administrator privileges.
+
+:octicons-tag-24: v3.1.8 handles NULL value for `service` (no *EINVAL* error).
+
+## Return value
+
+The function shall return a pointer to a *modbus_t* structure if
+successful. Otherwise it shall return NULL and set errno to one of the values
+defined below.
+
+## Errors
+
+- *ENOMEM*, out of memory. Possibly, the application hits its memory limit
+  and/or whole system is running out of memory.
+
+## Example
+
+```c
+modbus_t *ctx;
+
+ctx = modbus_new_tcp_pi("::1", "1502");
+if (ctx == NULL) {
+    fprintf(stderr, "Unable to allocate libmodbus context\n");
+    return -1;
+}
+
+if (modbus_connect(ctx) == -1) {
+    fprintf(stderr, "Connection failed: %s\n", modbus_strerror(errno));
+    modbus_free(ctx);
+    return -1;
+}
+```
+
+## See also
+
+- [modbus_new_tcp](modbus_new_tcp)
+- [modbus_tcp_pi_listen](modbus_tcp_pi_listen)
+- [modbus_free](modbus_free)

+ 36 - 0
docs/modbus_read_bits.md

@@ -0,0 +1,36 @@
+# modbus_read_bits
+
+## Name
+
+modbus_read_bits - read many bits
+
+## Synopsis
+
+```c
+int modbus_read_bits(modbus_t *ctx, int addr, int nb, uint8_t *dest);
+```
+
+## Description
+
+The *modbus_read_bits()* function shall read the status of the `nb` bits (coils)
+to the address `addr` of the remote device. The result of reading is stored in
+`dest` array as unsigned bytes (8 bits) set to `TRUE` or `FALSE`.
+
+You must take care to allocate enough memory to store the results in `dest`
+(at least `nb` * sizeof(uint8_t)).
+
+The function uses the Modbus function code 0x01 (read coil status).
+
+## Return value
+
+The function shall return the number of read bits if successful. Otherwise it
+shall return -1 and set errno.
+
+## Errors
+
+- *EMBMDATA*, too many bits requested
+
+## See also
+
+- [modbus_write_bit](modbus_write_bit)
+- [modbus_write_bits](modbus_write_bits)

+ 35 - 0
docs/modbus_read_input_bits.md

@@ -0,0 +1,35 @@
+# modbus_read_input_bits
+
+## Name
+
+modbus_read_input_bits - read many input bits
+
+## Synopsis
+
+```c
+int modbus_read_input_bits(modbus_t *ctx, int addr, int nb, uint8_t *dest);
+```
+
+## Description
+
+The *modbus_read_input_bits()* function shall read the content of the `nb` input
+bits to the address `addr` of the remote device.  The result of reading is stored
+in `dest` array as unsigned bytes (8 bits) set to `TRUE` or `FALSE`.
+
+You must take care to allocate enough memory to store the results in `dest`
+(at least `nb` * sizeof(uint8_t)).
+
+The function uses the Modbus function code 0x02 (read input status).
+
+## Return value
+
+The function shall return the number of read input status if
+successful. Otherwise it shall return -1 and set errno.
+
+## Errors
+
+- *EMBMDATA*, too many discrete inputs requested
+
+## See also
+
+- [modbus_read_input_registers](modbus_read_input_registers)

+ 39 - 0
docs/modbus_read_input_registers.md

@@ -0,0 +1,39 @@
+# modbus_read_input_registers
+
+## Name
+
+modbus_read_input_registers - read many input registers
+
+## Synopsis
+
+```c
+int modbus_read_input_registers(modbus_t *ctx, int addr, int nb, uint16_t *dest);
+```
+
+## Description
+
+The *modbus_read_input_registers()* function shall read the content of the `nb`
+input registers to address `addr` of the remote device. The result of the
+reading is stored in `dest` array as word values (16 bits).
+
+You must take care to allocate enough memory to store the results in `dest` (at
+least `nb` * sizeof(uint16_t)).
+
+The function uses the Modbus function code 0x04 (read input registers). The
+holding registers and input registers have different historical meaning, but
+nowadays it's more common to use holding registers only.
+
+## Return value
+
+The function shall return the number of read input registers if
+successful. Otherwise it shall return -1 and set errno.
+
+## Errors
+
+- *EMBMDATA*, too many bits requested.
+
+## See also
+
+- [modbus_read_input_bits](modbus_read_input_bits)
+- [modbus_write_register](modbus_write_register)
+- [modbus_write_registers](modbus_write_registers)

+ 21 - 35
doc/modbus_read_registers.txt → docs/modbus_read_registers.md

@@ -1,45 +1,38 @@
-modbus_read_registers(3)
-========================
+# modbus_read_registers
 
+## Name
 
-NAME
-----
 modbus_read_registers - read many registers
 
+## Synopsis
 
-SYNOPSIS
---------
-*int modbus_read_registers(modbus_t *'ctx', int 'addr', int 'nb', uint16_t *'dest');*
+```c
+int modbus_read_registers(modbus_t *ctx, int addr, int nb, uint16_t *dest);
+```
 
+## Description
 
-DESCRIPTION
------------
-The *modbus_read_registers()* function shall read the content of the _nb_
-holding registers to the address _addr_ of the remote device. The result of
-reading is stored in _dest_ array as word values (16 bits).
+The *modbus_read_registers()* function shall read the content of the `nb`
+holding registers to the address `addr` of the remote device. The result of
+reading is stored in `dest` array as word values (16 bits).
 
-You must take care to allocate enough memory to store the results in _dest_
-(at least _nb_ * sizeof(uint16_t)).
+You must take care to allocate enough memory to store the results in `dest`
+(at least `nb` * sizeof(uint16_t)).
 
 The function uses the Modbus function code 0x03 (read holding registers).
 
+## Return value
 
-RETURN VALUE
-------------
 The function shall return the number of read registers
 if successful. Otherwise it shall return -1 and set errno.
 
+## Errors
 
-ERRORS
-------
-*EMBMDATA*::
-Too many registers requested
+- *EMBMDATA*, too many registers requested.
 
+## Example
 
-EXAMPLE
--------
-[source,c]
--------------------
+```c
 modbus_t *ctx;
 uint16_t tab_reg[64];
 int rc;
@@ -64,16 +57,9 @@ for (i=0; i < rc; i++) {
 
 modbus_close(ctx);
 modbus_free(ctx);
--------------------
+```
 
+## See also
 
-SEE ALSO
---------
-linkmb:modbus_write_register[3]
-linkmb:modbus_write_registers[3]
-
-
-AUTHORS
--------
-The libmodbus documentation was written by Stéphane Raimbault
-<stephane.raimbault@gmail.com>
+- [modbus_write_register](modbus_write_register)
+- [modbus_write_registers](modbus_write_registers)

+ 32 - 0
docs/modbus_receive.md

@@ -0,0 +1,32 @@
+# modbus_receive
+
+## Name
+
+modbus_receive - receive an indication request
+
+## Synopsis
+
+```c
+int modbus_receive(modbus_t *'ctx', uint8_t *'req');
+```
+
+## Description
+
+The *modbus_receive()* function shall receive an indication request from the
+socket of the context `ctx`. This function is used by Modbus slave/server to
+receive and analyze indication request sent by the masters/clients.
+
+If you need to use another socket or file descriptor than the one defined in the
+context `ctx`, see the function [modbus_set_socket](modbus_set_socket).
+
+## Return value
+
+The function shall store the indication request in `req` and return the request
+length if successful. The returned request length can be zero if the indication
+request is ignored (eg. a query for another slave in RTU mode). Otherwise it
+shall return -1 and set errno.
+
+## See also
+
+- [modbus_set_socket](modbus_set_socket)
+- [modbus_reply](modbus_reply)

+ 20 - 30
doc/modbus_receive_confirmation.txt → docs/modbus_receive_confirmation.md

@@ -1,53 +1,43 @@
-modbus_receive_confirmation(3)
-==============================
+# modbus_receive_confirmation
 
+## Name
 
-NAME
-----
 modbus_receive_confirmation - receive a confirmation request
 
+## Synopsis
 
-SYNOPSIS
---------
-*int modbus_receive_confirmation(modbus_t *'ctx', uint8_t *'rsp');*
+```c
+int modbus_receive_confirmation(modbus_t *ctx, uint8_t *rsp);
+```
 
+## Description
 
-DESCRIPTION
------------
 The *modbus_receive_confirmation()* function shall receive a request via the
-socket of the context _ctx_. This function must be used for debugging purposes
+socket of the context `ctx`. This function must be used for debugging purposes
 because the received response isn't checked against the initial request. This
 function can be used to receive request not handled by the library.
 
-The maximum size of the response depends on the used backend, in RTU the _rsp_
-array must be _MODBUS_RTU_MAX_ADU_LENGTH_ bytes and in TCP it must be
-_MODBUS_TCP_MAX_ADU_LENGTH_ bytes. If you want to write code compatible with
-both, you can use the constant _MODBUS_MAX_ADU_LENGTH_ (maximum value of all
+The maximum size of the response depends on the used backend, in RTU the `rsp`
+array must be `MODBUS_RTU_MAX_ADU_LENGTH` bytes and in TCP it must be
+`MODBUS_TCP_MAX_ADU_LENGTH` bytes. If you want to write code compatible with
+both, you can use the constant `MODBUS_MAX_ADU_LENGTH` (maximum value of all
 libmodbus backends). Take care to allocate enough memory to store responses to
 avoid crashes of your server.
 
+## Return value
 
-RETURN VALUE
-------------
-The function shall store the confirmation request in _rsp_ and return the
+The function shall store the confirmation request in `rsp` and return the
 response length if successful. The returned request length can be zero if the
 indication request is ignored (eg. a query for another slave in RTU
 mode). Otherwise it shall return -1 and set errno.
 
-EXAMPLE
--------
-[source,c]
--------------------
+## Example
+
+```c
 uint8_t rsp[MODBUS_MAX_ADU_LENGTH];
 rc = modbus_receive_confirmation(ctx, rsp);
--------------------
-
-SEE ALSO
---------
-linkmb:modbus_send_raw_request[3]
+```
 
+## See also
 
-AUTHORS
--------
-The libmodbus documentation was written by Stéphane Raimbault
-<stephane.raimbault@gmail.com>
+- [modbus_send_raw_request](modbus_send_raw_request)

+ 39 - 0
docs/modbus_reply.md

@@ -0,0 +1,39 @@
+# modbus_reply
+
+## Name
+
+modbus_reply - send a response to the received request
+
+## Synopsis
+
+```c
+int modbus_reply(modbus_t *ctx, const uint8_t *req, int req_length, modbus_mapping_t *mb_mapping);
+```
+
+## Description
+
+The *modbus_reply()* function shall send a response to received request. The
+request `req` given in argument is analyzed, a response is then built and sent
+by using the information of the modbus context `ctx`.
+
+If the request indicates to read or write a value the operation will done in the
+modbus mapping `mb_mapping` according to the type of the manipulated data.
+
+If an error occurs, an exception response will be sent.
+
+This function is designed for Modbus server.
+
+## Return value
+
+The function shall return the length of the response sent if
+successful. Otherwise it shall return -1 and set errno.
+
+## Errors
+
+- *EMBMDATA*, sending has failed
+
+See also the errors returned by the syscall used to send the response (eg. send or write).
+
+## See also
+
+- [modbus_reply_exception](modbus_reply_exception)

+ 45 - 0
docs/modbus_reply_exception.md

@@ -0,0 +1,45 @@
+# modbus_reply_exception
+
+## Name
+
+modbus_reply_exception - send an exception response
+
+## Synopsis
+
+```c
+int modbus_reply_exception(modbus_t *ctx, const uint8_t *req, unsigned int exception_code);
+```
+
+## Description
+
+The *modbus_reply_exception()* function shall send an exception response based
+on the 'exception_code' in argument.
+
+The libmodbus provides the following exception codes:
+
+- MODBUS_EXCEPTION_ILLEGAL_FUNCTION (1)
+- MODBUS_EXCEPTION_ILLEGAL_DATA_ADDRESS (2)
+- MODBUS_EXCEPTION_ILLEGAL_DATA_VALUE (3)
+- MODBUS_EXCEPTION_SLAVE_OR_SERVER_FAILURE (4)
+- MODBUS_EXCEPTION_ACKNOWLEDGE (5)
+- MODBUS_EXCEPTION_SLAVE_OR_SERVER_BUSY (6)
+- MODBUS_EXCEPTION_NEGATIVE_ACKNOWLEDGE (7)
+- MODBUS_EXCEPTION_MEMORY_PARITY (8)
+- MODBUS_EXCEPTION_NOT_DEFINED (9)
+- MODBUS_EXCEPTION_GATEWAY_PATH (10)
+- MODBUS_EXCEPTION_GATEWAY_TARGET (11)
+
+The initial request `req` is required to build a valid response.
+
+## Return value
+
+The function shall return the length of the response sent if
+successful. Otherwise it shall return -1 and set errno.
+
+## Errors
+
+- *EINVAL*, the exception code is invalid
+
+## See also
+
+- [modbus_reply](modbus_reply)

+ 52 - 0
docs/modbus_report_slave_id.md

@@ -0,0 +1,52 @@
+# modbus_report_slave_id
+
+## Name
+
+modbus_report_slave_id - returns a description of the controller
+
+## Synopsis
+
+```c
+int modbus_report_slave_id(modbus_t *ctx, int max_dest, uint8_t *dest);
+```
+
+## Description
+
+The *modbus_report_slave_id()* function shall send a request to the controller
+to obtain a description of the controller.
+
+The response stored in `dest` contains:
+
+- the slave ID, this unique ID is in reality not unique at all so it's not
+  possible to depend on it to know how the information are packed in the
+  response.
+- the run indicator status (0x00 = OFF, 0xFF = ON)
+- additional data specific to each controller. For example, libmodbus returns
+  the version of the library as a string.
+
+The function writes at most `max_dest` bytes from the response to `dest` so
+you must ensure that `dest` is large enough.
+
+## Return value
+
+The function shall return the number of read data if successful.
+
+If the output was truncated due to the `max_dest` limit then the return value is
+the number of bytes which would have been written to `dest` if enough space had
+been available. Thus, a return value greater than `max_dest` means that the
+response data was truncated.
+
+Otherwise it shall return -1 and set errno.
+
+## Example
+
+```c
+uint8_t tab_bytes[MODBUS_MAX_PDU_LENGTH];
+
+...
+
+rc = modbus_report_slave_id(ctx, MODBUS_MAX_PDU_LENGTH, tab_bytes);
+if (rc > 1) {
+    printf("Run Status Indicator: %s\n", tab_bytes[1] ? "ON" : "OFF");
+}
+```

+ 35 - 0
docs/modbus_rtu_get_rts.md

@@ -0,0 +1,35 @@
+# modbus_rtu_get_rts
+
+## Name
+
+modbus_rtu_get_rts - get the current RTS mode in RTU
+
+## Synopsis
+
+```c
+int modbus_rtu_get_rts(modbus_t *ctx);
+```
+
+## Description
+
+The *modbus_rtu_get_rts()* function shall get the current Request To Send mode
+of the libmodbus context `ctx`. The possible returned values are:
+
+- `MODBUS_RTU_RTS_NONE`
+- `MODBUS_RTU_RTS_UP`
+- `MODBUS_RTU_RTS_DOWN`
+
+This function can only be used with a context using a RTU backend.
+
+## Return value
+
+The function shall return the current RTS mode if successful. Otherwise it shall
+return -1 and set errno.
+
+## Errors
+
+- *EINVAL*, the libmodbus backend is not RTU.
+
+## See also
+
+- [modbus_rtu_set_rts](modbus_rtu_set_rts)

+ 31 - 0
docs/modbus_rtu_get_rts_delay.md

@@ -0,0 +1,31 @@
+# modbus_rtu_get_rts_delay
+
+## Name
+
+modbus_rtu_get_rts_delay - get the current RTS delay in RTU
+
+## Synopsis
+
+```c
+int modbus_rtu_get_rts_delay(modbus_t *ctx);
+```
+
+## Description
+
+The `modbus_rtu_get_rts_delay()` function shall get the current Request To Send
+delay period of the libmodbus context 'ctx'.
+
+This function can only be used with a context using a RTU backend.
+
+## Return value
+
+The `modbus_rtu_get_rts_delay()` function shall return the current RTS delay in
+microseconds if successful. Otherwise it shall return -1 and set errno.
+
+## Errors
+
+- *EINVAL*, the libmodbus backend is not RTU.
+
+## See also
+
+- [modbus_rtu_set_rts_delay](modbus_rtu_set_rts_delay)

+ 41 - 0
docs/modbus_rtu_get_serial_mode.md

@@ -0,0 +1,41 @@
+# modbus_rtu_get_serial_mode
+
+## Name
+
+modbus_rtu_get_serial_mode - get the current serial mode
+
+## Synopsis
+
+```c
+int modbus_rtu_get_serial_mode(modbus_t *ctx);
+```
+
+## Description
+
+The *modbus_rtu_get_serial_mode()* function shall return the serial mode
+currently used by the libmodbus context:
+
+- **MODBUS_RTU_RS232**, the serial line is set for RS232 communication. RS-232
+  (Recommended Standard 232) is the traditional name for a series of standards
+  for serial binary single-ended data and control signals connecting between a
+  DTE (Data Terminal Equipment) and a DCE (Data Circuit-terminating Equipment).
+  It is commonly used in computer serial ports
+
+- **MODBUS_RTU_RS485**, the serial line is set for RS485 communication. EIA-485,
+  also known as TIA/EIA-485 or RS-485, is a standard defining the electrical
+  characteristics of drivers and receivers for use in balanced digital
+  multipoint systems. This standard is widely used for communications in
+  industrial automation because it can be used effectively over long distances
+  and in electrically noisy environments. This function is only available on
+  Linux kernels 2.6.28 onwards and can only be used with a context using a RTU
+  backend.
+
+## Return value
+
+The function shall return `MODBUS_RTU_RS232` or `MODBUS_RTU_RS485` if
+successful. Otherwise it shall return -1 and set errno to one of the values
+defined below.
+
+## Errors
+
+- *EINVAL*, the current libmodbus backend is not RTU.

+ 32 - 0
docs/modbus_rtu_set_custom_rts.md

@@ -0,0 +1,32 @@
+# modbus_rtu_set_custom_rts
+
+## Name
+
+modbus_rtu_set_custom_rts - set a function to be used for custom RTS implementation
+
+## Synopsis
+
+```c
+int modbus_rtu_set_custom_rts(modbus_t *ctx, void (*set_rts) (modbus_t *ctx, int on))
+```
+
+## Description
+
+The `modbus_rtu_set_custom_rts()` function shall set a custom function to be
+called when the RTS pin is to be set before and after a transmission. By default
+this is set to an internal function that toggles the RTS pin using an ioctl
+call.
+
+Note that this function adheres to the RTS mode, the values `MODBUS_RTU_RTS_UP` or
+`MODBUS_RTU_RTS_DOWN` must be used for the function to be called.
+
+This function can only be used with a context using a RTU backend.
+
+## Return value
+
+The `modbus_rtu_set_custom_rts()` function shall return 0 if successful.
+Otherwise it shall return -1 and set errno to one of the values defined below.
+
+## Errors
+
+- *EINVAL*, the libmodbus backend is not RTU.

+ 17 - 29
doc/modbus_rtu_set_rts.txt → docs/modbus_rtu_set_rts.md

@@ -1,19 +1,17 @@
-modbus_rtu_set_rts(3)
-=====================
+# modbus_rtu_set_rts
 
+## Name
 
-NAME
-----
 modbus_rtu_set_rts - set the RTS mode in RTU
 
+## Synopsis
 
-SYNOPSIS
---------
-*int modbus_rtu_set_rts(modbus_t *'ctx', int 'mode')*
+```c
+int modbus_rtu_set_rts(modbus_t *ctx, int mode)
+```
 
+## Description
 
-DESCRIPTION
------------
 The *modbus_rtu_set_rts()* function shall set the Request To Send mode to
 communicate on a RS485 serial bus. By default, the mode is set to
 `MODBUS_RTU_RTS_NONE` and no signal is issued before writing data on the wire.
@@ -28,24 +26,20 @@ RTS flag.
 
 This function can only be used with a context using a RTU backend.
 
+## Return value
 
-RETURN VALUE
-------------
 The function shall return 0 if successful. Otherwise it shall return -1 and set
 errno to one of the values defined below.
 
+## Errors
 
-ERRORS
-------
-*EINVAL*::
-The libmodbus backend isn't RTU or the mode given in argument is invalid.
+- *EINVAL*, the libmodbus backend isn't RTU or the mode given in argument is invalid.
 
+## Example
 
-EXAMPLE
--------
-.Enable the RTS mode with positive polarity
-[source,c]
--------------------
+Enable the RTS mode with positive polarity:
+
+```c
 modbus_t *ctx;
 uint16_t tab_reg[10];
 
@@ -68,14 +62,8 @@ if (rc == -1) {
 
 modbus_close(ctx);
 modbus_free(ctx);
--------------------
-
-SEE ALSO
---------
-linkmb:modbus_rtu_get_rts[3]
+```
 
+## See also
 
-AUTHORS
--------
-The libmodbus documentation was written by Stéphane Raimbault
-<stephane.raimbault@gmail.com>
+- [modbus_rtu_get_rts](modbus_rtu_get_rts)

+ 31 - 0
docs/modbus_rtu_set_rts_delay.md

@@ -0,0 +1,31 @@
+# modbus_rtu_set_rts_delay
+
+## Name
+
+modbus_rtu_set_rts_delay - set the RTS delay in RTU
+
+## Synopsis
+
+```c
+int modbus_rtu_set_rts_delay(modbus_t *ctx, int us);
+```
+
+## Description
+
+The `modbus_rtu_set_rts_delay()` function shall set the Request To Send delay
+period of the libmodbus context 'ctx'.
+
+This function can only be used with a context using a RTU backend.
+
+## Return value
+
+The `modbus_rtu_set_rts_delay()` function shall return 0 if successful.
+Otherwise it shall return -1 and set errno.
+
+## Errors
+
+- *EINVAL*, the libmodbus backend is not RTU or a negative delay was specified.
+
+## See also
+
+- [modbus_rtu_get_rts_delay](modbus_rtu_get_rts_delay)

+ 43 - 0
docs/modbus_rtu_set_serial_mode.md

@@ -0,0 +1,43 @@
+# modbus_rtu_set_serial_mode
+
+## Name
+
+modbus_rtu_set_serial_mode - set the serial mode
+
+## Synopsis
+
+```c
+int modbus_rtu_set_serial_mode(modbus_t *ctx, int mode);
+```
+
+## Description
+
+The *modbus_rtu_set_serial_mode()* function shall set the selected serial
+mode:
+
+- **MODBUS_RTU_RS232**, the serial line is set for RS232 communication. RS-232
+  (Recommended Standard 232) is the traditional name for a series of standards
+  for serial binary single-ended data and control signals connecting between a
+  DTE (Data Terminal Equipment) and a DCE (Data Circuit-terminating Equipment).
+  It is commonly used in computer serial ports.
+
+- **MODBUS_RTU_RS485**, the serial line is set for RS485 communication.
+EIA-485, also known as TIA/EIA-485 or RS-485, is a standard defining the
+electrical characteristics of drivers and receivers for use in balanced
+digital multipoint systems. This standard is widely used for communications
+in industrial automation because it can be used effectively over long
+distances and in electrically noisy environments.
+
+This function is only supported on Linux kernels 2.6.28 onwards.
+
+## Return value
+
+The function shall return 0 if successful. Otherwise it shall return -1 and set
+errno to one of the values defined below.
+
+## Errors
+
+- *EINVAL*, the current libmodbus backend is not RTU.
+- *ENOTSUP*, the function is not supported on your platform.
+
+If the call to `ioctl()` fails, the error code of ioctl will be returned.

+ 15 - 26
doc/modbus_send_raw_request.txt → docs/modbus_send_raw_request.md

@@ -1,23 +1,21 @@
-modbus_send_raw_request(3)
-==========================
+# modbus_send_raw_request
 
+## Name
 
-NAME
-----
 modbus_send_raw_request - send a raw request
 
+## Synopsis
 
-SYNOPSIS
---------
-*int modbus_send_raw_request(modbus_t *'ctx', const uint8_t *'raw_req', int 'raw_req_length');*
+```c
+int modbus_send_raw_request(modbus_t *ctx, const uint8_t *raw_req, int raw_req_length);
+```
 
+## Description
 
-DESCRIPTION
------------
 The *modbus_send_raw_request()* function shall send a request via the socket of
-the context _ctx_. This function must be used for debugging purposes because you
+the context `ctx`. This function must be used for debugging purposes because you
 have to take care to make a valid request by hand. The function only adds to the
-message, the header or CRC of the selected backend, so _raw_req_ must start and
+message, the header or CRC of the selected backend, so `raw_req` must start and
 contain at least a slave/unit identifier and a function code. This function can
 be used to send request not handled by the library.
 
@@ -25,18 +23,15 @@ The public header of libmodbus provides a list of supported Modbus functions
 codes, prefixed by `MODBUS_FC_` (eg. `MODBUS_FC_READ_HOLDING_REGISTERS`), to help
 build of raw requests.
 
+## Return value
 
-RETURN VALUE
-------------
 The function shall return the full message length, counting the extra data
 relating to the backend, if successful. Otherwise it shall return -1 and set
 errno.
 
+## Example
 
-EXAMPLE
--------
-[source,c]
--------------------
+```c
 modbus_t *ctx;
 /* Read 5 holding registers from address 1 */
 uint8_t raw_req[] = { 0xFF, MODBUS_FC_READ_HOLDING_REGISTERS, 0x00, 0x01, 0x0, 0x05 };
@@ -55,14 +50,8 @@ modbus_receive_confirmation(ctx, rsp);
 
 modbus_close(ctx);
 modbus_free(ctx);
--------------------
+```
 
-SEE ALSO
---------
-linkmb:modbus_receive_confirmation[3]
+## See also
 
-
-AUTHORS
--------
-The libmodbus documentation was written by Stéphane Raimbault
-<stephane.raimbault@gmail.com>
+- [modbus_receive_confirmation](modbus_receive_confirmation)

Daži faili netika attēloti, jo izmaiņu fails ir pārāk liels