Merge pull request #10809 from etactica/mb-1907
[19.07] libmodbus update to 3.1.6
This commit is contained in:
commit
80c42c968e
4 changed files with 41 additions and 74 deletions
|
@ -8,17 +8,17 @@
|
|||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=libmodbus
|
||||
PKG_VERSION:=3.1.4
|
||||
PKG_RELEASE:=3
|
||||
PKG_VERSION:=3.1.6
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=http://libmodbus.org/releases
|
||||
PKG_HASH:=c8c862b0e9a7ba699a49bc98f62bdffdfafd53a5716c0e162696b4bf108d3637
|
||||
PKG_HASH:=d7d9fa94a16edb094e5fdf5d87ae17a0dc3f3e3d687fead81835d9572cf87c16
|
||||
|
||||
PKG_MAINTAINER:=Michael Heimpold <mhei@heimpold.de>
|
||||
|
||||
PKG_LICENSE:=GPL-3.0-or-later LGPL-2.1-or-later
|
||||
PKG_LICENSE_FILES:=COPYING COPYING.LESSER
|
||||
PKG_LICENSE:=LGPL-2.1-or-later
|
||||
PKG_LICENSE_FILES:=COPYING.LESSER
|
||||
|
||||
PKG_FIXUP:=autoreconf
|
||||
PKG_INSTALL:=1
|
||||
|
@ -50,7 +50,7 @@ endef
|
|||
|
||||
define Package/libmodbus/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libmodbus.so* $(1)/usr/lib/
|
||||
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libmodbus.so.* $(1)/usr/lib/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,libmodbus))
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
From f1eb4bc7ccb09cd8d19ab641ee37637f8c34d16d Mon Sep 17 00:00:00 2001
|
||||
From: i-ky <gl.ivanovsky@gmail.com>
|
||||
Date: Tue, 10 Jul 2018 15:58:45 +0300
|
||||
Subject: [PATCH] Fixed MODBUS_GET_* macros in case of negative values
|
||||
|
||||
In case resulting value should be negative it is incorrect to use '+' operator to construct it from pieces, because highest bytes will result in negative number after bitwise shift while others will stay positive. Replacing addition with '|' should solve the issue.
|
||||
---
|
||||
src/modbus.h | 10 +++++-----
|
||||
1 file changed, 5 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/src/modbus.h b/src/modbus.h
|
||||
index f6e9a5f..c63f5ce 100644
|
||||
--- a/src/modbus.h
|
||||
+++ b/src/modbus.h
|
||||
@@ -245,12 +245,12 @@ MODBUS_API int modbus_reply_exception(modbus_t *ctx, const uint8_t *req,
|
||||
#define MODBUS_GET_HIGH_BYTE(data) (((data) >> 8) & 0xFF)
|
||||
#define MODBUS_GET_LOW_BYTE(data) ((data) & 0xFF)
|
||||
#define MODBUS_GET_INT64_FROM_INT16(tab_int16, index) \
|
||||
- (((int64_t)tab_int16[(index) ] << 48) + \
|
||||
- ((int64_t)tab_int16[(index) + 1] << 32) + \
|
||||
- ((int64_t)tab_int16[(index) + 2] << 16) + \
|
||||
+ (((int64_t)tab_int16[(index) ] << 48) | \
|
||||
+ ((int64_t)tab_int16[(index) + 1] << 32) | \
|
||||
+ ((int64_t)tab_int16[(index) + 2] << 16) | \
|
||||
(int64_t)tab_int16[(index) + 3])
|
||||
-#define MODBUS_GET_INT32_FROM_INT16(tab_int16, index) ((tab_int16[(index)] << 16) + tab_int16[(index) + 1])
|
||||
-#define MODBUS_GET_INT16_FROM_INT8(tab_int8, index) ((tab_int8[(index)] << 8) + tab_int8[(index) + 1])
|
||||
+#define MODBUS_GET_INT32_FROM_INT16(tab_int16, index) ((tab_int16[(index)] << 16) | tab_int16[(index) + 1])
|
||||
+#define MODBUS_GET_INT16_FROM_INT8(tab_int8, index) ((tab_int8[(index)] << 8) | tab_int8[(index) + 1])
|
||||
#define MODBUS_SET_INT16_TO_INT8(tab_int8, index, value) \
|
||||
do { \
|
||||
tab_int8[(index)] = (value) >> 8; \
|
||||
--
|
||||
2.17.1
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
From 1c5d969f46ccd5333f602dfbe2b0a1295650b9b0 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?St=C3=A9phane=20Raimbault?= <stephane.raimbault@gmail.com>
|
||||
Date: Wed, 25 Oct 2017 20:35:47 +0200
|
||||
Subject: [PATCH 1/2] Only set SER_RS485_ENABLED bit of existing RS485 settings
|
||||
|
||||
Thanks to @JCWren
|
||||
---
|
||||
src/modbus-rtu.c | 10 +++++++++-
|
||||
1 file changed, 9 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/modbus-rtu.c b/src/modbus-rtu.c
|
||||
index 8d9f386..f2911d6 100644
|
||||
--- a/src/modbus-rtu.c
|
||||
+++ b/src/modbus-rtu.c
|
||||
@@ -909,9 +909,13 @@ int modbus_rtu_set_serial_mode(modbus_t *ctx, int mode)
|
||||
#if HAVE_DECL_TIOCSRS485
|
||||
modbus_rtu_t *ctx_rtu = ctx->backend_data;
|
||||
struct serial_rs485 rs485conf;
|
||||
- memset(&rs485conf, 0x0, sizeof(struct serial_rs485));
|
||||
|
||||
if (mode == MODBUS_RTU_RS485) {
|
||||
+ // Get
|
||||
+ if (ioctl(ctx->s, TIOCGRS485, &rs485conf) < 0) {
|
||||
+ return -1;
|
||||
+ }
|
||||
+ // Set
|
||||
rs485conf.flags = SER_RS485_ENABLED;
|
||||
if (ioctl(ctx->s, TIOCSRS485, &rs485conf) < 0) {
|
||||
return -1;
|
||||
@@ -923,6 +927,10 @@ int modbus_rtu_set_serial_mode(modbus_t *ctx, int mode)
|
||||
/* Turn off RS485 mode only if required */
|
||||
if (ctx_rtu->serial_mode == MODBUS_RTU_RS485) {
|
||||
/* The ioctl call is avoided because it can fail on some RS232 ports */
|
||||
+ if (ioctl(ctx->s, TIOCGRS485, &rs485conf) < 0) {
|
||||
+ return -1;
|
||||
+ }
|
||||
+ rs485conf.flags &= ~SER_RS485_ENABLED;
|
||||
if (ioctl(ctx->s, TIOCSRS485, &rs485conf) < 0) {
|
||||
return -1;
|
||||
}
|
||||
--
|
||||
2.21.0
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
From 91a1d74f76c64e7b35bfb10114e1a4a6ff351656 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?St=C3=A9phane=20Raimbault?= <stephane.raimbault@gmail.com>
|
||||
Date: Thu, 26 Oct 2017 11:10:31 +0200
|
||||
Subject: [PATCH 2/2] Oops fix OR on RS485 settings (1c5d969)
|
||||
|
||||
---
|
||||
src/modbus-rtu.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/modbus-rtu.c b/src/modbus-rtu.c
|
||||
index f2911d6..190298e 100644
|
||||
--- a/src/modbus-rtu.c
|
||||
+++ b/src/modbus-rtu.c
|
||||
@@ -916,7 +916,7 @@ int modbus_rtu_set_serial_mode(modbus_t *ctx, int mode)
|
||||
return -1;
|
||||
}
|
||||
// Set
|
||||
- rs485conf.flags = SER_RS485_ENABLED;
|
||||
+ rs485conf.flags |= SER_RS485_ENABLED;
|
||||
if (ioctl(ctx->s, TIOCSRS485, &rs485conf) < 0) {
|
||||
return -1;
|
||||
}
|
||||
--
|
||||
2.21.0
|
||||
|
Loading…
Reference in a new issue