Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
746d3b4
New function modbus_reply_callback()
frodete Mar 31, 2016
817e51a
Change msinttypes URL to GitHub repository
yegorich Mar 30, 2016
0214a9a
Add Jakob to AUTHORS with Contributor License Agreement
stephane Apr 27, 2016
61854b2
Add an option to disable tests compilation
yegorich Apr 25, 2016
9478c33
Fix address range in random-test-client
stephane May 9, 2016
7d61d48
Change API modbus_mapping_(offsets_new) to (new_start_address)
stephane May 10, 2016
fcdfd63
Use new modbus_mapping_new_start_address in unit tests
stephane May 10, 2016
b5f77b7
Add more tests for new modbus_mapping_new_start_address
stephane May 10, 2016
0892ded
Fix "wildcard address" in TCP IPv6
Apr 30, 2016
de496be
Improve documentation of modbus_report_slave_id
stephane May 11, 2016
31100e3
Add bswap macro to compile on OSX
jbysewski Mar 13, 2016
471cfff
Minor
stephane May 11, 2016
b2d6069
Update NEWS file
stephane May 11, 2016
adb1177
Slight change to modbus_report_slave_id doc.
stephane May 11, 2016
72ce9a6
Add links to new modbus_*_float_* functions in index
stephane May 11, 2016
35761b8
Move setting of option inside the relevant conditional group
stephane May 11, 2016
493bce3
Add ./configure.scan to .gitignore
stephane May 11, 2016
991ec1b
Add unit-tests.sh to tarball
stephane May 17, 2016
fd35dab
Fix small leak (64 bytes in TCP) in unit-test-client
stephane May 17, 2016
c1cda79
Github's contributing and issue template files
stephane May 17, 2016
5bef3cf
Rewrite and rename README as README.md in tests/
stephane May 17, 2016
7094e39
Fix CID 69140 - Bad bit shift operation (coverity) in tests
stephane May 18, 2016
b92c709
CID 69142 - Unchecked return value in unit-test-server
stephane May 18, 2016
d0fdd8b
CID 69145 - Argument cannot be negative in unit-test-server
stephane May 18, 2016
e5bf0b3
Fix typo in 3053bd0adb
stephane May 18, 2016
5b60cdb
DRY in modbus_reply by improving response_exception()
stephane May 20, 2016
e1c86dd
Add debug message on unknown function and new unit test
stephane May 20, 2016
5b03897
Fix handling of invalid function code (closes #315)
stephane May 20, 2016
dfbc6bf
Fix wrong function name in debug message
stephane May 20, 2016
fcd8830
Rename raw_rep to raw_rsp in unit-test-client
stephane May 20, 2016
e769541
Another round of DRY in modbus_reply()
stephane May 20, 2016
786644a
Update configure.ac
StalderT May 20, 2016
f280ed9
Update modbus-data.c
StalderT May 20, 2016
bd999ad
Minor coding conventions on defines
stephane May 20, 2016
48174a8
Improve ifdef around bswap_16 for __CYGWIN__
stephane May 20, 2016
4d5dfb0
C_PROG_RANLIB is rendered obsolete by LT_INIT
stephane May 20, 2016
474217c
Rewrite new unit test for invalid function code
stephane May 20, 2016
2870019
Update according to API changes in response_exception() in
frodete May 21, 2016
94306ef
Add debug message on unknown function code.
frodete May 21, 2016
ccfbe0c
Add debug messages on illegal callback responses.
frodete May 21, 2016
493c4ab
Refactored code in modbus_reply_callback() to avoid duplication of
frodete May 29, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Makefile.in
/build-aux
/config.*
/configure
/configure.scan
/depcomp
/install-sh
/libtool
Expand Down
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ oldfaber <oldfaber@gmail.com>
Hannu Vuolasaho <vuokkosetae@gmail.com> - CLA
Michael Heimpold <mhei@heimpold.de> - CLA
Jimmy Bergström <jimmy@ekontroll.com> - CLA
Jakob Bysewski <kontakt@jbysewski.de> - CLA
29 changes: 29 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
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/.

- *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
libmodbus@googlegroups.com

- *Use a clear and decriptive title* for the issue to identify

- *Which version of libmodbus are you using?* you can obtain this information
from your package manager or by running `pkg-config --modversion libmodbus`.
You can provide the sha1 of the commit if you have fetched the code with `git`.

- *Which operating system are you using?*

- *Describe the exact steps which reproduce the problem* in as many details as
possible. For example, the software/equipement which runs the Modbus server, how
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).

