openwrt / openwrt/packages

mbusd: /etc/init.d/mbusd start could not start the modbus daemon

Open
#16,646 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

release/21.02 stale
Dominant language
Makefile
Stars
4.6k
Forks
4k
Avg merge
3d 12h
Merged PRs (30d)
134

Description

/etc/init.d/mbusd start could not start the modbus daemon

PKG_NAME:=mbusd
PKG_VERSION:=0.5.0
Maintainer: Marcin Jurkowski marcin1j@gmail.com
Environment: OpenWrt 21.02

Description:
Once configure the /etc/config/mbusd

config mbusd
        option rts '0'
        option enabled '1'
        option loglevel '2'
        option device '/dev/ttyS1'
        option speed '9600'
        option databits '8'
        option parity 'N'
        option stopbits '1'
        option rtu_retries '3'
        option rtu_wait '500'
        option port '502'
        option max_connections '32'
        option timeout '60'

according to "mbusd -h"

mbusd-0.5.0 Copyright (C) 2002-2003, 2011, 2013-2020 Victor Antonovich <v.antonovich@gmail.com>, Andrew Denysenko <nitr0@seti.kr.ua>

Usage: mbusd [-h] [-d] [-L logfile] [-v level] [-c cfgfile] 
             [-p device] [-s speed] [-m mode]
             [-t] [-y sysfsfile] [-Y sysfsfile]
             [-A address] [-P port] [-C maxconn] [-N retries]
             [-R pause] [-W wait] [-T timeout]

Options:
  -h         : this help
  -d         : don't daemonize
  -L logfile : set log file name (default /var/log/mbus.log, 
               '-' for logging to STDOUT only)
  -v level   : set log level (0-9, default 2, 0 - errors only)
  -c cfgfile : read configuration from cfgfile
  -p device  : set serial port device name (default /dev/ttyS0)
  -s speed   : set serial port speed (default 19200)
  -m mode    : set serial port mode (default 8N1)
  -A address : set TCP server address to bind (default 0.0.0.0)
  -P port    : set TCP server port number (default 502)
  -t         : enable RTS RS-485 data direction control using RTS
  -y         : enable RTS RS-485 data direction control using sysfs file, active transmit
  -Y         : enable RTS RS-485 data direction control using sysfs file, active receive
  -C maxconn : set maximum number of simultaneous TCP connections
               (1-128, default 32)
  -N retries : set maximum number of request retries
               (0-15, default 3, 0 - without retries)
  -R pause   : set pause between requests in milliseconds
               (1-10000, default 100)
  -W wait    : set response wait time in milliseconds
               (1-10000, default 500)
  -T timeout : set connection timeout value in seconds
               (0-1000, default 60, 0 - no timeout)

according to the option "-m" syntax, it requires "8N1" for example. But according to /etc/init.d/mbusd script, at line#53

.
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'
}
.

it defines the "parity" is boolean, it could not cope with "None", "Even" and "Odd". In order to make it work, it shall change to
'parity:string' \

and comment

.
mbusd_instance() {
	[ "$2" = 0 ] || {
		echo "Validation failed"
		return 1
	}
	[ "$enabled" -gt 0 ] || return 1

#      [ "$parity" = 0 ] && parity=n || parity=y
	[ "$rts" = 0 ] && rts=
.

Thank you for your attention and look forward to getting the new patch .

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with /etc/init.d/mbusd, especially validate_section_mbusd() around line 53, and compare its parity validation with the options shown by mbusd -h. Update the validation and related parity handling so the documented configuration is accepted, then verify that /etc/init.d/mbusd start can launch the daemon with the provided settings.

Written by the indexing model from the issue text.

Assessment

Tech stack
shell
Domain
operating-systems
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.