Merge pull request #13576 from marcin1j/pr/20191209-mbusd
New package: mbusd
This commit is contained in:
commit
ef58c37408
3 changed files with 131 additions and 0 deletions
46
net/mbusd/Makefile
Normal file
46
net/mbusd/Makefile
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
|
PKG_NAME:=mbusd
|
||||||
|
PKG_VERSION:=0.4.0
|
||||||
|
PKG_RELEASE:=1
|
||||||
|
|
||||||
|
PKG_SOURCE_URL:=https://codeload.github.com/3cky/mbusd/tar.gz/v$(PKG_VERSION)?
|
||||||
|
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||||
|
PKG_HASH:=8458afc455a28c8f798cadd3982f9e03496a494a2269e31e8255a6ca273a6898
|
||||||
|
|
||||||
|
PKG_LICENSE:=BSD-3-Clause
|
||||||
|
PKG_LICENSE_FILES:=LICENSE
|
||||||
|
|
||||||
|
PKG_MAINTAINER:=Marcin Jurkowski <marcin1j@gmail.com>
|
||||||
|
|
||||||
|
PKG_BUILD_PARALLEL:=1
|
||||||
|
PKG_INSTALL:=1
|
||||||
|
|
||||||
|
include $(INCLUDE_DIR)/package.mk
|
||||||
|
include $(INCLUDE_DIR)/cmake.mk
|
||||||
|
|
||||||
|
define Package/mbusd
|
||||||
|
SECTION:=net
|
||||||
|
CATEGORY:=Network
|
||||||
|
TITLE:=Modbus TCP gateway
|
||||||
|
URL:=https://github.com/3cky/mbusd
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/mbusd/description
|
||||||
|
Mbusd is open-source Modbus TCP to Modbus RTU (RS-232/485) gateway.
|
||||||
|
It presents a network of RTU slaves as single TCP slave.
|
||||||
|
|
||||||
|
That is a TCP-Slave (or server) which acts as a RTU-master to get
|
||||||
|
data from Modbus RTU-slave devices.
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/mbusd/install
|
||||||
|
$(INSTALL_DIR) $(1)/usr/bin
|
||||||
|
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/mbusd $(1)/usr/bin
|
||||||
|
$(INSTALL_DIR) $(1)/etc/config
|
||||||
|
$(INSTALL_DATA) ./files/mbusd.conf $(1)/etc/config/mbusd
|
||||||
|
$(INSTALL_DIR) $(1)/etc/init.d
|
||||||
|
$(INSTALL_BIN) ./files/mbusd.init $(1)/etc/init.d/mbusd
|
||||||
|
endef
|
||||||
|
|
||||||
|
$(eval $(call BuildPackage,mbusd))
|
17
net/mbusd/files/mbusd.conf
Normal file
17
net/mbusd/files/mbusd.conf
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
config mbusd
|
||||||
|
option enabled 0
|
||||||
|
option port 502
|
||||||
|
option loglevel 2
|
||||||
|
|
||||||
|
#option max_connections 32
|
||||||
|
#option timeout 60
|
||||||
|
|
||||||
|
option device '/dev/ttyUSB0'
|
||||||
|
option speed 19200
|
||||||
|
option databits 8
|
||||||
|
option parity 0
|
||||||
|
option stopbits 2
|
||||||
|
option rts 0
|
||||||
|
|
||||||
|
#option rtu_retries 3
|
||||||
|
#option rtu_wait 500
|
68
net/mbusd/files/mbusd.init
Normal file
68
net/mbusd/files/mbusd.init
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
#!/bin/sh /etc/rc.common
|
||||||
|
# Copyright (C) 2019 OpenWrt.org
|
||||||
|
|
||||||
|
START=90
|
||||||
|
USE_PROCD=1
|
||||||
|
NAME=mbusd
|
||||||
|
|
||||||
|
|
||||||
|
mbusd_instance() {
|
||||||
|
[ "$2" = 0 ] || {
|
||||||
|
echo "Validation failed"
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
[ "$enabled" -gt 0 ] || return 1
|
||||||
|
|
||||||
|
|
||||||
|
[ "$parity" = 0 ] && parity=n || parity=y
|
||||||
|
[ "$rts" = 0 ] && rts=
|
||||||
|
|
||||||
|
|
||||||
|
procd_open_instance mbusd-$port
|
||||||
|
procd_set_param command /usr/bin/mbusd \
|
||||||
|
-d \
|
||||||
|
-L - \
|
||||||
|
-P $port \
|
||||||
|
-v $loglevel \
|
||||||
|
${max_connections:+-C $max_connections} \
|
||||||
|
${timeout:+-T $timeout} \
|
||||||
|
-p $device \
|
||||||
|
-s $speed \
|
||||||
|
-m ${databits}${parity}${stopbits} \
|
||||||
|
${rts:+-t} \
|
||||||
|
${rtu_retries:+-N $rtu_retries} \
|
||||||
|
${rtu_wait:+-W $rtu_wait}
|
||||||
|
|
||||||
|
procd_set_param stdout 1
|
||||||
|
procd_set_param stderr 1
|
||||||
|
procd_set_param respawn
|
||||||
|
|
||||||
|
procd_close_instance
|
||||||
|
}
|
||||||
|
|
||||||
|
validate_section_mbusd() {
|
||||||
|
uci_load_validate mbusd mbusd "$1" "$2" \
|
||||||
|
'enabled:bool:1' \
|
||||||
|
'port:port:502' \
|
||||||
|
'loglevel:uinteger:2' \
|
||||||
|
'max_connections:uinteger' \
|
||||||
|
'timeout:uinteger' \
|
||||||
|
'device:string' \
|
||||||
|
'speed:uinteger' \
|
||||||
|
'databits:uinteger' \
|
||||||
|
'parity:bool' \
|
||||||
|
'stopbits:uinteger' \
|
||||||
|
'rts:bool:0' \
|
||||||
|
'rtu_retries:uinteger' \
|
||||||
|
'rtu_wait:uinteger'
|
||||||
|
}
|
||||||
|
|
||||||
|
start_service() {
|
||||||
|
config_load "$NAME"
|
||||||
|
config_foreach validate_section_mbusd mbusd mbusd_instance
|
||||||
|
}
|
||||||
|
|
||||||
|
service_triggers() {
|
||||||
|
procd_add_reload_trigger "$NAME"
|
||||||
|
procd_add_validation validate_section_mbusd
|
||||||
|
}
|
Loading…
Reference in a new issue