Skip to content

Commit 7504381

Browse files
authored
Merge branch 'MiczFlor:develop' into develop
2 parents 85a4e1b + 5dca35f commit 7504381

14 files changed

+152
-65
lines changed

.github/workflows/php.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929

3030
- name: Cache Composer packages
3131
id: composer-cache
32-
uses: actions/cache@v3
32+
uses: actions/cache@v4
3333
with:
3434
path: vendor
3535
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}

.github/workflows/test_docker_debian.yml

+43-14
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ on:
2020
# The branches below must be a subset of the branches above
2121
branches:
2222
- develop
23-
- main
23+
- master
2424
paths:
2525
- '.github/workflows/test_docker_debian*.yml'
2626
- 'ci/**'
@@ -39,19 +39,48 @@ concurrency:
3939

4040
jobs:
4141

42-
# Build container and run tests
43-
run:
44-
name: ${{ matrix.debian_codename }}
45-
strategy:
46-
fail-fast: false
47-
matrix:
48-
debian_codename: ['bookworm', 'bullseye', 'buster']
42+
# Build container and run tests. Duplication of job intended for better visualization.
43+
run_bookworm_armv7:
44+
name: 'bookworm armv7'
4945
uses: ./.github/workflows/test_docker_debian_codename_sub.yml
5046
with:
51-
runs_on: ubuntu-latest
47+
debian_codename: 'bookworm'
5248
platform: linux/arm/v7
53-
docker_image_name: rpi-jukebox-rfid
54-
cache_scope: ${{ github.ref }}-test-debian
55-
matrix_usernames: "['pi', 'hans']"
56-
matrix_test_scripts: "['run_installation_tests.sh', 'run_installation_tests2.sh', 'run_installation_tests3.sh']"
57-
debian_codename: ${{ matrix.debian_codename }}
49+
50+
# # can be activate on test branches
51+
# run_bookworm_armv6:
52+
# name: 'bookworm armv6'
53+
# uses: ./.github/workflows/test_docker_debian_codename_sub.yml
54+
# with:
55+
# debian_codename: 'bookworm'
56+
# platform: linux/arm/v6
57+
58+
run_bullseye_armv7:
59+
name: 'bullseye armv7'
60+
uses: ./.github/workflows/test_docker_debian_codename_sub.yml
61+
with:
62+
debian_codename: 'bullseye'
63+
platform: linux/arm/v7
64+
65+
# # can be activate on test branches, currently failing
66+
# run_bullseye_armv6:
67+
# name: 'bullseye armv6'
68+
# uses: ./.github/workflows/test_docker_debian_codename_sub.yml
69+
# with:
70+
# debian_codename: 'bullseye'
71+
# platform: linux/arm/v6
72+
73+
run_buster_armv7:
74+
name: 'buster armv7'
75+
uses: ./.github/workflows/test_docker_debian_codename_sub.yml
76+
with:
77+
debian_codename: 'buster'
78+
platform: linux/arm/v7
79+
80+
# # can be activate on test branches, currently failing
81+
# run_buster_armv6:
82+
# name: 'buster armv6'
83+
# uses: ./.github/workflows/test_docker_debian_codename_sub.yml
84+
# with:
85+
# debian_codename: 'buster'
86+
# platform: linux/arm/v6

.github/workflows/test_docker_debian_codename_sub.yml

+29-21
Original file line numberDiff line numberDiff line change
@@ -3,36 +3,33 @@ name: Subworkflow Test Install Scripts Debian
33
on:
44
workflow_call:
55
inputs:
6-
runs_on:
7-
required: true
8-
type: string
9-
platform:
10-
required: true
11-
type: string
126
debian_codename:
137
required: true
148
type: string
15-
cache_scope:
9+
platform:
1610
required: true
1711
type: string
1812
docker_image_name:
19-
required: true
20-
type: string
21-
matrix_usernames:
22-
required: true
13+
required: false
2314
type: string
24-
matrix_test_scripts:
25-
required: true
15+
default: rpi-jukebox-rfid
16+
cache_scope:
17+
required: false
2618
type: string
19+
default: ${{ github.ref }}-test-debian
2720
local_registry_port:
2821
required: false
2922
type: number
3023
default: 5000
24+
runs_on:
25+
required: false
26+
type: string
27+
default: ubuntu-latest
3128

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

3835
jobs:
@@ -45,6 +42,7 @@ jobs:
4542
cache_key: ${{ steps.vars.outputs.cache_key }}
4643
image_file_name: ${{ steps.vars.outputs.image_file_name }}
4744
image_tag_name: ${{ steps.vars.outputs.image_tag_name }}
45+
docker_run_options: ${{ steps.vars.outputs.docker_run_options }}
4846

4947
# create local docker registry to use locally build images
5048
services:
@@ -71,22 +69,28 @@ jobs:
7169
DEBIAN_CODENAME: ${{ inputs.debian_codename }}
7270
DOCKER_IMAGE_NAME: ${{ inputs.docker_image_name }}
7371
CACHE_SCOPE: ${{ inputs.cache_scope }}
72+
PLATFORM: ${{ inputs.platform }}
7473
run: |
75-
echo "image_tag_name=${{ env.DOCKER_IMAGE_NAME }}:${{ env.DEBIAN_CODENAME }}-test" >> $GITHUB_OUTPUT
76-
echo "image_file_name=${{ env.DOCKER_IMAGE_NAME }}-${{ env.DEBIAN_CODENAME }}.tar" >> $GITHUB_OUTPUT
77-
echo "cache_scope=${{ env.CACHE_SCOPE }}-${{ env.DEBIAN_CODENAME }}" >> $GITHUB_OUTPUT
74+
PLATFORM=${PLATFORM////_}
75+
echo "image_tag_name=${{ env.DOCKER_IMAGE_NAME }}:${{ env.DEBIAN_CODENAME }}-${PLATFORM}-test" >> $GITHUB_OUTPUT
76+
echo "image_file_name=${{ env.DOCKER_IMAGE_NAME }}-${{ env.DEBIAN_CODENAME }}-${PLATFORM}.tar" >> $GITHUB_OUTPUT
77+
echo "cache_scope=${{ env.CACHE_SCOPE }}-${{ env.DEBIAN_CODENAME }}-${PLATFORM}" >> $GITHUB_OUTPUT
7878
7979
- name: Set Output vars
8080
id: vars
8181
env:
8282
LOCAL_REGISTRY_PORT: ${{ inputs.local_registry_port }}
83+
PLATFORM: ${{ inputs.platform }}
8384
run: |
8485
echo "image_tag_name=${{ steps.pre-vars.outputs.image_tag_name }}" >> $GITHUB_OUTPUT
8586
echo "image_tag_name_local_base=localhost:${{ env.LOCAL_REGISTRY_PORT }}/${{ steps.pre-vars.outputs.image_tag_name }}-base" >> $GITHUB_OUTPUT
8687
echo "image_file_name=${{ steps.pre-vars.outputs.image_file_name }}" >> $GITHUB_OUTPUT
8788
echo "image_file_path=./${{ steps.pre-vars.outputs.image_file_name }}" >> $GITHUB_OUTPUT
8889
echo "cache_scope=${{ steps.pre-vars.outputs.cache_scope }}" >> $GITHUB_OUTPUT
8990
echo "cache_key=${{ steps.pre-vars.outputs.cache_scope }}-${{ github.sha }}#${{ github.run_attempt }}" >> $GITHUB_OUTPUT
91+
if [ "${{ env.PLATFORM }}" == "linux/arm/v6" ] ; then
92+
echo "docker_run_options=-e QEMU_CPU=arm1176" >> $GITHUB_OUTPUT
93+
fi
9094
9195
# Build base image for debian version name. Layers will be cached and image pushes to local registry
9296
- name: Build Image - Base
@@ -128,7 +132,7 @@ jobs:
128132
with:
129133
name: ${{ steps.vars.outputs.image_file_name }}
130134
path: ${{ steps.vars.outputs.image_file_path }}
131-
retention-days: 2
135+
retention-days: 1
132136

133137

134138
# Run tests with build image
@@ -139,8 +143,12 @@ jobs:
139143
strategy:
140144
fail-fast: false
141145
matrix:
142-
username: ${{ fromJSON(inputs.matrix_usernames) }}
143-
test_script: ${{ fromJSON(inputs.matrix_test_scripts) }}
146+
username: ['pi']
147+
test_script: ['run_installation_tests.sh', 'run_installation_tests2.sh', 'run_installation_tests3.sh']
148+
include:
149+
- username: 'hans'
150+
test_script: 'run_installation_tests.sh'
151+
144152

145153
steps:
146154
- name: Set up QEMU
@@ -163,7 +171,7 @@ jobs:
163171
uses: tj-actions/docker-run@v2
164172
with:
165173
image: ${{ needs.build.outputs.image_tag_name }}
166-
options: --platform ${{inputs.platform }} --user ${{ matrix.username }}
174+
options: ${{ needs.build.outputs.docker_run_options }} --platform ${{ inputs.platform }} --user ${{ matrix.username }} --init
167175
name: ${{ matrix.test_script }}
168176
args: |
169177
./${{ matrix.test_script }}

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ While Version 3 is still under development, it is becoming a lot more stable! Al
5050
If you seek the adventure, your support will be more then welcome. Before contributing, check out the following references.
5151

5252
***[Releases](https://github.com/MiczFlor/RPi-Jukebox-RFID/releases?q=v3&expanded=true)**
53-
* 🚀 **[Install Jukebox Version 3 Beta](https://github.com/MiczFlor/RPi-Jukebox-RFID/blob/future3/develop/documentation/builders/installation.md)**
53+
* 🚀 **[Install Jukebox Version 3](https://github.com/MiczFlor/RPi-Jukebox-RFID/blob/future3/main/documentation/builders/installation.md)**
5454
* 🐛 [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)
55-
* ☑️ [Feature Status](https://github.com/MiczFlor/RPi-Jukebox-RFID/blob/future3/develop/documentation/developers/status.md)
56-
* 📖 [Documentation](https://github.com/MiczFlor/RPi-Jukebox-RFID/blob/future3/develop/documentation/README.md)
57-
* 👩‍💻 [Development](https://github.com/MiczFlor/RPi-Jukebox-RFID/blob/future3/develop/documentation/developers/README.md)
55+
* ☑️ [Feature Status](https://github.com/MiczFlor/RPi-Jukebox-RFID/blob/future3/main/documentation/developers/status.md)
56+
* 📖 [Documentation](https://github.com/MiczFlor/RPi-Jukebox-RFID/blob/future3/main/documentation/README.md)
57+
* 👩‍💻 [Development](https://github.com/MiczFlor/RPi-Jukebox-RFID/blob/future3/main/documentation/developers/README.md)
5858
* 🦄 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)
5959

6060
---

components/rfid-reader/RC522/setup_rc522.sh

+8-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ question() {
1616
printf "Please make sure that the RC522 reader is wired up correctly to the GPIO ports before continuing...\n"
1717
question "Continue"
1818

19+
printf "Use backward-compatible card ID (not suggested for new installations)?\n"
20+
read -p "(y/N) " choice
21+
case "$choice" in
22+
y|Y ) printf "OFF" > "${JUKEBOX_HOME_DIR}"/settings/Rfidreader_Rc522_Readmode_UID;;
23+
* ) printf "ON" > "${JUKEBOX_HOME_DIR}"/settings/Rfidreader_Rc522_Readmode_UID;;
24+
esac
25+
1926
printf "Installing Python requirements for RC522...\n"
2027
sudo python3 -m pip install --upgrade --force-reinstall -q -r "${JUKEBOX_HOME_DIR}"/components/rfid-reader/RC522/requirements.txt
2128

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

3138
printf "Restarting phoniebox-rfid-reader service...\n"
32-
sudo systemctl start phoniebox-rfid-reader.service
39+
sudo systemctl restart phoniebox-rfid-reader.service
3340

3441
printf "Done.\n"

scripts/Reader.py

-2
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,8 @@ def get_devices():
2929

3030

3131
class Reader:
32-
reader = None
3332

3433
def __init__(self):
35-
self.reader = self
3634
path = os.path.dirname(os.path.realpath(__file__))
3735
self.keys = "X^1234567890XXXXqwertzuiopXXXXasdfghjklXXXXXyxcvbnmXXXXXXXXXXXXXXXXXXXXXXX"
3836
if not os.path.isfile(path + '/deviceName.txt'):

scripts/Reader.py.Multi

-2
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,8 @@ def get_devices():
2929

3030

3131
class Reader:
32-
reader = None
3332

3433
def __init__(self):
35-
self.reader = self
3634
devs = list()
3735
path = os.path.dirname(os.path.realpath(__file__))
3836
self.keys = "X^1234567890XXXXqwertzuiopXXXXasdfghjklXXXXXyxcvbnmXXXXXXXXXXXXXXXXXXXXXXX"

scripts/Reader.py.experimental

+26-2
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,15 @@ class Mfrc522Reader(object):
5353
def __init__(self):
5454
import pirc522
5555
self.device = pirc522.RFID()
56+
path = os.path.dirname(os.path.realpath(__file__))
57+
readmode_uid = False
58+
if os.path.isfile(path + '/../settings/Rfidreader_Rc522_Readmode_UID'):
59+
with open(path + '/../settings/Rfidreader_Rc522_Readmode_UID', 'r') as f:
60+
readmode_uid = f.read().rstrip().split(';', 1)[0] == 'ON'
61+
self._read_function = self._readCard_normal if readmode_uid else self._readCard_legacy
5662

57-
def readCard(self):
63+
def _readCard_legacy(self):
5864
# Scan for cards
59-
self.device.wait_for_tag()
6065
(error, tag_type) = self.device.request()
6166

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

78+
def _readCard_normal(self):
79+
# Scan for cards
80+
uid = self.device.read_id(as_number=True)
81+
if not uid:
82+
logger.debug("No Device ID found.")
83+
return None
84+
card_id = str(uid)
85+
logger.info("Card detected.")
86+
logger.info(card_id)
87+
return card_id
88+
89+
def readCard(self):
90+
# Scan for cards
91+
self.device.wait_for_tag()
92+
return self._read_function()
93+
7394
@staticmethod
7495
def cleanup():
7596
GPIO.cleanup()
@@ -203,3 +224,6 @@ class Reader(object):
203224
self.reader = UsbReader(device)
204225
except IndexError:
205226
sys.exit('Could not find the device %s.\n Make sure it is connected' % device_name)
227+
228+
def readCard(self):
229+
return self.reader.readCard()

scripts/Reader.py.experimental.Multi

+24-3
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,17 @@ class UsbReader(object):
7070

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

75-
def readCard(self):
82+
def _readCard_legacy(self):
7683
# Scan for cards
77-
self.device.wait_for_tag()
7884
(error, tag_type) = self.device.request()
7985

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

97+
def _readCard_normal(self):
98+
# Scan for cards
99+
uid = self.device.read_id(as_number=True)
100+
if not uid:
101+
logger.debug("No Device ID found.")
102+
return None
103+
card_id = str(uid)
104+
logger.info("Card detected.")
105+
logger.info(card_id)
106+
return card_id
107+
108+
def readCard(self):
109+
# Scan for cards
110+
self.device.wait_for_tag()
111+
return self._read_function()
112+
91113
@staticmethod
92114
def cleanup():
93115
GPIO.cleanup()
@@ -158,7 +180,6 @@ class Pn532Reader:
158180

159181
class Reader(object):
160182
def __init__(self):
161-
self.reader = self
162183
self.devs = list()
163184
path = os.path.dirname(os.path.realpath(__file__))
164185
if not os.path.isfile(path + '/deviceName.txt'):

scripts/Reader.py.original

-2
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,9 @@ def get_devices():
3030

3131

3232
class Reader:
33-
reader = None
3433

3534
def __init__(self):
3635
logger.debug('Initialize Reader')
37-
self.reader = self
3836
path = os.path.dirname(os.path.realpath(__file__))
3937
self.keys = "X^1234567890XXXXqwertzuiopXXXXasdfghjklXXXXXyxcvbnmXXXXXXXXXXXXXXXXXXXXXXX"
4038
deviceNameFile = os.path.join(path, 'deviceName.txt')

scripts/Reader.py.pcsc

+1-3
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@ from smartcard.util import *
1212

1313
class Reader:
1414

15-
reader = None
16-
1715
def __init__(self):
18-
self.reader = self
16+
pass
1917

2018
def readCard(self):
2119

scripts/daemon_rfid_reader.py

+1-8
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,7 @@ def handler(signum, frame):
8585
signal.alarm(1)
8686

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

9790
# disable the alarm after a successful read
9891
signal.alarm(0)

0 commit comments

Comments
 (0)