Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //This config is shared across all modules
- define("DEBUG", true); //Enable debug mode
- date_default_timezone_set("Europe/Warsaw"); //Timezone
- define("RFID_DEVICES_PATTERNS", '/dev/ttyUSB*[0-99] /dev/usbserial /dev/cu.usb*'); //Separate by space, patterns here should NOT contain " - it's quirk only for command line
- define("RFID_BAUD", 19200);
- define("STTY_PATH", "/bin/stty");
- define("RFID_START", "#"); //Set to NULL if your device doesn't send specific character
- define("RFID_END", "\n"); //Some RFID readers use \r\n, some \n and some other character
- define("RFID_PAYLOAD_LEN", 16); //Packet length in bytes (NOT including START and END)
- //Some runtimes - DO NOT MODIFY!!!
- /********************************************************************************************************************************************************************************************************************/
- define("L_INF", "INFO");
- define("L_ERR", "ERROR");
- define("L_FTL", "FATAL");
- define("L_WRN", "WARNING");
- define("L_DBG", "DEBUG");
- if(DEBUG) error_reporting(E_ALL);
- set_time_limit(0);
- $uname = strtolower(php_uname("s"));
- if($uname === "darwin" || strpos($uname, "bsd") !== false) { pLog("Running on $uname [BSD-compilant]", L_DBG); define("IS_BSD", true); }
- elseif(strpos($uname, "linux") !== false) { pLog("Running on Linux OS", L_DBG); define("IS_BSD", false); }
- elseif(strpos($uname, "windows") === 0) pLog('Running in Win$hit environment is not supported and NEVER will', L_FTL);
- else pLog("Unknown OS detected - $uname", L_FTL);
- function pLog($txt, $code=L_INF) {
- if(!DEBUG && $code === L_INF) return;
- $txt = str_replace(array("\n", "\r"), array('\n', '\r'), $txt);
- switch($code) {
- case L_INF: $color = "[1;32m"; break; //Green
- case L_FTL:
- case L_ERR: $color = "[0;31m"; break; //Red
- case L_WRN: $color = "[1;33m"; break; //Yellow
- case L_DBG: $color = "[0;37m"; break; //Light grey
- default:
- $color = "[0;90m"; //Dark grey
- $code = "UNKNOWN-$code";
- }
- echo chr(27).$color."<".date("d.m.Y H:i:s")."> [$code] $txt\n".chr(27).chr(27)."[0m".chr(27);
- if($code === L_FTL) die();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement