gassajor000 / pn532pi

Python interface for ndef communication using PN532 chip on raspberry pi
36 stars 18 forks source link

Failed to instance class on rpi zero #5

Closed h4de5 closed 4 years ago

h4de5 commented 4 years ago

I do got the following error message on raspberrypi zero:

TypeError: 'NoneType' object is not callable

This is probably because of a failing import of the HSU interface and the None initialization afterwards in https://github.com/gassajor000/pn532pi/blob/3b652729fec10d5cbfb817e8b519f90d76bbc30d/pn532pi/__init__.py#L4

As a workaround you can import the interface directly e.g.:

from pn532pi.interfaces.pn532i2c import Pn532I2c
gassajor000 commented 4 years ago

Thanks for reporting this. I don't have a Pi Zero so I wasn't able to test on it. I'll look into why this is happening and figure out a fix.

gassajor000 commented 4 years ago

If you can post the error triggering the except block when importing Pn532Hsu, that would be helpful.

h4de5 commented 4 years ago

I tried to directly import them without the try catch. It seems the "serial" module was missing too. But after "sudo pip3 install serial" I get the following error message:

Traceback (most recent call last):
  File "./readnfc.py", line 27, in <module>
    from pn532pi.interfaces.pn532hsu import Pn532Hsu
  File "/usr/local/lib/python3.4/dist-packages/pn532pi/interfaces/pn532hsu.py", line 1, in <module>
    from serial import Serial
ImportError: cannot import name 'Serial'
gassajor000 commented 4 years ago

I believe the serial library on pypi is for serializing json. The serial COM library is called pyserial (which is then imported as serial). Try doing pip install pyserial and see if that works.

h4de5 commented 4 years ago

you are right. its working with pyserial I really though that had something to do with HSU

gassajor000 commented 4 years ago

Ok cool. This should be fixed with the fix for install_requires. I'll try to get an new version uploaded today.

h4de5 commented 4 years ago

btw. great work! :D before I tried hours to get the reader working using the libs directly - the pip package is a relief!