Skip to content

Commit

Permalink
feat: Adapted robertdijk's code
Browse files Browse the repository at this point in the history
  • Loading branch information
Flowtter committed Sep 12, 2023
2 parents 6228713 + b64495e commit 5d2432b
Show file tree
Hide file tree
Showing 15 changed files with 376 additions and 24 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/publish-to-pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Publish Python 🐍 distributions 📦 to PyPI and TestPyPI

on:
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+'

jobs:
build-n-publish:
name: Build and publish Python 🐍 distributions 📦 to PyPI and TestPyPI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.6"
- name: Install pypa/build
run: >-
python -m
pip install
build
--user
- name: Build a binary wheel and a source tarball
run: >-
python -m
build
--sdist
--wheel
--outdir dist/
.
- name: Publish distribution 📦 to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository-url: https://test.pypi.org/legacy/
- name: Publish distribution 📦 to PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
19 changes: 13 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
# PY-ACR122U

<img src="http://downloads.acs.com.hk/product-website-image/acr38-image.jpg" width="150" height="150">
[![PyPI - Version](https://img.shields.io/pypi/v/py122u)](https://pypi.org/project/py122u/)
[![PyPI - License](https://img.shields.io/pypi/l/py122u)](https://pypi.org/project/py122u/)
[![PyPI - Downloads](https://img.shields.io/pypi/dm/py122u)](https://pypi.org/project/py122u/)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/py122u)](https://pypi.org/project/py122u/)
[![PyPI - Wheel](https://img.shields.io/pypi/wheel/py122u)](https://pypi.org/project/py122u/)

This is a python library for the ACR122U NFC reader

## Installation
- git clone https://github.com/Flowtter/py-acr122u.git
- cd py-acr122u
- pip install -r requirements.txt

```shell
pip install py122u
```

## Usage

```python
from src import nfc

from py122u import nfc

reader = nfc.Reader()
reader.connect()
reader.print_data(reader.get_uid())
reader.info()
```
- python main.py
4 changes: 3 additions & 1 deletion Example/write_and_read.py → example/write_and_read.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from src import nfc
from py122u import nfc

reader = nfc.Reader()
reader.connect()

reader.load_authentication_data(0x01, [0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF])
reader.authentication(0x00, 0x61, 0x01)
Expand Down Expand Up @@ -29,5 +30,6 @@ def read(r, position, number):
def read_16(r, position, number):
return r.read_binary_blocks(position, number)


write(reader, 0x01, 0x20, [0x00 for i in range(16)])
print(read(reader, 0x01, 0x20))
51 changes: 51 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
[build-system]
requires = ["setuptools>=61.0.0", "wheel"]
build-backend = "setuptools.build_meta"

[project]
name = "py122u"
version = "2.3.1"
description = "This is a python library for the ACR122U NFC reader"
readme = "README.md"
authors = [{ name = "Brice PARENT", email = "[email protected]"}, { name = "Robert van Dijk", email = "[email protected]" }]
license = { file = "LICENSE" }
classifiers = [
"License :: OSI Approved :: MIT License",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
]
keywords = ["nfc", "acr", "acr122u"]
dependencies = [
"pyscard>=2.0.7",
]
requires-python = ">=3.6"

[project.optional-dependencies]
dev = ["black", "bumpver", "isort", "pip-tools", "pytest", "pytest-mock"]

[project.urls]
Homepage = "https://github.com/Flowtter/py-acr122u"

[tool.bumpver]
current_version = "2.3.1"
version_pattern = "MAJOR.MINOR.PATCH"
commit_message = "Bump version {old_version} -> {new_version}"
commit = true
tag = true
push = false

[tool.bumpver.file_patterns]
"pyproject.toml" = [
'current_version = "{version}"',
'version = "{version}"',
]
"src/py122u/__init__.py" = ["{version}"]

[tool.pytest.ini_options]
minversion = "6.0"
addopts = "-ra -q"
testpaths = [
"tests",
"integration",
]

4 changes: 4 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[pytest]
testpaths = tests
python_files = *.py
addopts = -vv --showlocals
1 change: 0 additions & 1 deletion requirements.txt

This file was deleted.

5 changes: 0 additions & 5 deletions src/main.py

This file was deleted.

1 change: 1 addition & 0 deletions src/py122u/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "2.3.1"
11 changes: 11 additions & 0 deletions src/error.py → src/py122u/error.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,14 @@ class InstructionFailed(Error):

def __init__(self, message):
self.message = message


class BitOutOfRange(Error):
"""Exception raised when you try to set a bit that does not exsist
Attributes:
message -- explanation of the error
"""

def __init__(self, message):
self.message = message
Loading

0 comments on commit 5d2432b

Please sign in to comment.