Skip to content

Commit

Permalink
Merge branch 'MiczFlor:develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
s-martin authored Feb 13, 2024
2 parents 85a4e1b + 5dca35f commit 7504381
Show file tree
Hide file tree
Showing 14 changed files with 152 additions and 65 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
Expand Down
57 changes: 43 additions & 14 deletions .github/workflows/test_docker_debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ on:
# The branches below must be a subset of the branches above
branches:
- develop
- main
- master
paths:
- '.github/workflows/test_docker_debian*.yml'
- 'ci/**'
Expand All @@ -39,19 +39,48 @@ concurrency:

jobs:

# Build container and run tests
run:
name: ${{ matrix.debian_codename }}
strategy:
fail-fast: false
matrix:
debian_codename: ['bookworm', 'bullseye', 'buster']
# Build container and run tests. Duplication of job intended for better visualization.
run_bookworm_armv7:
name: 'bookworm armv7'
uses: ./.github/workflows/test_docker_debian_codename_sub.yml
with:
runs_on: ubuntu-latest
debian_codename: 'bookworm'
platform: linux/arm/v7
docker_image_name: rpi-jukebox-rfid
cache_scope: ${{ github.ref }}-test-debian
matrix_usernames: "['pi', 'hans']"
matrix_test_scripts: "['run_installation_tests.sh', 'run_installation_tests2.sh', 'run_installation_tests3.sh']"
debian_codename: ${{ matrix.debian_codename }}

# # can be activate on test branches
# run_bookworm_armv6:
# name: 'bookworm armv6'
# uses: ./.github/workflows/test_docker_debian_codename_sub.yml
# with:
# debian_codename: 'bookworm'
# platform: linux/arm/v6

run_bullseye_armv7:
name: 'bullseye armv7'
uses: ./.github/workflows/test_docker_debian_codename_sub.yml
with:
debian_codename: 'bullseye'
platform: linux/arm/v7

# # can be activate on test branches, currently failing
# run_bullseye_armv6:
# name: 'bullseye armv6'
# uses: ./.github/workflows/test_docker_debian_codename_sub.yml
# with:
# debian_codename: 'bullseye'
# platform: linux/arm/v6

run_buster_armv7:
name: 'buster armv7'
uses: ./.github/workflows/test_docker_debian_codename_sub.yml
with:
debian_codename: 'buster'
platform: linux/arm/v7

# # can be activate on test branches, currently failing
# run_buster_armv6:
# name: 'buster armv6'
# uses: ./.github/workflows/test_docker_debian_codename_sub.yml
# with:
# debian_codename: 'buster'
# platform: linux/arm/v6
50 changes: 29 additions & 21 deletions .github/workflows/test_docker_debian_codename_sub.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,33 @@ name: Subworkflow Test Install Scripts Debian
on:
workflow_call:
inputs:
runs_on:
required: true
type: string
platform:
required: true
type: string
debian_codename:
required: true
type: string
cache_scope:
platform:
required: true
type: string
docker_image_name:
required: true
type: string
matrix_usernames:
required: true
required: false
type: string
matrix_test_scripts:
required: true
default: rpi-jukebox-rfid
cache_scope:
required: false
type: string
default: ${{ github.ref }}-test-debian
local_registry_port:
required: false
type: number
default: 5000
runs_on:
required: false
type: string
default: ubuntu-latest

# let only one instance run the test so cache is not corrupted.
# cancel already running instances as only the last run will be relevant
concurrency:
group: ${{ inputs.cache_scope }}-${{ inputs.debian_codename }}
group: ${{ inputs.cache_scope }}-${{ inputs.debian_codename }}-${{ inputs.platform }}
cancel-in-progress: true

jobs:
Expand All @@ -45,6 +42,7 @@ jobs:
cache_key: ${{ steps.vars.outputs.cache_key }}
image_file_name: ${{ steps.vars.outputs.image_file_name }}
image_tag_name: ${{ steps.vars.outputs.image_tag_name }}
docker_run_options: ${{ steps.vars.outputs.docker_run_options }}

