bastibl / gr-keyfob

Transceiver for Hella wireless car key fobs.
172 stars 31 forks source link

object has no attribute 'parse_packet' #7

Closed kees-closed closed 5 years ago

kees-closed commented 5 years ago

When I try to run keyfob_decode_wav.py, keyfob_rx.py or keyfob_tx.py, I get the following error when I run keyfob_rx.py:

 <<< Welcome to GNU Radio Companion 3.7.13.4 >>>

Block paths:
    /usr/share/gnuradio/grc/blocks
    /usr/local/share/gnuradio/grc/blocks

Loading: "/home/kjong/git/gr-keyfob/apps/keyfob_rx.grc"
>>> Done

Loading: "/home/kjong/git/gr-keyfob/apps/keyfob_decode_wav.grc"
>>> Done

Generating: '/home/kjong/git/gr-keyfob/apps/keyfob_rx.py'

Executing: /usr/bin/python2 -u /home/kjong/git/gr-keyfob/apps/keyfob_rx.py

gr-osmosdr v0.1.x (0.1.5git) gnuradio 3.7.13.4
built-in source types: file fcd rtl rtl_tcp uhd hackrf rfspace airspy soapy redpitaya 
[INFO] [UHD] linux; GNU C++ version 8.1.1 20180712 (Red Hat 8.1.1-5); Boost_106600; UHD_3.12.0.0
Using device #0 Realtek RTL2838UHIDIR SN: 00000001
Found Fitipower FC0012 tuner
Exact sample rate is: 1000000,026491 Hz
Traceback (most recent call last):
  File "/home/kjong/git/gr-keyfob/apps/keyfob_rx.py", line 262, in <module>
    main()
  File "/home/kjong/git/gr-keyfob/apps/keyfob_rx.py", line 250, in main
    tb = top_block_cls()
  File "/home/kjong/git/gr-keyfob/apps/keyfob_rx.py", line 188, in __init__
    self.keyfob_parse_packet_0 = keyfob.parse_packet()
AttributeError: 'module' object has no attribute 'parse_packet'

>>> Done

Also the other files return the same error, even when using the included wav files. Do you have any suggestions? Could it be that sys.path doesn't include keyfob properly? I had to symlink the package since /usr/local wasn't included by default with: ln -s /usr/local/lib64/python2.7/site-packages/keyfob /usr/lib/python2.7/site-packages/..

bastibl commented 5 years ago

Usually you do not symlink but adapt the PYTHONPATH environment variable. Can you try this please.

kees-closed commented 5 years ago

Thank you for the quick reply. I removed the symlink and exported export PYTHONPATH=$PYTHONPATH:/usr/local/lib64/python2.7/site-packages. In Python the /usr/local/lib64 is now available. I can also import keyfob. However, I still get the same 'parse_packet' error. Does it work for you? If it does then I'll close it, then I guess I'm doing something wrong and I should troubleshoot it better.

