added mfrc522 reader (with temporary buffer replacement)
This commit is contained in:
parent
3427d07580
commit
3a9b6b8d5e
|
@ -3,11 +3,13 @@
|
|||
# RESET OUTPUT BUFFER
|
||||
|
||||
# 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('DATA_DIR', ROOT_DIR.'/data');
|
||||
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');
|
||||
|
||||
# CONFIGURATION FILES
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
#!/bin/sh
|
||||
|
||||
php $(realpath $(dirname $0))/source/read.php;
|
|
@ -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();
|
||||
?>
|
||||
|
Loading…
Reference in New Issue