Commit 789d365b authored by Andrey Filippov's avatar Andrey Filippov

added cli argv

parent 88f9f20e
<?php <?php
$phone_ip= "192.168.7.222"; $phone_ip= "192.168.2.23"; // "192.168.7.222";
$phone_port= "8123"; $phone_port= "8123";
$log_dir = dirname(get_included_files()[0])."/logs"; // "/home/eyesis/git/motosat/attic/logs/"; $log_dir = dirname(get_included_files()[0])."/attic/logs"; // "/home/eyesis/git/motosat/attic/logs/";
$log_name = "phone07.log"; $log_name = "phone08.log";
//http://localhost/motosat/log_phone_sensors.php?ip=192.168.2.23&log_name=phone10.log
//php7.0 log_phone_sensors.php ip=192.168.2.23 log_name=phone11.log
if (isset($argc)) {
unset($argv[0]);
foreach ($argv as $value) {
$a = parse_ini_string($value);
if (count($a) > 0){
foreach ($a as $k=>$v){
$_GET[$k]=$v;
}
} else {
$_GET[$value]='';
}
}
if (isset($_GET["ip"])) { $phone_ip = myfval($_GET["ip"]);} }
if (isset($_GET["log_dir"])) { $log_dir = myfval($_GET["log_dir"]);} if (isset($_GET["ip"])) {
if (isset($_GET["log_name"])) { $log_name = myfval($_GET["log_name"]);} $phone_ip = $_GET["ip"];
}
if (isset($_GET["log_dir"])) {
$log_dir = $_GET["log_dir"];
}
if (isset($_GET["log_name"])) {
$log_name = $_GET["log_name"];
}
$phone_url = "http://".$phone_ip.":".$phone_port; $phone_url = "http://".$phone_ip.":".$phone_port;
$log_file = fopen(trim($log_dir,"/")."/".$log_name,"w"); $log_path = rtrim($log_dir,"/")."/".$log_name;
if (false) {
var_dump($_GET);
echo '$phone_url =' . $phone_url . "\n";
echo 'log_path = ' . $log_path . "\n";
exit(0);
}
$log_file = fopen($log_path,"w");
$ts_l = 14; $ts_l = 14;
$acc_l = 35; $acc_l = 35;
$mag_l = 35; $mag_l = 35;
...@@ -46,6 +75,12 @@ function getDishAngles($xml_state){ ...@@ -46,6 +75,12 @@ function getDishAngles($xml_state){
} }
return $DishAngles; return $DishAngles;
} }
function myfval ($s) {
$s=trim($s,"\" ");
return floatval($s);
}
/* /*
$xml=simplexml_load_string("<sensors><timestmap>1570632414615</timestmap><accelerometer>0.095215, -0.811707, 9.966614</accelerometer><magnetometer>-15.299988, 4.798889, 46.078491</magnetometer><azimuth>61.597424</azimuth><pitch>4.655828</pitch><roll>-0.547352</roll><longitude>-111.932889</longitude><latitude>40.723488</latitude><date>Wed Oct 09 14:46:54 MDT 2019</date></sensors>"); $xml=simplexml_load_string("<sensors><timestmap>1570632414615</timestmap><accelerometer>0.095215, -0.811707, 9.966614</accelerometer><magnetometer>-15.299988, 4.798889, 46.078491</magnetometer><azimuth>61.597424</azimuth><pitch>4.655828</pitch><roll>-0.547352</roll><longitude>-111.932889</longitude><latitude>40.723488</latitude><date>Wed Oct 09 14:46:54 MDT 2019</date></sensors>");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment