table of contents
LIBMODBUS(7) | Libmodbus Manual | LIBMODBUS(7) |
NAME¶
libmodbus - a fast and portable Modbus librarySYNOPSIS¶
#include <modbus.h>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.Contexts¶
The Modbus protocol contains many variants (eg. serial RTU or Ehternet 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 others Modbus devices according to the selected variant.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_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]
Functions for data manipulation
Connection¶
The following functions are provided to establish and close a connection with Modbus devices: Establish a connection Close a connection Flush a connectionClient¶
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 dataServer¶
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: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.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[1]>RESOURCES¶
Main web site: http://www.libmodbus.org/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 files COPYING and COPYING.LESSER included with the libmodbus distribution.NOTES¶
- 1.
- stephane.raimbault@gmail.com
mailto:stephane.raimbault@gmail.com
05/26/2012 | libmodbus 3.0.3 |