Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for PN532 based RFID readers #825

Merged
merged 5 commits into from
Mar 22, 2020

Conversation

fredg02
Copy link
Contributor

@fredg02 fredg02 commented Mar 1, 2020

Fix for issue #824.

I've added the py532lib from https://github.com/HubCityLabs/py532lib. Let me know if the library should only be added if it's required (e.g. with a little install script).

This has been tested successfully with the latest source code from the develop branch on Raspbian Stretch with a Raspberry Pi Zero.
There is a potential issue where the I2C connection is lost after a while. A manual workaround is to reset the I2C connection via raspi-config. It should be easy to automate this resetting procedure if it occurs more frequently (during my short tests it was pretty stable).

If this PR gets merged, I can add a section to the wiki explaining the hard- and software setup (incl. wiring), etc.

@s-martin
Copy link
Collaborator

s-martin commented Mar 1, 2020

Thanks for your contribution to Phoniebox!

A few thoughts:

  • dependencies could by installed via pip, see e.g.
    git+git://github.com/lthiery/SPI-Py.git#egg=spi-py
    so we would not need to copy the other libs into the repo
  • the used Quickwire library is licensed under GPL, we need to check, how we can use it to be compliant with the license
  • I have seen the py532lib hasn't been updated for a few years, so is the current state of the code ok for our use case here?

We are happy to assist you to get this new code parts integrated here!

@s-martin
Copy link
Collaborator

s-martin commented Mar 2, 2020

So the Quickwire license seems to be LGPL or MIT license, maybe it's not really an issue.

Neverthelesss we should decide, if we want to distribute the code (i.e. add it to the repo here) or just load via pip.

@fredg02
Copy link
Contributor Author

fredg02 commented Mar 3, 2020

Hi,

Thanks for the quick reply.

  • dependencies could by installed via pip, see e.g.
    git+git://github.com/lthiery/SPI-Py.git#egg=spi-py

    so we would not need to copy the other libs into the repo

Unfortunately it does not work via pip install py532lib:

Collecting py532lib
Could not find a version that satisfies the requirement py532lib (from versions: )
No matching distribution found for py532lib`

It does work with pip3 install py532lib though. Where and how exactly should this be installed? Also in the requirements.txt file?

  • I have seen the py532lib hasn't been updated for a few years, so is the current state of the code ok for our use case here?

As mentioned, during my (limited) tests I have not found any issues. So I'm assuming that this legacy code is good enough. There are two alternative Python libs for PN532, but they have similar/other limitations:

@s-martin
Copy link
Collaborator

s-martin commented Mar 4, 2020

pip3 is fine for us, we are in the process of moving to Python 3 only anyway.

My suggestion would be to create a file e.g. requirements-pn532.txt (for example see https://github.com/MiczFlor/RPi-Jukebox-RFID/blob/362fb7742a59fc2691436319b0ef0574002073c2/requirements-spotify.txt), which installs all dependencies for that reader.

If we want to add the call sudo python3 -m pip install -r requirements-pn532.txt to the regular installer or we provide a README with a description how users could install it, should be discussed. @MiczFlor and @ZyanKLee , what do you think?

Generally I suggest to check https://github.com/MiczFlor/RPi-Jukebox-RFID/blob/develop/CONTRIBUTING.md, there is some info provided how additional components should be added to the repo.

You may also want to check #790, what's currently discussed and maybe #792 for future handling of additional components (plugins).

@ZyanKLee
Copy link
Collaborator

ZyanKLee commented Mar 4, 2020

My goal would be to assemble the pip-install command based on the user's input within our installer and install all pypi dependencies at once. That should avoid version incompatibilities... Hopefully.

So, creating a requirements-pn532.txt is a good idea.

@fredg02
Copy link
Contributor Author

fredg02 commented Mar 4, 2020

Based on #790 I have created components/rfid-reader/rfid-reader-PN532/requirements-pn532.txt and referenced it directly in the installer scripts for now.

Side note: mentioning the type of the component in the subsubfolder again seems redundant to me. I'm not even sure that the component name has to be added to the requirements.txt's file name.
E.g. components/rfid-reader/PN532/requirements.txt seems unique enough to me. I will add a comment to issue #790.

@fredg02
Copy link
Contributor Author

fredg02 commented Mar 6, 2020

I will update this PR with the shorter path to the requirements.txt as described above.

@fredg02 fredg02 force-pushed the pn532_rfid_reader branch from e6ded51 to f0ca994 Compare March 6, 2020 23:53
@ZyanKLee
Copy link
Collaborator

ZyanKLee commented Mar 7, 2020

@fredg02 did you do a clean install with those changes? And does the phoniebox with your RFID reader work after that?

@ZyanKLee ZyanKLee linked an issue Mar 7, 2020 that may be closed by this pull request
@fredg02
Copy link
Contributor Author

fredg02 commented Mar 9, 2020

@fredg02 did you do a clean install with those changes? And does the phoniebox with your RFID reader work after that?

Not yet, but I will test it.

@s-martin
Copy link
Collaborator

If you think there's a need to explain how to use this feature, please add a short README.md to components/rfid-reader/PN532/.

@MiczFlor
Copy link
Owner

@fredg02 thanks for your contribution. And very happy to see that the components folder is coming to life.

There is a conflict with the two install scripts for buster and stretch at the moment. Could you have a look please and fix this? It seems that later changes compromised your contribution.

And if you add a few lines to a README.md in the folder where the requirements are, I would later add that to the wiki

Thanks! micz

@fredg02
Copy link
Contributor Author

fredg02 commented Mar 19, 2020

Yes, I will. Sorry for the delay. Priorities have been shifting around lately, so I did not get to work on the PR.

@fredg02 fredg02 force-pushed the pn532_rfid_reader branch from f0ca994 to 124b6a4 Compare March 22, 2020 02:09
@fredg02
Copy link
Contributor Author

fredg02 commented Mar 22, 2020

Conflicts in the install scripts have been fixed. README.md has been added.

I've successfully tested the install script for Buster on a clean Raspbian Buster installation. After the installation I had to follow the steps in the README.md to get the PN532 reader to work.

Copy link
Collaborator

@s-martin s-martin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

components/rfid-reader/PN532/README.md Outdated Show resolved Hide resolved
@s-martin s-martin added this to the 2.0 milestone Mar 22, 2020
@s-martin s-martin merged commit 33f068e into MiczFlor:develop Mar 22, 2020
@fredg02 fredg02 deleted the pn532_rfid_reader branch March 22, 2020 17:30
@fredg02
Copy link
Contributor Author

fredg02 commented Mar 22, 2020

@s-martin, @ZyanKLee and @MiczFlor:Thanks for your support with this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🚀 | Add support for PN532 based RFID readers
4 participants