weewx-interceptor and Python3 on Raspbian 10 buster?

366 views
Skip to first unread message

lord...@gmail.com

unread,
Jan 15, 2022, 3:54:51 PM1/15/22
to weewx-user
I'm running Raspbian 10 (buster), fully patched as of today, on a Raspberry Pi 4.

Manually testing weewx-interceptor with python2 works fine, but it fails when using Python 3.  Since Python2 is no longer supported by the Python developers and my WeeWx installation is running under Python3, I'm hoping someone has an idea how to get this to work.

Python2:

PYTHONPATH=/usr/share/weewx python2 /usr/share/weewx/user/interceptor.py --device=observer --mode=sniff --iface=wlan0 --filter="src 192.168.4.10 and dst port 80"
mapped packet: {'pressure': 30.05, 'outHumidity': 40.0, 'UV': 0.0, 'radiation': 26.79, 'rain': None, 'dateTime': 1642278699, 'windDir': 315.0, 'outTemp': 7.9, 'windSpeed': 8.1, 'inHumidity': 26.0, 'inTemp': 72.9, 'windGust': 9.2, 'usUnits': 1}

Python3:

PYTHONPATH=/usr/share/weewx python3 /usr/share/weewx/user/interceptor.py --device=observer --mode=sniff --iface=wlan0 --filter="src 192.168.4.10 and dst port 80"
Exception in thread ServerThread:
Traceback (most recent call last):
  File "/usr/lib/python3.7/threading.py", line 917, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.7/threading.py", line 865, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/share/weewx/user/interceptor.py", line 434, in run_server
    self._server.run()
  File "/usr/share/weewx/user/interceptor.py", line 490, in run
    self.decode_ip_packet(0, pkt, ts)
  File "/usr/share/weewx/user/interceptor.py", line 517, in decode_ip_packet
    (_timestamp, _pktlen, _fmt_bytes(data)))
  File "/usr/share/weewx/user/interceptor.py", line 337, in _fmt_bytes
    return ' '.join(['%02x' % ord(x) for x in data])
  File "/usr/share/weewx/user/interceptor.py", line 337, in <listcomp>
    return ' '.join(['%02x' % ord(x) for x in data])
TypeError: ord() expected string of length 1, but int found

Looking at the Github repo for interceptor shows that it hasn't been updated in a couple of years (https://github.com/matthewwall/weewx-interceptor).  Is the project still being maintained?

It looks like "kq6up" filed issue #90 on 18 Dec 2020 with the same problem that I am seeing, but no response to their posting.

https://github.com/matthewwall/weewx-interceptor/issues/90

A few of the other comments have said to install the python-pypcap package instead of the python-libpcap, but that made no change on my system.

Others have mentioned installing with "pip3 install pycap" instead of the apt package, but that also made no difference.

Anyone have any thoughts on this?

Thank you,

-Dj

vince

unread,
Jan 15, 2022, 5:11:38 PM1/15/22
to weewx-user
I asked the same question in another thread last week.  I got nowhere trying to get the pypcap stuff going on debian11 or debian10 with python3, but since it was a nice-to-have only, I basically gave up trying.

Francesco

unread,
Jan 16, 2022, 1:17:11 AM1/16/22
to weewx-user
I'm using the interceptor driver and weewx on Debian 10 with python 3 without any issues. If you give me some time I can check my configuration and installed packages and let you know

Rainer Lang

unread,
Jan 16, 2022, 4:34:34 AM1/16/22
to weewx...@googlegroups.com
I'm also using the interceptor driver on Python 3.9.2 on Raspbian 11 - no issue
BUT
the interceptor driver is most of the time used in listen mode and not in sniffing mode.
In listen mode you instruct your console to post directly to your server (single IP address and port) where the interceptor driver is listening.

In sniffing mode the console sends a broadcast and the interceptor driver tries to "fish", sniff these messages from the network traffic and interpret them.
That's what Vince is looking for.
However, if you have a sniffing use case running on Debian 10, you are most welcome to share your configuration.
--
You received this message because you are subscribed to the Google Groups "weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/e5e746bd-18c2-49b4-be8b-1c4ff55e769bn%40googlegroups.com.


Message has been deleted
Message has been deleted
Message has been deleted

Francesco Venti

unread,
Jan 30, 2022, 7:16:30 PM1/30/22
to weewx...@googlegroups.com
I've checked and I'm using the interceptor in listen mode. I've tried to have a look nonetheless and (I think) I've made some progress. I've used a fake ecowitt protocol simulator to send data to the test machine, since I don't have a real station right now. Here the results using python2:


Cattura1.PNG
I've tried to edit the interceptor.py (line 373), changing ord(x) with x ( quoting stack overflow " using Python 3 where indexing a bytes object returns an integer ... no need to use ord()") and it seems to give the same output of python2 as you can see:
Cattura2.PNG
Now I don't know if it actually works or not, the data I'm sending are invalid (weewx gives a invalid packet header exeption both with python2 and 3, but it could be caused by the fake generator)


Il dom 30 gen 2022, 02:03 Boston Tom <tka...@gmail.com> ha scritto:
Similar issue.  Everything was working fine for several years until I decided to "upgrade" Python.  Now I cannot load pypcap and therefore cannot "sniff" any packets.  As soon as I put "mode = sniff" into the weew.conf file, syslog reports an error. When I resort to listen mode, it isn't capturing that data either.  Let me know if there are any known good solutions or workarounds.  Thank you.
Reply all
Reply to author
Forward
0 new messages