Commit bd363b03 authored by Oleg Dzhimiev's avatar Oleg Dzhimiev

cherry-picked sys & fpga time updating from warrior branch

parent 92ec9d48
......@@ -71,30 +71,25 @@
.img_window{
border: 1px solid rgba(210,210,210,1);
}
.port_preview{
width:300px;
min-height:224px;
overflow: auto;
}
table td {
padding-right:10px;
}
.btn.active:focus, .btn:focus{
outline:none;
}
.btn-toggle{
padding: 1px 0px;
}
</style>
</head>
<body>
<div style='padding:10px'>
<?php
<?php
include "include/elphel_functions_include.php";
......@@ -135,7 +130,7 @@
echo "Camera Control Interface<ul>$port_links</ul>\n";
?>
?>
<table>
<tr id="toggle_awb" title='Auto White Balance'>
<td>
......@@ -177,28 +172,40 @@
<a href="/test_sensors.php" title="Switch to test pattern and check md5sums">Test sensors</a><br />
<a href="/debugfs.html" title="Linux Kernel Dynamic Debug helper interface (debug device drivers)">DebugFS</a><br />
</div>
<script>
var jp4_previews_enable = true;
var jp4_previews_enable = true;
$(function(){
$(function(){
check_time();
init_awb_toggle();
init_aexp_toggle();
init_jp4_previews();
});
});
function init_jp4_previews(){
async function check_time(){
$.ajax({
url: "utils.php?cmd=time&ts="+Date.now(),
success: (res)=>{
console.log(res);
}
});
}
function init_jp4_previews(){
$('.port_preview').each(function(){
index = parseInt($(this).attr("index"));
if (jp4_previews_enable) {
$(this).jp4({ip:location.host,port:2323+index,width:300,fast:true,lowres:4});
//$(this).jp4({src:"http://"+location.host+":"+(2323+index)+"/img",width:300,fast:true,lowres:4});
}else{
$(this).html("<img width='300' src='http://"+location.host+":"+(2323+index)+"/img' />");
}
});
}
}
function init_awb_toggle(){
function init_awb_toggle(){
$('#toggle_awb').click(function() {
if ($(this).find('.btn.active').html()=="ON"){
......@@ -230,7 +237,7 @@ function init_awb_toggle(){
});
});
}
}
function init_aexp_toggle(){
$('#toggle_aexp').click(function() {
......
......@@ -23,6 +23,9 @@ switch($cmd){
case "sensors":
print(cmd_sensors());
break;
case "time":
cmd_time();
break;
default:
print("OK");
}
......@@ -37,12 +40,40 @@ function cmd_sensors(){
$res .= "\t\t<port index='$i' port='$p'>$sensor</port>\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)\nCamera 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 .= "<Document>\n";
$xml .= $res;
$xml .= $s;
$xml .= "</Document>\n";
return $xml;
}
......
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