Good bug reports provide right and quick fixes!
13 changes: 13 additions & 0 deletions ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
### libmodbus version

### Operating system

### Description of the Modbus network (server, client, links, etc)

### Expected behavior

### Actual behavior

### Steps to reproduce the behavior (commands or source code)

### libmodbus output with debug mode enabled
6 changes: 5 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@ CLEANFILES += libmodbus.pc

dist_doc_DATA = MIGRATION README.md

SUBDIRS = src tests doc
SUBDIRS = src doc

if BUILD_TESTS
SUBDIRS += tests
endif
20 changes: 16 additions & 4 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
libmodbus 3.1.3 (XXXX-XX-XX)
libmodbus 3.1.3 (2016-05-11)
============================

- Introduce offsets in modbus mappings.
- Add some more macros for data manipulation.
- New bswap macros for Max OSX by Jakob Bysewski.
- Fix "wildcard address" in TCP IPv6 by Shoichi Sakane.
- Introduce offsets in modbus mappings with modbus_mapping_new_start_address.
Thanks to Michael Heimpold and Stéphane Raimbault.
- Fix address range in random-test-client.
Thanks to Martin Galvan.
- Add an option to disable tests compilation by Yegor Yefremov.
- Define MSG_DONTWAIT to MSG_NONBLOCK on AIX (#294).
Thanks to Fabrice Cantos.
- Fix building when byteswap.h is not defined by Tomasz Mon.
- Add some more macros for data manipulation and documentation.
- Remove duplicate install of modbus.h (closes #290).
Thanks to Daniel Sutcliffe.
- Move MIGRATION and README.md to dist_doc_DATA target.
- Change order of few functions in modbus RTU code.
- Add entries for modbus_rtu_[get|set]_delay in documentation index.
- Implemented runtime configurable RTS delay by Jimmy Bergström.
Expand All @@ -12,7 +24,7 @@ libmodbus 3.1.3 (XXXX-XX-XX)
- Added ILLEGAL_DATA_ADDRESS tests for modbus_write_register[|s].
Thanks to Andrey Skvortsov.
- Update documentation of modbus_rtu_set_rts
- fix rts signal switch time by Hiromasa Ihara.
- Fix rts signal switch time by Hiromasa Ihara.
- Improve new_rtu and set_slave documentation (related to #276).
- Fix late check of ctx in modbus_reply[|_exception] (closes #269).
- Wait the server for 1 second before running tests (help Travis).
Expand Down
27 changes: 7 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ 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
<http://code.google.com/p/msinttypes/> to fill the absence of stdint.h.
<https://github.com/chemeris/msinttypes> to fill the absence of stdint.h.

To compile under Windows, install [MinGW](http://www.mingw.org/) and MSYS then
select the common packages (gcc, automake, libtool, etc). The directory
Expand All @@ -59,13 +59,14 @@ automake libtool`.
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 *docs* directory
to generate HTML files.

The documentation is also available [online](http://libmodbus.org/documentation).

Testing
-------

Expand All @@ -83,21 +84,7 @@ 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`.

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)
3. Modbus messages when running in debug mode (`man modbus_set_debug`)

To report your problem, you can:

* fill a bug report on the issue tracker <http://github.com/stephane/libmodbus/issues>.
* or send an email to the libmodbus mailing list [libmodbus@googlegroups.com](https://groups.google.com/forum/#!forum/libmodbus).
To report a bug or to contribute
--------------------------------

If your prefer live talk when your're looking for help or to offer contribution,
there is also a channel called #libmodbus on Freenode.
See [CONTRIBUTING](CONTRIBUTING.md) document.
27 changes: 20 additions & 7 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#
m4_define([libmodbus_version_major], [3])
m4_define([libmodbus_version_minor], [1])
m4_define([libmodbus_version_micro], [2])
m4_define([libmodbus_version_micro], [3])

m4_define([libmodbus_release_status],
[m4_if(m4_eval(libmodbus_version_minor % 2), [1], [snapshot], [release])])
Expand Down Expand Up @@ -57,13 +57,17 @@ AC_CANONICAL_HOST

# OS check
os_win32="false"
os_cygwin="false"
os_qnx="false"
case "${host_os}" in
*mingw32*)
os_win32="true"
;;
*nto-qnx*)
os_qnx="true"
;;
*cygwin*)
os_cygwin="true"
;;
esac
AM_CONDITIONAL(OS_WIN32, test "$os_win32" = "true")
Expand Down Expand Up @@ -110,7 +114,6 @@ AC_C_INLINE

# libtool
AC_PROG_CXX
AC_PROG_RANLIB

# Various types
AC_TYPE_INT64_T
Expand All @@ -120,11 +123,13 @@ AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
AC_TYPE_UINT8_T

# Required for getaddrinfo (TCP PI - IPv6)
AC_CHECK_HEADERS([winsock2.h], HAVE_WINSOCK2_H=yes)
if test "x$HAVE_WINSOCK2_H" = "xyes"; then
LIBS="$LIBS -lws2_32"
AC_SUBST(LIBS)
if test "$os_cygwin" = "false"; then
# Required for getaddrinfo (TCP IP - IPv6)
AC_CHECK_HEADERS([winsock2.h], HAVE_WINSOCK2_H=yes)
if test "x$HAVE_WINSOCK2_H" = "xyes"; then
LIBS="$LIBS -lws2_32"
AC_SUBST(LIBS)
fi
fi

# Check for RS485 support (Linux kernel version 2.6.28+)
Expand All @@ -141,6 +146,13 @@ my_CFLAGS="-Wall \
-Wformat-security"
AC_SUBST([my_CFLAGS])

# Build options
AC_ARG_ENABLE(tests,
AS_HELP_STRING([--disable-tests],
[Build tests (default: yes)]),,
[enable_tests=yes])
AM_CONDITIONAL(BUILD_TESTS, [test $enable_tests != no])

AC_CONFIG_HEADERS([config.h tests/unit-test.h])
AC_CONFIG_FILES([
Makefile
Expand All @@ -167,4 +179,5 @@ AC_MSG_RESULT([
ldflags: ${LDFLAGS}

documentation: ${ac_libmodbus_build_doc}
tests: ${enable_tests}
])
3 changes: 2 additions & 1 deletion doc/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ TXT3 = \
modbus_get_socket.txt \
modbus_mapping_free.txt \
modbus_mapping_new.txt \
modbus_mapping_offset_new.txt \
modbus_mapping_new_start_address.txt \
modbus_mask_write_register.txt \
modbus_new_rtu.txt \
modbus_new_tcp_pi.txt \
Expand All @@ -26,6 +26,7 @@ TXT3 = \
modbus_read_registers.txt \
modbus_receive_confirmation.txt \
modbus_receive.txt \
modbus_reply_callback.txt \
modbus_reply_exception.txt \
modbus_reply.txt \
modbus_report_slave_id.txt \
Expand Down
12 changes: 10 additions & 2 deletions doc/libmodbus.txt
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,17 @@ Handling of bits and bytes::
linkmb:modbus_get_byte_from_bits[3]

Set or get float numbers::
linkmb:modbus_get_float[3]
linkmb:modbus_set_float[3]
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
Expand Down Expand Up @@ -228,6 +235,7 @@ Receive::

Reply::
linkmb:modbus_reply[3]
linkmb:modbus_reply_callback[3]
linkmb:modbus_reply_exception[3]


Expand Down
6 changes: 4 additions & 2 deletions doc/modbus_mapping_new.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ 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_offset_new()_ function
with all offsets set 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.
Expand Down Expand Up @@ -59,6 +60,7 @@ if (mb_mapping == NULL) {
SEE ALSO
--------
linkmb:modbus_mapping_free[3]
linkmb:modbus_mapping_new_start_address[3]


AUTHORS
Expand Down
81 changes: 81 additions & 0 deletions doc/modbus_mapping_new_start_address.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
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 adresses 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 adresses 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_offset_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_offset_new()_ 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_offset_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>
Loading