knxd / PyKNyX

Python KNX Framework
GNU General Public License v3.0
10 stars 7 forks source link

Can't send messages, but can receive #1

Closed jcbastosportela closed 6 years ago

jcbastosportela commented 6 years ago

I've been trying to use PyKNyX with a RPi 3 in order to create a "Wireless KNX device".

I have a BeagleBone + TPUART running KNXD 0.14.15 (args: "-e 9.0.0 -E 9.9.200:14 -DTRS -b tpuarts:/dev/ttyO4"); it works all right. I've been using before as my ETS interface + router: I successfully get the multicast from other router (Weinzierl) on the same network.

Now I have a RPi3 in which I installed KNXD 0.14.13 + PyKNyX. I want this to communicate in multicast; however I just partially succeeded: When I send some KNX message via ETS to the TP bus I do get it in the RPi, but when the RPi attempts to answer I don't get the message in the TP bus. I am pretty sure that I'm getting some of settings wrong, but I can't figure out what. The KNXD args are: "-e 10.0.0 -E 9.0.200:8 -u /tmp/eib -b ip:".

I'd be most happy if some one would be of help in this.

UPDATE1{ I tried with "knxtool" something like: knxtool groupwrite local: 1/2/3 0 and it worked (= I could get the message routed from the RPi to BeagleBonethe:TP bus). But still can't make PyKNyX to send... }

UPDATE2{ 1 - I've tried to connect to remote IP router (KNXD running with -e 9.0.0 -E 9.9.200:3 -RS -b tpuarts:/dev/ttyO4) but PyKNyX won't connect. I've monitored with wireshark and no messages are sent when the RPi3 is not running KNXD; 2 - I've tried to add the -RS to the RPi, but together with -b ip: it creates loops; 3 - I've tried to put the KNXD (TP<->IP) server in other multicast (-e 9.0.0 -E 9.9.200:3 -R --Server=224.11.11.11:3672 -b tpuarts:/dev/ttyO4) and the RPi3 like this (-e 11.0.0 -E 11.1.1:8 -RS -u /tmp/eib -b ip:224.11.11.11:3672): this works for one device, but when I start other RPi3 with same settings the loops start (obviously). 4 - I tried some other hacks inside the PyKNyX that didn't help. }

Thank you!

jcbastosportela commented 6 years ago

Okay, I've figured out the problem.

First of all

It is utterly wrong trying to use on KNXD per pyknyx! Trying to do so results in setting N IP routers in the same network leading to the loops.

Why did I try to do so? Because when I tried to run pyknyx remotely I noticed that it wasn't communicating with the KNXD (with -R) existing on the same network. But I noticed it could communicate with a KNXD running locally, so I started trying to use KNXD locally which would connect to the remote KNXD (which uses tpuart as driver); but for this, the local KNXD has to provide a router interface (again -R --Server=[other_multicast_group]) (). This worked okay when there was just one pyknyx; when I was duplicating this setup there were again tow -R running on same multicast (total mess). I could set different multicasts in all devices but this isn't pretty.

Second

The PyKNyX 1.0.1 implementation isn't going to connect to a remote router (KNXD) due to this line: localAddr = socket.gethostbyname(socket.gethostname()) in the file /pknyx/stack/transceiver/udpTransceiver.py. because it will very return the localhost's IP (generally 127.0.0.1); this will be used in the bind of the UPD multicast socket, so the socket will multicast just for the 'lo' interface (local interface). The localAddr should be set to the IP of the network interface that we want to use for the broadcast, in my case 'wlan0' which as the IP 12.0.0.66 (eg).

Third

In the master this problem was already fixed by using localAddr ='0.0.0.0'

Anyway, this problem helped me studying deeper KNXD.