Skip to content

OpenHAB Modbus bridge with mbusd error #127

@Brigithubert

Description

@Brigithubert

My setup: Got a Komfovent C4 connected (followed IVC wiki) via ch341-uart converter on RPi2B (ttyUSB0) as Modbus gateway.

OpenHAB is running on another RPi in the network.

Polling register 1006 (Modbus address 20) using mbpoll -m rtu -a 20 -b 19200 -t 4 -r 1006 /dev/ttyUSB0 -v on the RPi2B works.

I then setup a configuration for mbusd as follows:

loglevel = 2
logfile = /var/log/mbusd.log
device = /dev/ttyUSB0
speed = 19200
mode = 8e1
trx_control = addc
address = 0.0.0.0
port = 502
maxconn = 32
timeout = 60
retries = 3
pause = 100
wait = 500
replyonbroadcast = no

Installed Modbus bridge on OpenHAB v4.3.5 and created a thing

UID: modbus:tcp:
label: Modbus
thingTypeUID: modbus:tcp
configuration:
rtuEncoded: false
timeBetweenTransactionsMillis: 60
connectMaxTries: 1
reconnectAfterMillis: 100000
port: 502
timeBetweenReconnectMillis: 0
host: 192.168.1.211
connectTimeoutMillis: 10000
afterConnectionDelayMillis: 0
id: 20
enableDiscovery: false

Created another thing "Regular poll"

UID: modbus:poller::
label: Poller
thingTypeUID: modbus:poller
configuration:
start: 1006
length: 1
refresh: 5000
maxTries: 3
cacheMillis: 50
type: input
bridgeUID: modbus:tcp:

This results in (OpenHAB):
COMMUNICATION_ERROR Error with read: org.openhab.core.io.transport.modbus.internal.ModbusSlaveErrorResponseExceptionImpl: Slave responded with error=1 (ILLEGAL_FUNCTION)

Starting mbusd -L /tmp/mbusd.log -p /dev/ttyUSB0 -s 19200 -m 8e1 -P 502 -d -v9 and running the poller in OpenHAB results in

26 Jan 2026 14:15:55 conn_loop(): select() returns 1
26 Jan 2026 14:15:55 conn_open(): accepting connection from 192.168.1.10
26 Jan 2026 14:15:55 queue_new_elem(): length now is 1
26 Jan 2026 14:15:55 conn[192.168.1.10]: state now is CONN_HEADER
26 Jan 2026 14:15:55 conn_loop(): select(): max_sd = 5, t_out = 000000:000060
26 Jan 2026 14:15:55 conn_loop(): select() returns 1
26 Jan 2026 14:15:55 conn[192.168.1.10]: state now is CONN_RQST_FUNC
26 Jan 2026 14:15:55 conn_loop(): select(): max_sd = 5, t_out = 000000:000060
26 Jan 2026 14:15:55 conn_loop(): select() returns 1
26 Jan 2026 14:15:55 conn[192.168.1.10]: read request fc 4
26 Jan 2026 14:15:55 conn[192.168.1.10]: state now is CONN_RQST_TAIL
26 Jan 2026 14:15:55 conn[192.168.1.10]: request: [14][04][2a][93][00][0a]
26 Jan 2026 14:15:55 conn[192.168.1.10]: state now is CONN_TTY
26 Jan 2026 14:15:55 tty: state now is TTY_RQST
26 Jan 2026 14:15:55 conn_loop(): select(): max_sd = 4, t_out = 000000:000060
26 Jan 2026 14:15:55 conn_loop(): select() returns 1
26 Jan 2026 14:15:55 tty: written 8 bytes
26 Jan 2026 14:15:55 tty: request written (total 8 bytes)
26 Jan 2026 14:15:55 tty: state now is TTY_RESP
26 Jan 2026 14:15:55 tty: estimated 25 bytes, waiting 518905 usec
26 Jan 2026 14:15:55 conn_loop(): select(): max_sd = 4, t_out = 000000:000000
26 Jan 2026 14:15:55 conn_loop(): select() returns 1
26 Jan 2026 14:15:55 tty: read 5 bytes
26 Jan 2026 14:15:55 tty: rx len changed from 25 to 6
26 Jan 2026 14:15:55 tty: read 5 bytes of 6, offset 0
26 Jan 2026 14:15:55 conn_loop(): select(): max_sd = 4, t_out = 000000:000000
26 Jan 2026 14:15:55 conn_loop(): select() returns 0
26 Jan 2026 14:15:55 tty: response read (total 5 bytes, offset 0 bytes)
26 Jan 2026 14:15:55 tty: response is correct
26 Jan 2026 14:15:55 tty: response: [14][84][01][93][04]
26 Jan 2026 14:15:55 conn[192.168.1.10]: state now is CONN_RESP
26 Jan 2026 14:15:55 tty: state now is TTY_PAUSE
26 Jan 2026 14:15:55 conn_loop(): select(): max_sd = 5, t_out = 000000:000000
26 Jan 2026 14:15:55 conn_loop(): select() returns 1
26 Jan 2026 14:15:55 conn[192.168.1.10]: state now is CONN_HEADER
26 Jan 2026 14:15:55 conn_loop(): select(): max_sd = 5, t_out = 000000:000000
26 Jan 2026 14:15:55 conn_loop(): select() returns 1
26 Jan 2026 14:15:55 conn[192.168.1.10]: state now is CONN_RQST_FUNC
26 Jan 2026 14:15:55 conn_loop(): select(): max_sd = 5, t_out = 000000:000000
26 Jan 2026 14:15:55 conn_loop(): select() returns 1
26 Jan 2026 14:15:55 conn[192.168.1.10]: read request fc 4
26 Jan 2026 14:15:55 conn[192.168.1.10]: state now is CONN_RQST_TAIL
26 Jan 2026 14:15:55 conn[192.168.1.10]: request: [14][04][2a][93][00][0a]
26 Jan 2026 14:15:55 conn[192.168.1.10]: state now is CONN_TTY
26 Jan 2026 14:15:55 conn_loop(): select(): max_sd = 4, t_out = 000000:000000
26 Jan 2026 14:15:55 conn_loop(): select() returns 0
26 Jan 2026 14:15:55 tty: state now is TTY_RQST
26 Jan 2026 14:15:55 conn_loop(): select(): max_sd = 4, t_out = 000000:000060
26 Jan 2026 14:15:55 conn_loop(): select() returns 1
26 Jan 2026 14:15:55 tty: written 8 bytes
26 Jan 2026 14:15:55 tty: request written (total 8 bytes)
26 Jan 2026 14:15:55 tty: state now is TTY_RESP
26 Jan 2026 14:15:55 tty: estimated 25 bytes, waiting 518905 usec
26 Jan 2026 14:15:55 conn_loop(): select(): max_sd = 4, t_out = 000000:000000
26 Jan 2026 14:15:55 conn_loop(): select() returns 1
26 Jan 2026 14:15:55 tty: read 5 bytes
26 Jan 2026 14:15:55 tty: rx len changed from 25 to 6
26 Jan 2026 14:15:55 tty: read 5 bytes of 6, offset 0
26 Jan 2026 14:15:55 conn_loop(): select(): max_sd = 4, t_out = 000000:000000
26 Jan 2026 14:15:56 conn_loop(): select() returns 0
26 Jan 2026 14:15:56 tty: response read (total 5 bytes, offset 0 bytes)
26 Jan 2026 14:15:56 tty: response is correct
26 Jan 2026 14:15:56 tty: response: [14][84][01][93][04]
26 Jan 2026 14:15:56 conn[192.168.1.10]: state now is CONN_RESP
26 Jan 2026 14:15:56 tty: state now is TTY_PAUSE
26 Jan 2026 14:15:56 conn_loop(): select(): max_sd = 5, t_out = 000000:000000
26 Jan 2026 14:15:56 conn_loop(): select() returns 1
26 Jan 2026 14:15:56 conn[192.168.1.10]: state now is CONN_HEADER
26 Jan 2026 14:15:56 conn_loop(): select(): max_sd = 5, t_out = 000000:000000
26 Jan 2026 14:15:56 conn_loop(): select() returns 1
26 Jan 2026 14:15:56 conn[192.168.1.10]: state now is CONN_RQST_FUNC
26 Jan 2026 14:15:56 conn_loop(): select(): max_sd = 5, t_out = 000000:000000
26 Jan 2026 14:15:56 conn_loop(): select() returns 1
26 Jan 2026 14:15:56 conn[192.168.1.10]: read request fc 4
26 Jan 2026 14:15:56 conn[192.168.1.10]: state now is CONN_RQST_TAIL
26 Jan 2026 14:15:56 conn[192.168.1.10]: request: [14][04][2a][93][00][0a]
26 Jan 2026 14:15:56 conn[192.168.1.10]: state now is CONN_TTY
26 Jan 2026 14:15:56 conn_loop(): select(): max_sd = 4, t_out = 000000:000000
26 Jan 2026 14:15:56 conn_loop(): select() returns 0
26 Jan 2026 14:15:56 tty: state now is TTY_RQST
26 Jan 2026 14:15:56 conn_loop(): select(): max_sd = 4, t_out = 000000:000060
26 Jan 2026 14:15:56 conn_loop(): select() returns 1
26 Jan 2026 14:15:56 tty: written 8 bytes
26 Jan 2026 14:15:56 tty: request written (total 8 bytes)
26 Jan 2026 14:15:56 tty: state now is TTY_RESP
26 Jan 2026 14:15:56 tty: estimated 25 bytes, waiting 518905 usec
26 Jan 2026 14:15:56 conn_loop(): select(): max_sd = 4, t_out = 000000:000000
26 Jan 2026 14:15:56 conn_loop(): select() returns 1
26 Jan 2026 14:15:56 tty: read 5 bytes
26 Jan 2026 14:15:56 tty: rx len changed from 25 to 6
26 Jan 2026 14:15:56 tty: read 5 bytes of 6, offset 0
26 Jan 2026 14:15:56 conn_loop(): select(): max_sd = 4, t_out = 000000:000000
26 Jan 2026 14:15:57 conn_loop(): select() returns 0
26 Jan 2026 14:15:57 tty: response read (total 5 bytes, offset 0 bytes)
26 Jan 2026 14:15:57 tty: response is correct
26 Jan 2026 14:15:57 tty: response: [14][84][01][93][04]
26 Jan 2026 14:15:57 conn[192.168.1.10]: state now is CONN_RESP
26 Jan 2026 14:15:57 tty: state now is TTY_PAUSE
26 Jan 2026 14:15:57 conn_loop(): select(): max_sd = 5, t_out = 000000:000000
26 Jan 2026 14:15:57 conn_loop(): select() returns 1
26 Jan 2026 14:15:57 conn[192.168.1.10]: state now is CONN_HEADER
26 Jan 2026 14:15:57 conn_loop(): select(): max_sd = 5, t_out = 000000:000000
26 Jan 2026 14:15:57 conn_loop(): select() returns 0
26 Jan 2026 14:15:57 tty: state now is TTY_READY
26 Jan 2026 14:15:57 conn_loop(): select(): max_sd = 5, t_out = 000000:000060

Any idea?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions