mirror of
https://github.com/novatiq/packages.git
synced 2026-04-30 15:38:40 +01:00
mbusd: add mbusd
Mbusd is open-source Modbus TCP to Modbus RTU (RS-232/485) gateway. Signed-off-by: Marcin Jurkowski <marcin1j@gmail.com>
This commit is contained in:
@@ -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
|
||||
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user