2017-01-29 22:02:29 +00:00
|
|
|
#!/usr/bin/php
|
|
|
|
|
|
|
|
<?php
|
|
|
|
|
2017-01-30 09:39:45 +00:00
|
|
|
require_once __DIR__.'/../../include/php/const';
|
2017-01-29 22:02:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
function mfrc522_read(){
|
|
|
|
|
|
|
|
/* [1] Read card code
|
|
|
|
=========================================================*/
|
|
|
|
/* (1) Fetch card file */
|
|
|
|
$code = @file_get_contents(TMP_DIR.'/card');
|
|
|
|
|
|
|
|
/* (2) Manage error */
|
|
|
|
if( !is_string($code) || !preg_match("/^\s*([A-F0-9]{2}(?:-[A-F0-9]{2}){3,5})\s*$/m", $code, $match) )
|
|
|
|
return 127;
|
|
|
|
|
|
|
|
/* (3) Extract only code */
|
|
|
|
$code = $match[1];
|
|
|
|
|
|
|
|
|
|
|
|
/* [2] Return card code
|
|
|
|
=========================================================*/
|
|
|
|
slog("read $code code", 'mfrc522:read');
|
|
|
|
return $code;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
echo mfrc522_read();
|
|
|
|
?>
|
|
|
|
|