Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
elphel-web-393
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Elphel
elphel-web-393
Commits
a0cd44c5
Commit
a0cd44c5
authored
May 19, 2020
by
Oleg Dzhimiev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update system & fpga time from index.php
parent
cf152318
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
223 additions
and
186 deletions
+223
-186
index.php
src/index/index.php
+183
-177
utils.php
src/php_top/utils.php
+40
-9
No files found.
src/index/index.php
View file @
a0cd44c5
This diff is collapsed.
Click to expand it.
src/php_top/utils.php
View file @
a0cd44c5
...
@@ -12,19 +12,22 @@ include "include/elphel_functions_include.php";
...
@@ -12,19 +12,22 @@ include "include/elphel_functions_include.php";
$cmd
=
"donothing"
;
$cmd
=
"donothing"
;
if
(
isset
(
$_GET
[
'cmd'
]))
if
(
isset
(
$_GET
[
'cmd'
]))
$cmd
=
$_GET
[
'cmd'
];
$cmd
=
$_GET
[
'cmd'
];
else
if
(
isset
(
$argv
[
1
]))
else
if
(
isset
(
$argv
[
1
]))
$cmd
=
$argv
[
1
];
$cmd
=
$argv
[
1
];
// allow CORS
// allow CORS
header
(
'Access-Control-Allow-Origin: *'
);
header
(
'Access-Control-Allow-Origin: *'
);
switch
(
$cmd
){
switch
(
$cmd
){
case
"sensors"
:
case
"sensors"
:
print
(
cmd_sensors
());
print
(
cmd_sensors
());
break
;
break
;
default
:
case
"time"
:
print
(
"OK"
);
cmd_time
();
break
;
default
:
print
(
"OK"
);
}
}
function
cmd_sensors
(){
function
cmd_sensors
(){
...
@@ -37,12 +40,40 @@ function cmd_sensors(){
...
@@ -37,12 +40,40 @@ function cmd_sensors(){
$res
.=
"
\t\t
<port index='
$i
' port='
$p
'>
$sensor
</port>
\n
"
;
$res
.=
"
\t\t
<port index='
$i
' port='
$p
'>
$sensor
</port>
\n
"
;
}
}
$res
.=
"
\t
</camera>
\n
"
;
$res
.=
"
\t
</camera>
\n
"
;
return
wrap_into_xml
(
$res
);
}
function
cmd_time
(){
date_default_timezone_set
(
'UTC'
);
$t
=
elphel_get_fpga_time
();
if
(
!
isset
(
$_GET
[
'ts'
])){
//date +%s will report system time
//print(exec("date +%s"));
print
(
"Camera time:
$t
"
);
}
else
{
// ts is in ms
$ts_s
=
substr
(
$_GET
[
'ts'
],
0
,
10
);
$ts_ms
=
substr
(
$_GET
[
'ts'
],
-
3
);
//$ts = $_GET['ts']/1000;
$ts_formatted
=
date
(
"Y-m-d H:i:s.
$ts_ms
"
,
$ts_s
);
print
(
"Your time:
$ts_s
.
$ts_ms
(
$ts_formatted
)
\n
Camera time:
$t
\n
"
);
if
(
abs
(
$ts_s
-
$t
)
>
24
*
3600
){
elphel_set_fpga_time
(
$_GET
[
'ts'
]
/
1000
);
exec
(
"date -s
$ts_formatted
"
);
exec
(
"hwclock --systohc"
);
print
(
"Timestamps differ by more than 24h. Camera and fpga time updated.
\n
"
);
}
}
}
function
wrap_into_xml
(
$s
){
$xml
=
"<?xml version='1.0' standalone='yes'?>
\n
"
;
$xml
=
"<?xml version='1.0' standalone='yes'?>
\n
"
;
$xml
.=
"<Document>
\n
"
;
$xml
.=
"<Document>
\n
"
;
$xml
.=
$
re
s
;
$xml
.=
$s
;
$xml
.=
"</Document>
\n
"
;
$xml
.=
"</Document>
\n
"
;
return
$xml
;
return
$xml
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment