[SOLVED] Knx gateway flapping (online/offline) and question about port 3671

depends on how you did your configuration (be aware that I only set the parameters which differ from default)

what’s the output of

systemctl status knxd.service

@stamate_viorel @Udo_Hartmann
I am running knxd on openwrt router, with usb interface connected to it.

these are the defaults of the service

/usr/lib/knxd_args --eibaddr=0.0.1 --client-addrs=0.0.2:10 --error=0 --listen-tcp=6720 --Name=KNX2 --Routing --Tunnelling --Discovery --Server=224.0.23.12 --listen-local=/var/run/knxd --trace=0 -b usb:1:2:1

6720 is the default TCP port
3671 is the default UDP port

but openhab knx binding does not care about that. it only wants you to set 3671 regardless if you set tunnel or router.
so I ended up configuring nothing and let it auto detect it or use internal defaults.

Bridge knx:ip:bridge [
    ipAddress="192.168.4.1",
    type="TUNNEL"
] {

it still goes offline at least once per day.

maybe I should install knxd on the rpi where openhab is running…

/usr/lib/knxd_args  --error=0 --Name=KNX2 --Discovery --Tunnelling --Routing --Server --listen-local=/var/run/knxd --trace=0 -b usb:1:2:1
Network interfaces
Local server
The -i or --listen-tcp option tells knxd to accept client connections on a specific IP. The -u or --listen-local option tells knxd to accept client connections on a Unix socket. You want one or both of these if you have client programs which specifically talk to knxd. This includes the tools, examples and language bindings which come with knxd.

Multicast server
The -S or --Server option starts a multicast server; the default is port 3671 on address 224.0.23.12. Most likely, you really want options -R -S or --Routing --Server so that knxd actually routes multicast data. This is the network mode ETS uses when you attach to an interface. Note that multicast packets get blocked by some WLAN APs.

Tunneling server
-T -S or --Tunnelling --Server starts a UDP-based server to which clients can connect. This is the network mode ETS uses if you attach to a specific host. Most likely, you really want -n HOSTNAME -D -T -R -S or --Name=HOSTNAME --Discovery --Tunnelling --Routing --Server.

Multicast client
The -b ip: option also connects to multicast; however, it just treats the multicast address like a glorified KNX wire with no bells and whistles. Use this if some other device (knxd or otherwise) provides the server features.

Some older and/or buggy WLAN gateways don't forward multicast data.

Non-Multicast client
Use -b ipt:your-knx-gateway or -b iptn:your-knx-gateway. depending on whether you need address translation.

Some older KNX/IP interfaces don't really work with this method. It's recommended to use multicast wherever possible.

Single-server mode
With the exception of multicast, technically a server is not an interface – it creates a new one for every connecting client. Thus, starting knxd -u or knxd -TS just to facilitate a couple of clients to talk to each other (i.e. not using any other interface option) makes sense – in theory. However, in actual practice this is a configuration error because it's almost never what you actually want. If you really intent to run knxd that way, you need to add a dummy interface.

yeah, it works so unstable, I guess it’s a bug in knx bundle, because the gateway (knxd) is working fine, listening to port, restart of knxd doesnt help, but restart of knx binding helps. all devices are on 100mbit wire, no wifi involved.
so I “solved” it with a rule, like many people before me:

rule "KNX Binding Restart"
when
    Thing "knx:ip:bridge" changed to OFFLINE
then
    executeCommandLine("sudo /usr/bin/ssh -p 8101 -i /home/pi/openhab.id_rsa openhab@localhost bundle:restart org.openhab.binding.knx", 6000)
end
1 Like

At least it’s no general bug, as knx here is working rock stable (since openHAB1.0 with only exceptions as openHAB2 came out and there was not knx2 binding yet)

Well, as I mentioned in my first post, its rock solid to most of the people, but there are cases of instability

Knx2 mentioned here

Here

Also Here

Here…

Did you try the knxd configuration that I proposed ? Also keep in mind tunnel is unicast and router is multicast maybe your networking is playing tricks on you ?
It’s pretty easy to blame openhab sometimes but keep in mind the people that developed this spend a lot of time on it and Knox is one of the oldest binding.

the implementation of knxd on openwrt is strange, it has /etc/knxd.ini that it completely ignores and starts with whatever settings it wants.
I will install knxd on raspbian where oh is running and run your proposed config from there. on debian i hope i will be able to edit knxd.ini or knxd.conf and define the start options that i want…thanks for your help

You can also search Calimero knx that is what the binding is using. As a side note the knxd package hasn’t been maintained in openwrt for 4 years…
But why don’t use the knx binding directly in openhab seeing you can move the USB ?
https://www.openhab.org/addons/bindings/knx/#serial-gateway

I was thinking i need a real serial TPUART device to use the serial-gateway with the binding, but if it works with usb crap, i will most definitely give it a go, as I dont really need to route it through the network, the devices are next to each other.

the version i’m running
[OpenWrt Wiki] package: knxd
is from 2022 ( 0.14.53)
actually when I installed knxd on rpi buster, it took from buster repository 0.14.30 :slight_smile:
so router is more up to date then my rpi :slight_smile:

What usb are you using ??? That connects to the bus without it ??

i use some usb interface, and as I understood TPUART is better then usb because it behaves as serial port, but I may be mistaken…

Just for my knowledge do you have a model ?

its ESYLUX
EC10430541 - ESYLUX

For a second you got me but KNX USB interface uses a TPUART (Twisted Pair Universal Asynchronous Receiver-Transmitter) to communicate with KNX devices on the bus so your included that is why I was curious. Try directly to use the serial connection of openhab and post the result.

but my device is just a USB device, it does not create /dev/ttyXXX…

The subnet connection type is one of
{ “ip”, “knxip”, “ft12”, “usb”, “tpuart”, “user-supplied”, “virtual”, “emulate” }.

The KNX communication medium is one of
{ “tp1” (default), “pl110”, “knxip”, “rf” }.

so the communication medium is twisted pair, but device type can be usb, uart, ip…
…and mine is unfortunately usb.
I would love to try it, but I dont see how…I’m trying to force the udev rules to create a symlink as dev/ttySomething for this crappy device, but it doesnt create it…

what i’m saying is my device is not usb-to-serial, its just pure usb device

dmesg | grep -i usb
lsusb

Post here the above

root@knx:/etc/openhab# dmesg | grep -i usb
[    0.142426] usbcore: registered new interface driver usbfs
[    0.142512] usbcore: registered new interface driver hub
[    0.142605] usbcore: registered new device driver usb
[    1.982256] usbcore: registered new interface driver lan78xx
[    1.985059] usbcore: registered new interface driver smsc95xx
[    2.959772] dwc_otg 3f980000.usb: DWC OTG Controller
[    2.962080] dwc_otg 3f980000.usb: new USB bus registered, assigned bus number 1
[    2.964528] dwc_otg 3f980000.usb: irq 89, io mem 0x00000000
[    2.971878] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002, bcdDevice= 5.10
[    2.976572] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    2.979081] usb usb1: Product: DWC OTG Controller
[    2.981533] usb usb1: Manufacturer: Linux 5.10.103-v7+ dwc_otg_hcd
[    2.984017] usb usb1: SerialNumber: 3f980000.usb
[    2.987264] hub 1-0:1.0: USB hub found
[    2.993762] usbcore: registered new interface driver usb-storage
[    3.027581] usbcore: registered new interface driver usbhid
[    3.030191] usbhid: USB HID core driver
[    3.324833] usb 1-1: new high-speed USB device number 2 using dwc_otg
[    3.565191] usb 1-1: New USB device found, idVendor=0424, idProduct=2514, bcdDevice= b.b3
[    3.570352] usb 1-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[    3.573921] hub 1-1:1.0: USB hub found
[    3.894851] usb 1-1.1: new high-speed USB device number 3 using dwc_otg
[    4.025257] usb 1-1.1: New USB device found, idVendor=0424, idProduct=2514, bcdDevice= b.b3
[    4.030757] usb 1-1.1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[    4.034517] hub 1-1.1:1.0: USB hub found
[    4.364883] usb 1-1.1.3: new high-speed USB device number 4 using dwc_otg
[    4.509489] usb 1-1.1.3: New USB device found, idVendor=1908, idProduct=1320, bcdDevice= 1.00
[    4.515580] usb 1-1.1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[    4.521808] usb 1-1.1.3: Product: Mass storage
[    4.525169] usb 1-1.1.3: Manufacturer: Generic
[    4.528288] usb 1-1.1.3: SerialNumber: AB5595148119
[    4.545780] usb-storage 1-1.1.3:1.0: USB Mass Storage device detected
[    4.564971] scsi host0: usb-storage 1-1.1.3:1.0
[    4.614925] usb 1-1.2: new high-speed USB device number 5 using dwc_otg
[    4.758747] usb 1-1.2: New USB device found, idVendor=0835, idProduct=8500, bcdDevice= 1.09
[    4.764377] usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[    4.767574] usb 1-1.2: Product: USB2.0 Hub
[    4.770352] usb 1-1.2: Manufacturer: Action Star
[    4.774440] hub 1-1.2:1.0: USB hub found
[    4.904887] usb 1-1.1.1: new high-speed USB device number 6 using dwc_otg
[    5.035447] usb 1-1.1.1: New USB device found, idVendor=0424, idProduct=7800, bcdDevice= 3.00
[    5.040721] usb 1-1.1.1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[    5.135058] usb 1-1.2.1: new high-speed USB device number 7 using dwc_otg
[    5.268684] usb 1-1.2.1: New USB device found, idVendor=0835, idProduct=8501, bcdDevice= 6.09
[    5.274145] usb 1-1.2.1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[    5.279967] usb 1-1.2.1: Product: USB HID
[    5.282814] usb 1-1.2.1: Manufacturer: Action Star
[    5.305454] hid-generic 0003:0835:8501.0001: hiddev96,hidraw0: USB HID v1.11 Device [Action Star USB HID] on usb-3f980000.usb-1.2.1/input0
[    5.414925] usb 1-1.2.4: new full-speed USB device number 8 using dwc_otg
[    5.568536] usb 1-1.2.4: New USB device found, idVendor=0451, idProduct=16a8, bcdDevice= 0.09
[    5.574682] usb 1-1.2.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[    5.580831] usb 1-1.2.4: Product: TI CC2531 USB CDC
[    5.586934] usb 1-1.2.4: Manufacturer: Texas Instruments
[    5.586947] usb 1-1.2.4: SerialNumber: __0X00124B001949B82D
[    5.686642] usb 1-1.2.5: new high-speed USB device number 9 using dwc_otg
[    5.818851] usb 1-1.2.5: New USB device found, idVendor=0835, idProduct=8500, bcdDevice= 1.09
[    5.824353] usb 1-1.2.5: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[    5.824368] usb 1-1.2.5: Product: USB2.0 Hub
[    5.824387] usb 1-1.2.5: Manufacturer: Action Star
[    5.846049] hub 1-1.2.5:1.0: USB hub found
[    6.164897] usb 1-1.2.5.1: new high-speed USB device number 10 using dwc_otg
[    6.298763] usb 1-1.2.5.1: New USB device found, idVendor=0835, idProduct=8502, bcdDevice= 6.09
[    6.298792] usb 1-1.2.5.1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[    6.298807] usb 1-1.2.5.1: Product: USB HID
[    6.298822] usb 1-1.2.5.1: Manufacturer: Action Star
[    6.303015] hid-generic 0003:0835:8502.0002: hiddev97,hidraw1: USB HID v1.11 Device [Action Star USB HID] on usb-3f980000.usb-1.2.5.1/input0
[    6.404875] usb 1-1.2.5.4: new full-speed USB device number 11 using dwc_otg
[    6.536861] usb 1-1.2.5.4: New USB device found, idVendor=0658, idProduct=0200, bcdDevice= 0.00
[    6.536885] usb 1-1.2.5.4: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[    8.666205] usbcore: registered new interface driver brcmfmac
[    8.817189] usbcore: registered new interface driver uas
[    8.878065] cdc_acm 1-1.2.4:1.0: ttyACM0: USB ACM device
[    8.883003] cdc_acm 1-1.2.5.4:1.0: ttyACM1: USB ACM device
[    8.883920] usbcore: registered new interface driver cdc_acm
[    8.883937] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters
[   10.817531] ext4 filesystem being mounted at /mnt/usb supports timestamps until 2038 (0x7fffffff)
[2011424.212660] usb 1-1.1.2: new full-speed USB device number 12 using dwc_otg
[2011424.358454] usb 1-1.1.2: New USB device found, idVendor=28c2, idProduct=000c, bcdDevice= 2.01
[2011424.358466] usb 1-1.1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[2011424.358474] usb 1-1.1.2: Product: KNX-USB Inteface
[2011424.358482] usb 1-1.1.2: Manufacturer: ESYLUX
[2011424.358489] usb 1-1.1.2: SerialNumber: 0072130B0148
[2011424.372371] hid-generic 0003:28C2:000C.0003: hiddev98,hidraw2: USB HID v1.10 Device [ESYLUX KNX-USB Inteface] on usb-3f980000.usb-1.1.2/input0
[2012278.435934] gusbcfg_show(9580bbb3) -> platform_dev aa1853cb, otg_dev 8e3aa43b
[2012278.438821] dwc_otg 3f980000.usb: Invalid offset (0xffffffff)
[2012279.628686] GUSBCFG         @0xBB80000C : 0x20001700
[2012313.850220] dwc_otg 3f980000.usb: Invalid offset (0xffffffff)
[2012314.207588] gusbcfg_show(9580bbb3) -> platform_dev aa1853cb, otg_dev 8e3aa43b
[2012314.207905] GUSBCFG         @0xBB80000C : 0x20001700
[2012882.609574] usb 1-1.1.2: USB disconnect, device number 12
[2012887.259352] usb 1-1.1.2: new full-speed USB device number 13 using dwc_otg
[2012887.406078] usb 1-1.1.2: New USB device found, idVendor=28c2, idProduct=000c, bcdDevice= 2.01
[2012887.406093] usb 1-1.1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[2012887.406100] usb 1-1.1.2: Product: KNX-USB Inteface
[2012887.406107] usb 1-1.1.2: Manufacturer: ESYLUX
[2012887.406113] usb 1-1.1.2: SerialNumber: 0072130B0148
[2012887.418043] hid-generic 0003:28C2:000C.0004: hiddev98,hidraw2: USB HID v1.10 Device [ESYLUX KNX-USB Inteface] on usb-3f980000.usb-1.1.2/input0
root@knx:/etc/openhab# lsusb
Bus 001 Device 011: ID 0658:0200 Sigma Designs, Inc. Aeotec Z-Stick Gen5 (ZW090) - UZB
Bus 001 Device 010: ID 0835:8502 Action Star Enterprise Co., Ltd
Bus 001 Device 009: ID 0835:8500 Action Star Enterprise Co., Ltd
Bus 001 Device 008: ID 0451:16a8 Texas Instruments, Inc.
Bus 001 Device 007: ID 0835:8501 Action Star Enterprise Co., Ltd
Bus 001 Device 005: ID 0835:8500 Action Star Enterprise Co., Ltd
Bus 001 Device 004: ID 1908:1320 GEMBIRD PhotoFrame PF-15-1
Bus 001 Device 013: ID 28c2:000c
Bus 001 Device 006: ID 0424:7800 Standard Microsystems Corp.
Bus 001 Device 003: ID 0424:2514 Standard Microsystems Corp. USB 2.0 Hub
Bus 001 Device 002: ID 0424:2514 Standard Microsystems Corp. USB 2.0 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
root@knx:/etc/openhab#

its this one
ID 28c2:000c

while i have it connected to this machine, i will try knxd here on debian, maybe it will work better then openwrt…

ls /dev/ttyACM*

i have acm0 and acm1 (my zigbee2mqtt CC2558 and zwave aeotec gateway. this knx interface is HID crap.