junzis / pyModeS

Python decoder for Mode S and ADS-B signals
GNU General Public License v3.0
529 stars 151 forks source link

Exception thrown from pyModeS/decoder/common.py", line 8, in hex2bin -- ValueError: invalid literal for int() with base 16: '8DB5AEC399146B0A40080A1A45C2L' #50

Closed davedice closed 4 years ago

davedice commented 4 years ago

I downloaded pyModes-master on 2019-9-9 and installed it in-place and then encountered an exception. The same error occurs if I use a traditional "pip install ." command instead of in-place installation.

I'm running off-the-shelf 64-bit ubuntu 19.04 (fully updated) on a Toshiba laptop, although I could reproduce the the same issue on a similarly configured ubuntu 19.04 skylake desktop system.

I'm using an RTL-SDR v3 dongle, which is known-good and works well with a variety of applications.
After observing the failure, I checked the hardware with gqrx and all is well.

It's very likely I have some local configuration issue or have the dependencies wrong.

Thanks again for providing pyModeS. It looks promising.

Installation

mkdir run; pip install --target run . Processing /home/dice/Downloads/pyModeS-master Collecting argparse (from pyModeS==2.2) Using cached https://files.pythonhosted.org/packages/f2/94/3af39d34be01a24a6e65433d19e107099374224905f1e0cc6bbe1fd22a2f/argparse-1.4.0-py2.py3-none-any.whl Collecting numpy (from pyModeS==2.2) Using cached https://files.pythonhosted.org/packages/d7/b1/3367ea1f372957f97a6752ec725b87886e12af1415216feec9067e31df70/numpy-1.16.5-cp27-cp27mu-manylinux1_x86_64.whl Collecting pyrtlsdr (from pyModeS==2.2) Using cached https://files.pythonhosted.org/packages/50/21/8c58fbe41f3b08e6a147e892156151430c30eb863f5e9e7ba12acb9b14a3/pyrtlsdr-0.2.91-py2.py3-none-any.whl Collecting pyzmq (from pyModeS==2.2) Using cached https://files.pythonhosted.org/packages/27/d7/d8aa6dde15f077f20efdf657367e26cbd2fcb96d182d0e690be9b3f2b76c/pyzmq-18.1.0-cp27-cp27mu-manylinux1_x86_64.whl Building wheels for collected packages: pyModeS Running setup.py bdist_wheel for pyModeS ... done Stored in directory: /home/dice/.cache/pip/wheels/cf/6e/62/d368ad6d2ca558906f55d91c334075b9bf3afa4fd734431052 Successfully built pyModeS Installing collected packages: argparse, numpy, pyrtlsdr, pyzmq, pyModeS Successfully installed argparse-1.4.0 numpy-1.16.5 pyModeS-2.2 pyrtlsdr-0.2.91 pyzmq-18.1.0

Execution

append ./run and ./run/bin to PATH and PYTHONPATH ./run/bin/modeslive --source rtlsdr

The following is stderr/stdout :

Found Rafael Micro R820T tuner [R82XX] PLL not locked! Exact sample rate is: 2000000.052982 Hz Allocating 15 zero-copy buffers

File "_ctypes/callbacks.c", line 315, in 'calling callback function' File "/home/dice/Downloads/pyModeS-master/run/rtlsdr/rtlsdr.py", line 628, in _bytes_converter_callback self._callback_bytes(values, context) File "/home/dice/Downloads/pyModeS-master/run/rtlsdr/rtlsdr.py", line 675, in _samples_converter_callback self._callback_samples(iq, context) File "/home/dice/Downloads/pyModeS-master/run/pyModeS/extra/rtlreader.py", line 131, in _read_callback messages = self._process_buffer() File "/home/dice/Downloads/pyModeS-master/run/pyModeS/extra/rtlreader.py", line 75, in _process_buffer if self._check_msg(msghex): File "/home/dice/Downloads/pyModeS-master/run/pyModeS/extra/rtlreader.py", line 101, in _check_msg df = pms.df(msg) File "/home/dice/Downloads/pyModeS-master/run/pyModeS/decoder/common.py", line 44, in df msgbin = hex2bin(msg) File "/home/dice/Downloads/pyModeS-master/run/pyModeS/decoder/common.py", line 8, in hex2bin binstr = bin(int(hexstr, 16))[2:].zfill(int(num_of_bits)) ValueError: invalid literal for int() with base 16: '8DB5AEC399146B0A40080A1A45C2L'

On the odd chance that the trailing long "L" was causing the problem, I modified common.py to discard any trailing non-hex characters. That inhibited the error, but I didn't see any aircraft, although running dump1090 a minute later showed over 60.

Shutdown

I also observed the following warnings after ctrl-c :

Traceback (most recent call last): File "_ctypes/callbacks.c", line 315, in 'calling callback function' File "/home/dice/Downloads/pyModeS-master/run/rtlsdr/rtlsdr.py", line 628, in _bytes_converter_callback Process Process-3: Exception KeyError: KeyError(140077307160384,) in <module 'threading' from '/usr/lib/python2.7/threading.pyc'> ignored Segmentation fault (core dumped)

junzis commented 4 years ago

@davedice - thank you for raising this. There seem to be two separate problems. Let's try to sovle the odd "L" first. Would you please tell me which Python version you are running?

junzis commented 4 years ago

I did a quick check the "L" seems to be an unwanted thing in Python 2, which is then removed in Python 3. I haven't thoroughly tested the new functionalities with Python 2... I will try to fix this in the coming days.

Btw, most of the project nowadays are transforming to Python 3. At some point, we will probably drop the support for Python 2.

davedice commented 4 years ago

Thanks for the fast response. I just tried virtualenv with /usr/bin/python3.7 and, with the latest source, all worked well. Would you like to close the issue?

junzis commented 4 years ago

Let's keep it open for now. I will try to do some debugging with Python 2. I still hope this can work with Python 2 for a bit longer :)

davedice commented 4 years ago

Thanks again, -Dave

junzis commented 4 years ago

This Python 2 bug should be fixed now.