# create local docker registry to use locally build images
services:
Expand All @@ -71,22 +69,28 @@ jobs:
DEBIAN_CODENAME: ${{ inputs.debian_codename }}
DOCKER_IMAGE_NAME: ${{ inputs.docker_image_name }}
CACHE_SCOPE: ${{ inputs.cache_scope }}
PLATFORM: ${{ inputs.platform }}
run: |
echo "image_tag_name=${{ env.DOCKER_IMAGE_NAME }}:${{ env.DEBIAN_CODENAME }}-test" >> $GITHUB_OUTPUT
echo "image_file_name=${{ env.DOCKER_IMAGE_NAME }}-${{ env.DEBIAN_CODENAME }}.tar" >> $GITHUB_OUTPUT
echo "cache_scope=${{ env.CACHE_SCOPE }}-${{ env.DEBIAN_CODENAME }}" >> $GITHUB_OUTPUT
PLATFORM=${PLATFORM////_}
echo "image_tag_name=${{ env.DOCKER_IMAGE_NAME }}:${{ env.DEBIAN_CODENAME }}-${PLATFORM}-test" >> $GITHUB_OUTPUT
echo "image_file_name=${{ env.DOCKER_IMAGE_NAME }}-${{ env.DEBIAN_CODENAME }}-${PLATFORM}.tar" >> $GITHUB_OUTPUT
echo "cache_scope=${{ env.CACHE_SCOPE }}-${{ env.DEBIAN_CODENAME }}-${PLATFORM}" >> $GITHUB_OUTPUT
- name: Set Output vars
id: vars
env:
LOCAL_REGISTRY_PORT: ${{ inputs.local_registry_port }}
PLATFORM: ${{ inputs.platform }}
run: |
echo "image_tag_name=${{ steps.pre-vars.outputs.image_tag_name }}" >> $GITHUB_OUTPUT
echo "image_tag_name_local_base=localhost:${{ env.LOCAL_REGISTRY_PORT }}/${{ steps.pre-vars.outputs.image_tag_name }}-base" >> $GITHUB_OUTPUT
echo "image_file_name=${{ steps.pre-vars.outputs.image_file_name }}" >> $GITHUB_OUTPUT
echo "image_file_path=./${{ steps.pre-vars.outputs.image_file_name }}" >> $GITHUB_OUTPUT
echo "cache_scope=${{ steps.pre-vars.outputs.cache_scope }}" >> $GITHUB_OUTPUT
echo "cache_key=${{ steps.pre-vars.outputs.cache_scope }}-${{ github.sha }}#${{ github.run_attempt }}" >> $GITHUB_OUTPUT
if [ "${{ env.PLATFORM }}" == "linux/arm/v6" ] ; then
echo "docker_run_options=-e QEMU_CPU=arm1176" >> $GITHUB_OUTPUT
fi
# Build base image for debian version name. Layers will be cached and image pushes to local registry
- name: Build Image - Base
Expand Down Expand Up @@ -128,7 +132,7 @@ jobs:
with:
name: ${{ steps.vars.outputs.image_file_name }}
path: ${{ steps.vars.outputs.image_file_path }}
retention-days: 2
retention-days: 1


# Run tests with build image
Expand All @@ -139,8 +143,12 @@ jobs:
strategy:
fail-fast: false
matrix:
username: ${{ fromJSON(inputs.matrix_usernames) }}
test_script: ${{ fromJSON(inputs.matrix_test_scripts) }}
username: ['pi']
test_script: ['run_installation_tests.sh', 'run_installation_tests2.sh', 'run_installation_tests3.sh']
include:
- username: 'hans'
test_script: 'run_installation_tests.sh'


steps:
- name: Set up QEMU
Expand All @@ -163,7 +171,7 @@ jobs:
uses: tj-actions/docker-run@v2
with:
image: ${{ needs.build.outputs.image_tag_name }}
options: --platform ${{inputs.platform }} --user ${{ matrix.username }}
options: ${{ needs.build.outputs.docker_run_options }} --platform ${{ inputs.platform }} --user ${{ matrix.username }} --init
name: ${{ matrix.test_script }}
args: |
./${{ matrix.test_script }}
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ While Version 3 is still under development, it is becoming a lot more stable! Al
If you seek the adventure, your support will be more then welcome. Before contributing, check out the following references.

***[Releases](https://github.com/MiczFlor/RPi-Jukebox-RFID/releases?q=v3&expanded=true)**
* 🚀 **[Install Jukebox Version 3 Beta](https://github.com/MiczFlor/RPi-Jukebox-RFID/blob/future3/develop/documentation/builders/installation.md)**
* 🚀 **[Install Jukebox Version 3](https://github.com/MiczFlor/RPi-Jukebox-RFID/blob/future3/main/documentation/builders/installation.md)**
* 🐛 [Report a bug](https://github.com/MiczFlor/RPi-Jukebox-RFID/issues/new?assignees=&labels=future3%2C+bug%2C+needs+triage&template=future3.md&title=ISSUE+SUMMARY+on+future3)
* ☑️ [Feature Status](https://github.com/MiczFlor/RPi-Jukebox-RFID/blob/future3/develop/documentation/developers/status.md)
* 📖 [Documentation](https://github.com/MiczFlor/RPi-Jukebox-RFID/blob/future3/develop/documentation/README.md)
* 👩‍💻 [Development](https://github.com/MiczFlor/RPi-Jukebox-RFID/blob/future3/develop/documentation/developers/README.md)
* ☑️ [Feature Status](https://github.com/MiczFlor/RPi-Jukebox-RFID/blob/future3/main/documentation/developers/status.md)
* 📖 [Documentation](https://github.com/MiczFlor/RPi-Jukebox-RFID/blob/future3/main/documentation/README.md)
* 👩‍💻 [Development](https://github.com/MiczFlor/RPi-Jukebox-RFID/blob/future3/main/documentation/developers/README.md)
* 🦄 Code: [Release Branch](https://github.com/MiczFlor/RPi-Jukebox-RFID/tree/future3/main), [Development Branch](https://github.com/MiczFlor/RPi-Jukebox-RFID/tree/future3/develop)

---
Expand Down
9 changes: 8 additions & 1 deletion components/rfid-reader/RC522/setup_rc522.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ question() {
printf "Please make sure that the RC522 reader is wired up correctly to the GPIO ports before continuing...\n"
question "Continue"

printf "Use backward-compatible card ID (not suggested for new installations)?\n"
read -p "(y/N) " choice
case "$choice" in
y|Y ) printf "OFF" > "${JUKEBOX_HOME_DIR}"/settings/Rfidreader_Rc522_Readmode_UID;;
* ) printf "ON" > "${JUKEBOX_HOME_DIR}"/settings/Rfidreader_Rc522_Readmode_UID;;
esac

printf "Installing Python requirements for RC522...\n"
sudo python3 -m pip install --upgrade --force-reinstall -q -r "${JUKEBOX_HOME_DIR}"/components/rfid-reader/RC522/requirements.txt

Expand All @@ -29,6 +36,6 @@ sudo chown pi:www-data "${JUKEBOX_HOME_DIR}"/scripts/deviceName.txt
sudo chmod 644 "${JUKEBOX_HOME_DIR}"/scripts/deviceName.txt

printf "Restarting phoniebox-rfid-reader service...\n"
sudo systemctl start phoniebox-rfid-reader.service
sudo systemctl restart phoniebox-rfid-reader.service

printf "Done.\n"
2 changes: 0 additions & 2 deletions scripts/Reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,8 @@ def get_devices():


class Reader:
reader = None

def __init__(self):
self.reader = self
path = os.path.dirname(os.path.realpath(__file__))
self.keys = "X^1234567890XXXXqwertzuiopXXXXasdfghjklXXXXXyxcvbnmXXXXXXXXXXXXXXXXXXXXXXX"
if not os.path.isfile(path + '/deviceName.txt'):
Expand Down
2 changes: 0 additions & 2 deletions scripts/Reader.py.Multi
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,8 @@ def get_devices():


class Reader:
reader = None

def __init__(self):
self.reader = self
devs = list()
path = os.path.dirname(os.path.realpath(__file__))
self.keys = "X^1234567890XXXXqwertzuiopXXXXasdfghjklXXXXXyxcvbnmXXXXXXXXXXXXXXXXXXXXXXX"
Expand Down
28 changes: 26 additions & 2 deletions scripts/Reader.py.experimental
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,15 @@ class Mfrc522Reader(object):
def __init__(self):
import pirc522
self.device = pirc522.RFID()
path = os.path.dirname(os.path.realpath(__file__))
readmode_uid = False
if os.path.isfile(path + '/../settings/Rfidreader_Rc522_Readmode_UID'):
with open(path + '/../settings/Rfidreader_Rc522_Readmode_UID', 'r') as f:
readmode_uid = f.read().rstrip().split(';', 1)[0] == 'ON'
self._read_function = self._readCard_normal if readmode_uid else self._readCard_legacy

def readCard(self):
def _readCard_legacy(self):
# Scan for cards
self.device.wait_for_tag()
(error, tag_type) = self.device.request()

if not error:
Expand All @@ -70,6 +75,22 @@ class Mfrc522Reader(object):
logger.debug("No Device ID found.")
return None

def _readCard_normal(self):
# Scan for cards
uid = self.device.read_id(as_number=True)
if not uid:
logger.debug("No Device ID found.")
return None
card_id = str(uid)
logger.info("Card detected.")
logger.info(card_id)
return card_id

def readCard(self):
# Scan for cards
self.device.wait_for_tag()
return self._read_function()

@staticmethod
def cleanup():
GPIO.cleanup()
Expand Down Expand Up @@ -203,3 +224,6 @@ class Reader(object):
self.reader = UsbReader(device)
except IndexError:
sys.exit('Could not find the device %s.\n Make sure it is connected' % device_name)

def readCard(self):
return self.reader.readCard()
27 changes: 24 additions & 3 deletions scripts/Reader.py.experimental.Multi
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,17 @@ class UsbReader(object):

class Mfrc522Reader(object):
def __init__(self):
import pirc522
self.device = pirc522.RFID()
path = os.path.dirname(os.path.realpath(__file__))
readmode_uid = False
if os.path.isfile(path + '/../settings/Rfidreader_Rc522_Readmode_UID'):
with open(path + '/../settings/Rfidreader_Rc522_Readmode_UID', 'r') as f:
readmode_uid = f.read().rstrip().split(';', 1)[0] == 'ON'
self._read_function = self._readCard_normal if readmode_uid else self._readCard_legacy

def readCard(self):
def _readCard_legacy(self):
# Scan for cards
self.device.wait_for_tag()
(error, tag_type) = self.device.request()

if not error:
Expand All @@ -88,6 +94,22 @@ class Mfrc522Reader(object):
logger.debug("No Device ID found.")
return None

def _readCard_normal(self):
# Scan for cards
uid = self.device.read_id(as_number=True)
if not uid:
logger.debug("No Device ID found.")
return None
card_id = str(uid)
logger.info("Card detected.")
logger.info(card_id)
return card_id

def readCard(self):
# Scan for cards
self.device.wait_for_tag()
return self._read_function()

@staticmethod
def cleanup():
GPIO.cleanup()
Expand Down Expand Up @@ -158,7 +180,6 @@ class Pn532Reader:

class Reader(object):
def __init__(self):
self.reader = self
self.devs = list()
path = os.path.dirname(os.path.realpath(__file__))
if not os.path.isfile(path + '/deviceName.txt'):
Expand Down
2 changes: 0 additions & 2 deletions scripts/Reader.py.original
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,9 @@ def get_devices():


class Reader:
reader = None

def __init__(self):
logger.debug('Initialize Reader')
self.reader = self
path = os.path.dirname(os.path.realpath(__file__))
self.keys = "X^1234567890XXXXqwertzuiopXXXXasdfghjklXXXXXyxcvbnmXXXXXXXXXXXXXXXXXXXXXXX"
deviceNameFile = os.path.join(path, 'deviceName.txt')
Expand Down
4 changes: 1 addition & 3 deletions scripts/Reader.py.pcsc
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@ from smartcard.util import *

class Reader:

reader = None

def __init__(self):
self.reader = self
pass

def readCard(self):

Expand Down
9 changes: 1 addition & 8 deletions scripts/daemon_rfid_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,7 @@ def handler(signum, frame):
signal.alarm(1)

# reading the card id
# NOTE: it's been reported that KKMOON Reader might need the following line altered.
# Instead of:
# cardid = reader.reader.readCard()
# change the line to:
# cardid = reader.readCard()
# See here for (German ;) details:
# https://github.com/MiczFlor/RPi-Jukebox-RFID/issues/551
cardid = reader.reader.readCard()
cardid = reader.readCard()

# disable the alarm after a successful read
signal.alarm(0)
Expand Down
Loading

0 comments on commit 7504381

Please sign in to comment.