#!/usr/bin/php [rfid1, rfid2, ..] =========================================================*/ /* [3] Initialize global variables =========================================================*/ $last_card = null; $times = 0; } function mfrc522_loop(){ /* [1] Wait for rfid card =========================================================*/ while( ($code=syscall(SOURCE_DIR.'/lib/mfrc522/read')) === false ); $code = strtoupper($code); slog("card '$code' read", 'mfrc522:read'); $start_ts = microtime(true); /* [2] Check for user in auth list =========================================================*/ /* [n] Wait for 0.5 s before reading again =========================================================*/ while( microtime(true)-$start_ts < 0.5 ); } slog('daemon started (loop)', 'mfrc522:loop'); while( true ) mfrc522_loop(); ?>