SRA Lab Open Source Code

11May/130

Very late announce of libmodbus v3.1.0

OK last year, I've silently released libmodbus v3.1.0 and it's never too late to announce it!

libmodbus 3.1.0 (2012-05-22)

Major changes to handle many slaves in RTU mode, non blocking connections and
RTS flow control.

  • Fixes for Microsoft Visual C++ compiler
  • Fixes for Windows. Thanks to oldfaber
  • Return value of _modbus_tcp_pi_connect() on failure (closes #61)
  • Avoid ioctl call on non-RS485 ports. Thanks to Michael Haberler
  • Display node and service in PI and port in IPv4 at connection
  • Return -1 on getaddrinfo error and print error in debug mode
  • More robust way to establish the connection in non blocking mode
  • TCP - Socket in non blocking mode by default. Thanks to Thomas Stalder
  • Apply CLOEXEC flag for TCP protocol independent too (IPv6)
  • New RTU receive() to ignore confirmation from other slaves (closes #18)
  • Move RTU filtering in CRC check to avoid useless call to modbus_reply
  • Unique transaction identifier by TCP connection
  • Use accept4 with SOCK_CLOEXEC when available (Linux)
  • Open fd and socket with the CLOEXEC flag when available
  • Exception response on report slave ID wasn't detected (closes #27)
  • Provides a way to disable the byte timeout (Alex Stapleton)
  • Added slave ID check for response messages (Alex Stapleton)
  • RTS flow control with modbus_rtu_set_rts and modbus_rtu_get_rts functions by Torello Querci and Stéphane Raimbault.

Download libmodbus v3.1.0

8May/130

New libmodbus v3.0.4

New stable release v3.0.4:

  • autogen.sh creates symlinks instead of copies
  • Add missing m4 directory (closes #103)
  • Fix alignment problem on ARMv5 platform. Thanks to Alexander Dahl.
  • Remove useless test on error_recovery argument. Thanks to Carlos Tangerino.

Download libmodbus v3.0.4.

26May/120

New libmodbus v3.0.3

This new bugfix release contains the following changes:

  • Fix another Visual C++ 2008/2010 deficiency (closes #53)
  • Add -lsocket to compile on QNX
  • Fix TCP PI init under Windows.
    Thanks to oldfaber.
  • Fix a missing free in random-test-client.
    Thanks again to Stefan Finzel.
  • Fix OMG bug in modbus_mapping_free not freeing memory.
    Thanks to Stefan Finzel for the bug report.
  • Fix semicolon typo and unistd.h include under Windows.
    Thanks to Andrew Kravchuk.

Download libmodbus v3.0.3.

6Feb/120

Fork me, I’m famous!

The modbus library finds its way into the official repositories Fedora (packaged by Stéphane Raimbault), Debian and Ubuntu (packaged by Ivo De Decker).

https://community.dev.fedoraproject.org/packages/libmodbus
http://packages.debian.org/search?keywords=libmodbus
http://packages.ubuntu.com/search?keywords=libmodbus

Of course, we'll happy to support other distributions!

To improve the communication and ease the subscription process, the libmodbus project as moved from Launchpad list to Google Groups libmodbus@googlegroups.com.

Update: Julien Boibessot integrated libmodbus into Buildroot.

6Feb/120

libmodbus v3.0.2

Yet another stable release with minor fixes.

libmodbus 3.0.2 (2012-01-16)

  • Update Debian package.
  • Documentation fixes and additions.
  • Add missing C++ macros in public headers. Thanks to Bernhard Agthe.
  • Protects modbus_mapping_free against NULL argument. Thanks to Andrea Mattia.
  • Fix check on file doc/libmodbus.7 in acinclude.m4 (closes #28)
  • Close file descriptor when the settings don't apply in RTU. Original patch provided by Thomas Stalder.
  • unit-test.h is now generated to avoid config.h dependency.
  • Request for Windows Sockets specification version 2.2 instead of 2.0. Thanks to Pavel Mazniker for the report.
22Jul/110

v3.0.1 to avoid ".0" problems

A dot zero isn't a dot zero without few problems, so I've released libmodbus v3.0.1 to fix problems with non-recent Linux kernels and other platforms.

libmodbus 3.0.1 (2011-07-18)

  • Avoid useless serial_mode integer when TIOCSRS485 isn't supported
  • Fix compilation failure on Windows (RS485 support) by Tobias Doerffel
  • Properly check TIOCSRS485 define by Matthijs Kool
  • Rename package to libmodbus5 to fix lintian warning
12Jul/110

Magic libmodbus 3.0.0 is out

OK, the new stable release of libmodbus is finally out! Only 2 years after libmodbus v2.0.3 and 400 commits, I'm happy to release this new version which contains many changes to improve the API and enhance the Modbus protocol conformity. The major features of this release are:

  • more coherent and extended API
  • POSIX error return codes
  • full documentation of the API
  • IPv6 support
  • new backend design
  • support for Windows, MacOS X and FreeBSD
  • rewriting of the message reading to avoid timeout
  • native serial communication on Windows

Thanks to the many contributors

Tobias Doerffel, Florian octo Forster, Hannu Vuolasaho, Patsy Kaye, Ivo De Decker,
Allan Cornet, Manfred Gruber, Jason Oster, Petr Parýzek, Antti Manninen, Barry Grumbine,
Kirill Smelkov, Anibal Limón, David Olivari, Sisyph, aladdinwu, Jeff Laughlin, Yishin Li , Henrik Munktell, Paul Fertser, Norbert Koch and Stéphane Raimbault.

The development continues for the next v3.1 release with this roadmap.

Have fun!

5Jun/110

libmodbus v2.9.4 is out!

This minor release contains many new features with IPv6 support, documentation (man and HTML), error recovery modes and small API changes. I'm intend to release the version 3.0 so I need feeback from this release even more if you use libmodbus on Windows or MacOS X (check nanosleep support for example).

It's easy to test the library, just compile and run the unit tests! Don't forget to notify your success or failure (by mail, wiki or bug report), see the Call for Testers page or the mailing list for details.

There are already Debian and Fedora packages but I need help to submit them to the distributions, so all experience in this field is appreciated.

libmodbus 2.9.4 (2011-06-05)

  • IPv6 support  Make the TCP implementation "protocol independent" by Florian Forster  and Stéphane Raimbault.
  • Fix compilation on Windows 7 (x64) with MinGW/MSYS and GCC 4.
    Reported by Patsy Kaye.
  • Documentation of libmodbus functions with AsciiDoc (man and HTML) by Stéphane  Raimbault
  • Avoid an iteration in flush function
  • New functions to send and receive raw requests (modbus_send_raw_request,  modbus_receive_confirmation)
  • Fix flush function of TCP backend on Windows
  • API changes for server/slave:
    * modbus_receive doesn't take socket/fd argument anymore
    * new function modbus_set_socket to set socket/fd
  • API changes for timeout functions:
    * modbus_get_timeout_begin -> modbus_get_response_timeout
    * modbus_set_timeout_begin -> modbus_set_response_timeout
    * modbus_get_timeout_end -> modbus_get_byte_timeout
    * modbus_set_timeout_end -> modbus_set_byte_timeout
  • Fix longstanding limitation of server to wait forever
  • New functions modbus_set/get_serial_mode by Manfred Gruber and Stéphane  Raimbault for RS485 communications
  • Improved recovery mode (see modbus_set_error_recovery documentation) for  data link and protocol errors.
  • Fix compilation issue with Microsoft Visual Studio 2008.  Reported by Allan Cornet.
27Apr/110

Not compliant device can be time consuming!

Travis Atkinson of Com-Pac Filtration and me have worked together to find out why the HMI of Weintek Labs I-Series, with Ethernet, answered only to request sent by the modpoll program (proprietary software).

After many emails and the help of Wireshark, we have discovered modpoll uses the unit identifier as slave ID for TCP requests, according to the Modbus specs that's incorrect (cf page 23 of Modbus Messaging Implementation Guide v1.0b) but else the device drops the request! Two problems can sometimes lead to proper operation or Weintek company has designed this product on modpoll requests :-/

PS: The workaround was to set the slave ID with modbus_set_slave()

14Apr/110

libmodbus for Arduino (almost!)

The libmodbus project is a real success on many platforms and to conquer the world, I've written a version dedicated to Arduino devices. My goals are:

  • to talk with a standard Arduino UNO or Duemilanove via the integrated USB
    serial line (8N1)
  • to have the lowest footprint (binary sketch size and SRAM)
  • to be robust

OK, you're right, other projects exist already:

  • Master/slave by jpmzometa and others is great but the reading in loop doesn't handle serial latency and the code contains too many arrays IMHO
  • ModbusMaster is a master and I want a slave.
  • Arduino-Modbus, the code is, eh, ugly!
  • modbusmq by Mario Di Bacco is based on libmodbus but it aims Modbus TCP.

So I've extracted/adapted only the slave, RTU, reading/writing registers of libmodbus. To reduce the footprint even further, I've replaced the fast CRC code based on precomputed arrays (512 bytes) by a slow one (not so slow!). The result is clean library for Arduino able to handle exceptions if an error occurs.

The binary sketch size is 2,450 bytes and around 1,830 bytes of memory still free when running on 2K SRAM model.

The source code is available on github and have the project is referenced in the arduino.cc playground wiki.