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

Bugfix: re-enable Mifare Ultralight C support #2214

Merged
merged 8 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions scripts/Reader.py.experimental
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,13 @@ class UsbReader(object):


class Mfrc522Reader(object):
def __init__(self):
def __init__(self, mode_legacy=True):
import pirc522
self.device = pirc522.RFID()
self.mode_legacy = mode_legacy
self.readCard = self.readCard_legacy if self.mode_legacy else self.readCard_normal

def readCard(self):
def readCard_legacy(self):
# Scan for cards
self.device.wait_for_tag()
(error, tag_type) = self.device.request()
Expand All @@ -70,6 +72,17 @@ 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

@staticmethod
def cleanup():
GPIO.cleanup()
Expand Down Expand Up @@ -188,9 +201,14 @@ class Reader(object):
else:
with open(path + '/deviceName.txt', 'r') as f:
device_name = f.read().rstrip().split(';', 1)[0]
try:
with open(path + '/../settings/Mode_Legacy', 'r') as f:
mode_legacy = f.read().rstrip().split(';', 1)[0] == 'ON'
except FileNotFoundError:
AlvinSchiller marked this conversation as resolved.
Show resolved Hide resolved
mode_legacy = True

if device_name == 'MFRC522':
self.reader = Mfrc522Reader()
self.reader = Mfrc522Reader(mode_legacy)
elif device_name == 'RDM6300':
# The Rdm6300Reader supports 2 Additional Number Formats which can bee choosen by an optional parameter dictionary:
# {'numberformat':'card_id_float'} or {'numberformat':'card_id_dec'}
Expand Down
12 changes: 12 additions & 0 deletions scripts/inc.writeGlobalConfig.sh
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,16 @@ fi
# 2. then|or read value from file
SECONDSWIPEPAUSECONTROLS=`cat $PATHDATA/../settings/Second_Swipe_Pause_Controls`

##############################################
# Legacy mode
# 1. create a default if file does not exist
if [ ! -f $PATHDATA/../settings/Mode_Legacy ]; then
echo "ON" > $PATHDATA/../settings/Mode_Legacy
AlvinSchiller marked this conversation as resolved.
Show resolved Hide resolved
chmod 777 $PATHDATA/../settings/Mode_Legacy
fi
# 2. then|or read value from file
MODELEGACY=`cat $PATHDATA/../settings/Mode_Legacy`

##############################################
# Audio_iFace_Name
# 1. create a default if file does not exist
Expand Down Expand Up @@ -332,6 +342,7 @@ CMDSEEKBACK=`grep 'CMDSEEKBACK' $PATHDATA/../settings/rfid_trigger_play.conf|tai
# SECONDSWIPE
# SECONDSWIPEPAUSE
# SECONDSWIPEPAUSECONTROLS
# MODELEGACY
AlvinSchiller marked this conversation as resolved.
Show resolved Hide resolved
# AUDIOIFACENAME
# AUDIOIFACEACTIVE
# VOLUMEMANAGER
Expand Down Expand Up @@ -369,6 +380,7 @@ echo "SWIPEORPLACE=\"${SWIPEORPLACE}\"" >> "${PATHDATA}/../settings/global.conf"
echo "SECONDSWIPE=\"${SECONDSWIPE}\"" >> "${PATHDATA}/../settings/global.conf"
echo "SECONDSWIPEPAUSE=\"${SECONDSWIPEPAUSE}\"" >> "${PATHDATA}/../settings/global.conf"
echo "SECONDSWIPEPAUSECONTROLS=\"${SECONDSWIPEPAUSECONTROLS}\"" >> "${PATHDATA}/../settings/global.conf"
echo "MODELEGACY=\"${MODELEGACY}\"" >> "${PATHDATA}/../settings/global.conf"
echo "AUDIOIFACENAME=\"${AUDIOIFACENAME}\"" >> "${PATHDATA}/../settings/global.conf"
echo "AUDIOIFACEACTIVE=\"${AUDIOIFACEACTIVE}\"" >> "${PATHDATA}/../settings/global.conf"
echo "VOLUMEMANAGER=\"${VOLUMEMANAGER}\"" >> "${PATHDATA}/../settings/global.conf"
Expand Down