v1.9.23: auto-detect PC/SC reader with retry on startup

__main__.py:
- Probe smartcard.System.readers() before init_reader when no reader
  was explicitly specified
- Retry 3 times with 2s delay to handle late pcscd startup and
  USB enumeration delays

start.sh:
- Also match pcscd.bin process name (some distros)
- Wait 1s for pcscd if not running yet
This commit is contained in:
2026-08-31 22:49:52 +03:00
parent 29c3143909
commit 8c41655e18
4 changed files with 27 additions and 6 deletions
+8 -4
View File
@@ -10,10 +10,14 @@ VENV_DIR="$SCRIPT_DIR/.venv"
# Auto-detect reader
READER_ARGS=""
if command -v pcscd > /dev/null 2>&1 && pgrep -x pcscd > /dev/null 2>&1; then
READER_ARGS="-p 0"
elif [ -e /dev/ttyUSB0 ]; then
READER_ARGS="-d /dev/ttyUSB0"
if command -v pcscd > /dev/null 2>&1; then
# Give pcscd a moment if it's not running yet (USB enumeration delay)
if ! pgrep -x pcscd > /dev/null 2>&1 && ! pgrep -x pcscd.bin > /dev/null 2>&1; then
sleep 1
fi
if pgrep -x pcscd > /dev/null 2>&1 || pgrep -x pcscd.bin > /dev/null 2>&1; then
READER_ARGS="-p 0"
fi
fi
SERVER=""