>>> import sys
>>> print(sys.path)
['', '/home/user/git/gr-keyfob/apps', '/usr/local/lib64/python2.7/site-packages', '/usr/lib/python27.zip', '/usr/lib64/python2.7', '/usr/lib64/python2.7/plat-linux2', '/usr/lib64/python2.7/lib-tk', '/usr/lib64/python2.7/lib-old', '/usr/lib64/python2.7/lib-dynload', '/usr/l
ib64/python2.7/site-packages', '/usr/lib64/python2.7/site-packages/gtk-2.0', '/usr/lib64/python2.7/site-packages/wx-3.0-gtk3', '/usr/lib/python2.7/site-packages']
>>> import keyfob
bastibl commented 5 years ago

I just checked it again and it works for me:tm:. I'd assume it's a problem with swig. Do you have it installed? Did you manage to install other OOTs?

kees-closed commented 5 years ago

I've swig-3.0.12-21.fc29.x86_64 installed. This is the first time I've worked with GNU Radio in general and it's the first OOT I've installed. I'll fiddle a bit more with it and maybe I'll try it in a different distribution. Thanks!

bastibl commented 5 years ago

Another idea would be to check if Swig is actually found by Cmake. You should have a CMakeCache.txt file in your build directory. Search for SWIG and PYTHON_LIBRARY to check if they are set. Otherwise Python bindings for the C++ blocks will not be generated: https://github.com/bastibl/gr-keyfob/blob/master/swig/CMakeLists.txt#L31-L35

kees-closed commented 5 years ago

As far I can tell Swig is found.

 cmake ..
-- Build type not specified: defaulting to release.
-- Boost version: 1.66.0
-- Found the following Boost libraries:
--   filesystem
--   system
Checking for GNU Radio Module: RUNTIME
 * INCLUDES=/usr/include
 * LIBS=/lib64/libgnuradio-runtime.so;/lib64/libgnuradio-pmt.so
GNURADIO_RUNTIME_FOUND = TRUE
-- 
-- Checking for module SWIG
-- Found SWIG version 3.0.12.
-- Configuring done
-- Generating done
-- Build files have been written to: /home/kjong/git/gr-keyfob/build
bastibl commented 5 years ago

Very tricky -.- Maybe this hides an import error: https://github.com/bastibl/gr-keyfob/blob/master/python/__init__.py#L30-L31 Can you please remove the try/except and import the module again?

kees-closed commented 5 years ago

This seems to be the problem. When I remove the try/except it returns the same error as it does in an interpreter. SELinux permissions are also correct for /usr/local.

>>> from keyfob_swig import *
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named keyfob_swig

keyfob_swig.py is listed

/usr/local/lib64/python2.7/site-packages/keyfob
├── __init__.py
├── __init__.pyc
├── __init__.pyo
├── keyfob_swig.py
├── keyfob_swig.pyc
├── keyfob_swig.pyo
├── _keyfob_swig.so
├── manchester_decode.py
├── manchester_decode.pyc
└── manchester_decode.pyo

0 directories, 10 files
kees-closed commented 5 years ago

Wait, I got it working, I also needed to include the path where the stuff was generated. I did that with export PYTHONPATH=$PYTHONPATH:/usr/local/lib64/python2.7/site-packages:/home/kjong/git/gr-keyfob/build/swig. Thanks for you help and time!

bastibl commented 5 years ago

Glad you got it working. But it's really strange... Actually this shouldn't be required :-/ Can you check with ldd _keyfob_swig.so if the libraries in both directories (/usr/local/... and /home/kjong/...) can resolve their dependencies?

kees-closed commented 5 years ago

Seems like the /usr/local one can't resolve libgnuradio-keyfob.so.

/usr/local/lib64/python2.7/site-packages/keyfob/_keyfob_swig.so:
        linux-vdso.so.1 (0x00007ffc59cf0000)
        libpython2.7.so.1.0 => /lib64/libpython2.7.so.1.0 (0x00007f2fd7008000)
        libgnuradio-keyfob.so => not found
        libboost_filesystem.so.1.66.0 => /lib64/libboost_filesystem.so.1.66.0 (0x00007f2fd6feb000)
        libboost_system.so.1.66.0 => /lib64/libboost_system.so.1.66.0 (0x00007f2fd6fe4000)
        libgnuradio-runtime-3.7.13.4.so.0.0.0 => /lib64/libgnuradio-runtime-3.7.13.4.so.0.0.0 (0x00007f2fd6eef000)
        libgnuradio-pmt-3.7.13.4.so.0.0.0 => /lib64/libgnuradio-pmt-3.7.13.4.so.0.0.0 (0x00007f2fd6e8e000)
        libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007f2fd6cf4000)
        libm.so.6 => /lib64/libm.so.6 (0x00007f2fd6b70000)
        libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f2fd6b55000)
        libc.so.6 => /lib64/libc.so.6 (0x00007f2fd698f000)
        libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f2fd696d000)
        libdl.so.2 => /lib64/libdl.so.2 (0x00007f2fd6967000)
        libutil.so.1 => /lib64/libutil.so.1 (0x00007f2fd6960000)
        librt.so.1 => /lib64/librt.so.1 (0x00007f2fd6956000)
        libvolk.so.1.4 => /lib64/libvolk.so.1.4 (0x00007f2fd676b000)
        libboost_date_time.so.1.66.0 => /lib64/libboost_date_time.so.1.66.0 (0x00007f2fd6756000)
        libboost_program_options.so.1.66.0 => /lib64/libboost_program_options.so.1.66.0 (0x00007f2fd66d3000)
        libboost_regex.so.1.66.0 => /lib64/libboost_regex.so.1.66.0 (0x00007f2fd65b4000)
        libboost_thread.so.1.66.0 => /lib64/libboost_thread.so.1.66.0 (0x00007f2fd6585000)
        libboost_chrono.so.1.66.0 => /lib64/libboost_chrono.so.1.66.0 (0x00007f2fd6579000)
        libboost_atomic.so.1.66.0 => /lib64/libboost_atomic.so.1.66.0 (0x00007f2fd6574000)
        liborc-0.4.so.0 => /lib64/liborc-0.4.so.0 (0x00007f2fd64f4000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f2fd72c2000)
        libicudata.so.62 => /lib64/libicudata.so.62 (0x00007f2fd4b57000)
        libicui18n.so.62 => /lib64/libicui18n.so.62 (0x00007f2fd4881000)
        libicuuc.so.62 => /lib64/libicuuc.so.62 (0x00007f2fd46b8000)
