-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgpsreader.php
More file actions
77 lines (61 loc) · 2.8 KB
/
gpsreader.php
File metadata and controls
77 lines (61 loc) · 2.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
/*
phpGPSReader - reading GPS locations from cgps and put them in arrays.
Copyright (C) 2017 Ole-Henrik Jakobsen
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
This is a PHP-CLI script made to pick up location from cgps.
Configure config.ini to choose which daemon to use.
Requirements: php-cli gpsd gpsd-clients
Last updated: 2018-05-25
*/
$ini_file = "config.ini";
$ini_array = parse_ini_file($ini_file, true);
// put array data into variables
$test = @$ini_array["TEST"];
$daemon = @$ini_array["DAEMON"];
function gpsreader() {
global $ini_array;
global $daemon;
global $test;
if(!$test) { $test = 0; }
// get temperature from sensor
include("daemons/" . $daemon . ".php");
if($gpsreader) {
return $gpsreader_array;
}
else {
return false;
}
}
if(!@$test && @$argc && @is_file("" . @dirname(__FILE__) . "/daemons/" . $argv[1] . ".php")) {
$use_sensor = $argv[1];
$gpsreader_cli = gpsreader();
if(@$argv[2] == "1") {
$dis_errors = @$argv[2];
print("Device: " . @$gpsreader_cli["deviceport"] . "\n");
print("Time: " . @$gpsreader_cli["time"] . ""); if($dis_errors) { print(" (offset: " . @$gpsreader_cli["error"]["timeoffset"] . ")"); } print("\n");
print("Latitude: " . @$gpsreader_cli["latitude"] . ""); if($dis_errors) { print(" (error: " . @$gpsreader_cli["error"]["latitude"] . ")"); } print("\n");
print("Longitude: " . @$gpsreader_cli["longitude"] . ""); if($dis_errors) { print(" (error: " . @$gpsreader_cli["error"]["longitude"] . ")"); } print("\n");
print("Altitude: " . @$gpsreader_cli["altitude"] . ""); if($dis_errors) { print(" (error: " . @$gpsreader_cli["error"]["altitude"] . ")"); } print("\n");
print("Track: " . @$gpsreader_cli["track"] . ""); if($dis_errors) { print(" (error: " . @$gpsreader_cli["error"]["course"] . ")"); } print("\n");
print("Speed: " . @$gpsreader_cli["speed"] . ""); if($dis_errors) { print(" (error: " . @$gpsreader_cli["error"]["speed"] . ")"); } print("\n");
print("Climb: " . @$gpsreader_cli["climb"] . "\n");
print("Mode: " . @$gpsreader_cli["mode"] . "\n");
}
else if(@$argv[2] == "simple_location") {
print("" . @$gpsreader_cli["latitude"] . "," . @$gpsreader_cli["longitude"] . "");
}
}
if($test) {
gpsreader();
}
?>