Skip to content
This repository
Stéphane Raimbault
file 88 lines (61 sloc) 3.38 kb

A groovy modbus library


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 connection.

The functions included in the library have been derived from the Modicon Modbus Protocol Reference Guide which can be obtained from Schneider at

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 The documentation is licensed under the Creative Commons Attribution-ShareAlike License 3.0 (Unported) (

The official website is

The library is written in C and designed to run on Linux, Mac OS X, FreeBSD and QNX and Windows.


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 documentation (optional).

To install, just run the usual dance, ./configure && make install. Run ./ first to generate the configure script if required.

You can change installation directory with prefix option, eg. ./configure --prefix=/usr/local/. You have to check that the installation library path is properly set up on your system (/etc/ and library cache is up to date (run ldconfig as root if required).

The library provides a libmodbus.pc file to use with pkg-config to ease your program compilation and linking.

If you want to compile with Microsoft Visual Studio, you need to install to fill the absence of stdint.h.

To compile under Windows, install MinGW and MSYS then select the common packages (gcc, automake, libtool, etc). The directory ./src/win32/ contains a Visual C project.

To compile under OS X with homebrew, you will need to install the following dependencies first: brew install autoconf automake libtool.


Some tests are provided in tests directory, you can freely edit the source code to fit your needs (it's Free Software :).

See tests/README for a description of each program.

For a quick test of libmodbus, you can run the following programs in two shells:

  1. ./unit-test-server
  2. ./unit-test-client

By default, all TCP unit tests will be executed (see --help for options).

Report a Bug

Before reporting a bug, take care to read the documentation (RTFM!) and to provide enough information:

  1. libmodbus version
  2. OS/environment/architecture
  3. libmodbus backend (TCP, RTU, IPv6)
  4. Modbus messages when running in debug mode (man modbus_set_debug)

To report your problem, you can:

If your prefer live talk when your're looking for help or to offer contribution, there is also a channel called #libmodbus on Freenode.

Something went wrong with that request. Please try again.