_keyfob_swig.so:
        linux-vdso.so.1 (0x00007ffc719c2000)
        libpython2.7.so.1.0 => /lib64/libpython2.7.so.1.0 (0x00007f83f90af000)
        libgnuradio-keyfob.so => /home/kjong/git/gr-keyfob/build/lib/libgnuradio-keyfob.so (0x00007f83f9095000)
        libboost_filesystem.so.1.66.0 => /lib64/libboost_filesystem.so.1.66.0 (0x00007f83f9078000)
        libboost_system.so.1.66.0 => /lib64/libboost_system.so.1.66.0 (0x00007f83f9071000)
        libgnuradio-runtime-3.7.13.4.so.0.0.0 => /lib64/libgnuradio-runtime-3.7.13.4.so.0.0.0 (0x00007f83f8f7c000)
        libgnuradio-pmt-3.7.13.4.so.0.0.0 => /lib64/libgnuradio-pmt-3.7.13.4.so.0.0.0 (0x00007f83f8f1b000)
        libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007f83f8d81000)
        libm.so.6 => /lib64/libm.so.6 (0x00007f83f8bfd000)
        libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f83f8be2000)
        libc.so.6 => /lib64/libc.so.6 (0x00007f83f8a1c000)
        libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f83f89fa000)
        libdl.so.2 => /lib64/libdl.so.2 (0x00007f83f89f4000)
        libutil.so.1 => /lib64/libutil.so.1 (0x00007f83f89ed000)
        librt.so.1 => /lib64/librt.so.1 (0x00007f83f89e3000)
        libvolk.so.1.4 => /lib64/libvolk.so.1.4 (0x00007f83f87f8000)
        libboost_date_time.so.1.66.0 => /lib64/libboost_date_time.so.1.66.0 (0x00007f83f87e3000)
        libboost_program_options.so.1.66.0 => /lib64/libboost_program_options.so.1.66.0 (0x00007f83f8760000)
        libboost_regex.so.1.66.0 => /lib64/libboost_regex.so.1.66.0 (0x00007f83f863f000)
        libboost_thread.so.1.66.0 => /lib64/libboost_thread.so.1.66.0 (0x00007f83f8612000)
        libboost_chrono.so.1.66.0 => /lib64/libboost_chrono.so.1.66.0 (0x00007f83f8606000)
        libboost_atomic.so.1.66.0 => /lib64/libboost_atomic.so.1.66.0 (0x00007f83f8601000)
        liborc-0.4.so.0 => /lib64/liborc-0.4.so.0 (0x00007f83f8581000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f83f9369000)
        libicudata.so.62 => /lib64/libicudata.so.62 (0x00007f83f6be4000)
        libicui18n.so.62 => /lib64/libicui18n.so.62 (0x00007f83f690e000)
        libicuuc.so.62 => /lib64/libicuuc.so.62 (0x00007f83f6745000)
bastibl commented 5 years ago

Did you forget to adapt your LD_LIBRARY_PATH to include the installation directory of the library? Probably it's /usr/local/lib64 in your case.

kees-closed commented 5 years ago

LD_LIBRARY_PATH wasn't changed indeed, this could've been the problem.