Closed gabicavalcante closed 6 years ago
you're missing swig, I made it mandatory now
Thanks! I got a error, and I thought it would be resolved after making make install. But I got the same error now:
pi@raspberrypi:~/nfc-bindings $ python python/examples/quick_start_example.py
Version: 0.13.2
Traceback (most recent call last):
File "python/examples/quick_start_example.py", line 11, in <module>
context = nfc.init()
AttributeError: 'module' object has no attribute 'init'
Do you know why this is happening?
I suspect the nfc module that you're trying to load is not the one you thought you installed as the version reported 0.13.2 should be the same as the libnfc version. Did you make install ? Did you set the install prefix ? Also 'python' should point to python of version 3.4, maybe you should run it with 'python3'.
I tried with python 3.
pi@raspberrypi:~/nfc-bindings $ python3 python/examples/quick_start_example.py
Version: libnfc-1.7.1-191-g216145f
ERROR: Unable to open NFC device.
When I test the libnfc, I don't have any problem:
pi@raspberrypi:~/libnfc/examples $ sudo ./nfc-poll
/home/pi/libnfc/examples/.libs/lt-nfc-poll uses libnfc libnfc-1.7.1-191-g216145f
NFC reader: PN532 board via UART opened
NFC device will poll during 30000 ms (20 pollings of 300 ms for 5 modulations)
ISO/IEC 14443A (106 kbps) target:
ATQA (SENS_RES): 00 04
UID (NFCID1): 04 5b 8f 0e
SAK (SEL_RES): 08
Waiting for card removing...
My scheme: https://github.com/emersonmello/doorlock_raspberrypi/blob/master/hw-wiring.png
maybe the sudo grants you rigts to your device here ?
I tried without sudo, and the libnfc works:
pi@raspberrypi:~/libnfc/examples $ ./nfc-poll
/home/pi/libnfc/examples/.libs/lt-nfc-poll uses libnfc libnfc-1.7.1-191-g216145f
NFC reader: PN532 board via UART opened
NFC device will poll during 30000 ms (20 pollings of 300 ms for 5 modulations)
ISO/IEC 14443A (106 kbps) target:
ATQA (SENS_RES): 00 04
UID (NFCID1): 04 5b 8f 0e
SAK (SEL_RES): 08
Waiting for card removing...
I tried with sudo now:
pi@raspberrypi:~/nfc-bindings $ sudo python3 python/examples/quick_start_example.py
Traceback (most recent call last):
File "python/examples/quick_start_example.py", line 8, in <module>
import nfc
ImportError: No module named 'nfc'
did you use the same libnfc version ?
could you try with sudo but setting sudo PYTHONPATH=/home/pi/.local/lib/python3.4/site-packages python3 python/examples/quick_start_example.py
?
The version of libnfc is the same
libnfc:
pi@raspberrypi:~/libnfc/examples $ ./nfc-poll
/home/pi/libnfc/examples/.libs/lt-nfc-poll uses libnfc libnfc-1.7.1-191-g216145f
nfc-bindings:
pi@raspberrypi:~/nfc-bindings $ sudo PYTHONPATH=/home/pi/.local/lib/python3.4/site-packages python3 python/examples/quick_start_example.py
Version: libnfc-1.7.1-191-g216145f
ERROR: Unable to open NFC device.
But tried the command nfc-list
and I got an error:
nfc-list uses libnfc libnfc-1.7.1-191-g216145f
No NFC device found.
I'm gonna try to find a way to fix it.
I fixed the problem with libnfc, now:
pi@raspberrypi:~/nfc-bindings/python/examples $ nfc-list
nfc-list uses libnfc 1.7.1
NFC device: pn532_i2c:/dev/i2c-1 opened
1 ISO14443A passive target(s) found:
ISO/IEC 14443A (106 kbps) target:
ATQA (SENS_RES): 00 04
UID (NFCID1): e1 2f ce e9
SAK (SEL_RES): 08
and
pi@raspberrypi:~/nfc-bindings $ swig -version
SWIG Version 2.0.12
Compiled with g++ [armv7l-unknown-linux-gnueabihf]
Configured options: +pcre
pi@raspberrypi:~/nfc-bindings $ python --version
Python 2.7.9
pi@raspberrypi:~/nfc-bindings $ nfc-list
nfc-list uses libnfc 1.7.1
NFC device: pn532_i2c:/dev/i2c-1 opened
pi@raspberrypi:~/nfc-bindings $ make --version
GNU Make 4.0
But when I try:
pi@raspberrypi:~/nfc-bindings/python/examples $ python quick_start_example.py
Traceback (most recent call last):
File "quick_start_example.py", line 8, in <module>
import nfc
File "/home/pi/.local/lib/python2.7/site-packages/nfc.py", line 32, in <module>
_nfc = swig_import_helper()
File "/home/pi/.local/lib/python2.7/site-packages/nfc.py", line 28, in swig_import_helper
_mod = imp.load_module('_nfc', fp, pathname, description)
ImportError: /home/pi/.local/lib/python2.7/site-packages/_nfc.so: undefined symbol: iso14443b_crc
or
pi@raspberrypi:~/nfc-bindings/python/examples $ python3 quick_start_example.py
Traceback (most recent call last):
File "quick_start_example.py", line 8, in <module>
import nfc
ImportError: No module named 'nfc'
I removed HAS_ISO14443B_CRC:INTERNAL=1 from CMakeCache.txt, but when I rerun cmake -DCMAKE_INSTALL_PREFIX=~/.local .
, HAS_ISO14443B_CRC:INTERNAL=1 is in the file again. I'm doing the right command line?
I did:
pi@raspberrypi:~/nfc-bindings $ objdump -tT /usr/lib/libnfc.so|grep iso1444
00000000 l df *ABS* 00000000 iso14443-subr.c
00011ea4 l O .rodata 00000010 pn532_iso14443a_supported_baud_rates
00006504 l F .text 000000bc snprint_nfc_iso14443b2ct_info
00011e90 l O .rodata 00000014 pn533_iso14443a_supported_baud_rates
00011e5c l O .rodata 00000008 pn532_iso14443b_supported_baud_rates
00005f84 l F .text 000003f0 snprint_nfc_iso14443b_info
000064c8 l F .text 0000003c snprint_nfc_iso14443b2sr_info
00011e48 l O .rodata 00000014 pn533_iso14443b_supported_baud_rates
00004b1c l F .text 000011cc snprint_nfc_iso14443a_info
00002c30 l F .text 000000b4 iso14443_cascade_uid
00006374 l F .text 00000154 snprint_nfc_iso14443bi_info
00002b8c g F .text 0000004c iso14443b_crc
00002b84 g F .text 00000008 iso14443a_crc_append
00002bd8 g F .text 00000008 iso14443b_crc_append
00002be0 g F .text 00000050 iso14443a_locate_historical_bytes
00002b3c g F .text 00000048 iso14443a_crc
00002be0 g DF .text 00000050 Base iso14443a_locate_historical_bytes
00002b8c g DF .text 0000004c Base iso14443b_crc
00002bd8 g DF .text 00000008 Base iso14443b_crc_append
00002b84 g DF .text 00000008 Base iso14443a_crc_append
00002b3c g DF .text 00000048 Base iso14443a_crc
So, there is iso14443b_crc...
Yes iso14443b_crc is exported, at least the one in /usr/lib/.
Which one is the bindings linked to ?
ldd /home/pi/.local/lib/python2.7/site-packages/_nfc.so
When I run the Quickstart: