added mfrc522 reader (with temporary buffer replacement)

This commit is contained in:
xdrm-brackets 2017-01-29 23:02:29 +01:00
parent 3427d07580
commit 3a9b6b8d5e
3 changed files with 40 additions and 2 deletions

View File

@ -3,11 +3,13 @@
# RESET OUTPUT BUFFER # RESET OUTPUT BUFFER
# MAIN DIRECTORIES # MAIN DIRECTORIES
define('ROOT_DIR', '/home/sats/satsd'); #define('ROOT_DIR', '/home/sats/satsd');
define('ROOT_DIR', '/home/xdrm-brackets/SANDBOX/sats-local');
define('LOG_DIR', ROOT_DIR.'/log'); define('LOG_DIR', ROOT_DIR.'/log');
define('DATA_DIR', ROOT_DIR.'/data'); define('DATA_DIR', ROOT_DIR.'/data');
define('CONF_DIR', ROOT_DIR.'/conf'); define('CONF_DIR', ROOT_DIR.'/conf');
define('SOURCE_DIR', ROOT_DIR.'/source'); #define('SOURCE_DIR', ROOT_DIR.'/source');
define('SOURCE_DIR', ROOT_DIR.'/home/xdrm-brackets/Desktop/git.xdrm.io/logauth-sats');
define('TMP_DIR', ROOT_DIR.'/tmp'); define('TMP_DIR', ROOT_DIR.'/tmp');
# CONFIGURATION FILES # CONFIGURATION FILES

3
lib/mfrc522/read Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
php $(realpath $(dirname $0))/source/read.php;

33
lib/mfrc522/source/read.php Executable file
View File

@ -0,0 +1,33 @@
#!/usr/bin/php
<?php
require_once __DIR__.'/../../include/const';
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();
?>