...
 
Commits (2)
......@@ -30,6 +30,8 @@
const params = new URLSearchParams(location.search);
const port = params.get('port') || 0;
const refresh = params.get('refresh') || 5;
const sensor_type = params.get('sensor_type') || '';
console.log("img.html: sensor_type="+sensor_type);
if (params.get('port')===null){
let s = "";
......@@ -42,8 +44,11 @@
}
let imgsrv_port = IMGSRV_PORT0 + parseInt(port);
let t1 = $("#cnv_div").jp4({src:"http://"+location.host+":"+imgsrv_port+"/img",width:1600,fast:true,lowres:2,debug:false,refresh:true});
if (sensor_type == "boson640") {
let t1 = $("#cnv_div").jp4({src:"http://"+location.host+":"+imgsrv_port+"/tiff_palette=2/tiff_telem=1/tiff_auto=0/tiff_convert/bimg",width:1600,fast:true,lowres:2,debug:false,refresh:true});
} else {
let t1 = $("#cnv_div").jp4({src:"http://"+location.host+":"+imgsrv_port+"/img",width:1600,fast:true,lowres:2,debug:false,refresh:true});
}
</script>
</body>
......
......@@ -122,7 +122,7 @@
$sensors = get_sensors();
$sensor_type = "none";
$preview_image_cmd=array();
foreach($sensors as $i => $sensor){
if ($sensor!="none"){
$sensor_type = $sensor;
......@@ -131,15 +131,24 @@
$sandp = "http://{$_SERVER["SERVER_ADDR"]}:".($port0+$i);
$href1 = "$sandp/bimg";
$href2 = "$sandp/mimg";
$href3 = "$sandp/tiff_palette=2/tiff_telem=1/tiff_auto=33/tiff_convert/bimg";
if ($sensor_type == 'boson640'){
$preview_image_cmd[] = '/tiff_palette=2/tiff_telem=1/tiff_auto=33/tiff_convert/bimg';
} else {
$preview_image_cmd[] = 'img';
}
$table_contents .= "<td valign='top'>";
$table_contents .= "<div class='port_window img_window'>";
//$table_contents .= "<div><a href=\"$href1\"><img class='img_window' src='$href1' style='width:300px'/></a></div>";
$table_contents .= "<div><a href=\"$href1\"><div index='$i' class='port_preview'></div></a></div>";
if ($sensor_type == boson640){
$table_contents .= "<div><a href=\"$href3\"><div index='$i' class='port_preview'></div></a></div>";
} else {
$table_contents .= "<div><a href=\"$href1\"><div index='$i' class='port_preview'></div></a></div>";
}
$table_contents .= "<div style='text-align:center;'>";
$table_contents .= "port $i: ";
$table_contents .= "port $i: (".$sensor_type.")";
$table_contents .= "<a title='single image' href='$href1'>bimg</a>, ";
$table_contents .= "<a href=\"img.html?port=$i\" title='single image, auto refreshed on load, LOW RES, displays jpeg, tiff and jp4 formats'>img</a>, ";
$table_contents .= "<a href=\"img.html?port=$i&amp;sensor_type=$sensor_type\" title='single image, auto refreshed on load, LOW RES, displays jpeg, tiff and jp4 formats'>img</a>, ";
$table_contents .= "<a title='multi-part image stream (M-JPEG). Played in browser as is.' href='$href2'>mimg</a>, ";
$table_contents .= "<a href=\"mjpeg.html?port=$i\" title='MJPEG stream played in html canvas' class='canvas_mjpeg'>canvas</a>";
$table_contents .= "</div>";
......@@ -281,9 +290,9 @@
index = parseInt($(this).attr("index"));
if (jp4_previews_enable) {
//jp4_previews[index] = $(this).jp4({ip:location.host,port:2323+index,width:300,fast:true,lowres:4});
jp4_previews[index] = $(this).jp4({src:"http://"+location.host+":"+(2323+index)+"/img",width:300,fast:true,lowres:4});
jp4_previews[index] = $(this).jp4({src:"http://"+location.host+":"+(2323+index)+"<?php echo $preview_image_cmd[0];?>",width:300,fast:true,lowres:4});
}else{
$(this).html("<img width='300' src='http://"+location.host+":"+(2323+index)+"/img' />");
$(this).html("<img width='300' src='http://"+location.host+":"+(2323+index)+"<?php echo $preview_image_cmd[0];?>' />");
}
});
}
......
......@@ -8,9 +8,12 @@ CONFDIR = $(SYSCONFDIR)/elphel393
INSTALL = install
DOCS= index.html
DOCS= index.html \
test_goggles.html \
test_rc.html
PHP_SCRIPTS_EXE=lwir16.php \
dualsock.php \
test_int.php \
test_wpipe.php \
test_ps.php
......
#!/usr/bin/php
<?php
/*!*******************************************************************************
*! FILE NAME : dualsock.php
*! DESCRIPTION: Skeleton websockets server to connect to 2 smartphones -
*! 1 for stereo goggles, anothe as a hand-held RC
*! Copyright (C) 2021 Elphel, Inc
*! -----------------------------------------------------------------------------**
*!
*! 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/>.
*! -----------------------------------------------------------------------------**
*!
*/
// print_r($argv);
set_include_path ( get_include_path () . PATH_SEPARATOR . '/www/pages/include' );
include 'show_source_include.php';
include 'elphel_functions_include.php'; // includes curl functions
define('SOCK_GOGGLES_FILE', '/tmp/wstunnel-nobin.socket'); // defined in /etc/lighttpd.conf ws://<ip>:80/ws-nobin/"
define('SOCK_REMOTE_CONTROL_FILE', '/tmp/wstunnel-nobin1.socket'); // defined in /etc/lighttpd.conf ws://<ip>:80/ws-nobin1/"
define('SOCK_GOGGLES', 'SOCK_GOGGLES');
define('SOCK_REMOTE_CONTROL', 'SOCK_REMOTE_CONTROL');
define('LOGFILE', '/tmp/dualsock.log');
set_time_limit(0); // no limit - run forever
logmsg('Staring dualsock.php');
if(file_exists(SOCK_GOGGLES_FILE)) unlink(SOCK_GOGGLES_FILE); //delete socket if it was already there
if(file_exists(SOCK_REMOTE_CONTROL_FILE)) unlink(SOCK_REMOTE_CONTROL_FILE); //delete socket if it was already there
init();
$GLOBALS[SOCK_GOGGLES] = socket_create(AF_UNIX, SOCK_STREAM, 0);
$GLOBALS[SOCK_REMOTE_CONTROL] = socket_create(AF_UNIX, SOCK_STREAM, 0);
socket_bind($GLOBALS[SOCK_GOGGLES], SOCK_GOGGLES_FILE); // bind new socket with filesystem path
socket_bind($GLOBALS[SOCK_REMOTE_CONTROL], SOCK_REMOTE_CONTROL_FILE);
socket_set_block($GLOBALS[SOCK_GOGGLES]); // will wait for data available /ready to accept
socket_set_block($GLOBALS[SOCK_REMOTE_CONTROL]); // will wait for data available /ready to accept
socket_listen($GLOBALS[SOCK_GOGGLES]); // will listen to the socket for incoming data
socket_listen($GLOBALS[SOCK_REMOTE_CONTROL]); // will listen to the socket for incoming data
// Warning: socket_write(): unable to write to socket [32]: Broken pipe in /www/pages/lwir16/dualsock.php on line 103
// Main loop
while (1) {
$read = array(
$GLOBALS[SOCK_GOGGLES],
$GLOBALS[SOCK_REMOTE_CONTROL]
);
$write = NULL;
$except = NULL;
$select_timeout_sec = 5; // will be used for housekeeping actions, needed if there are no incoming commands
$select_timeout_usec = 0; // when need faster than number of seconds
$num_changed_sockets = socket_select(
$read, // will modify array to have only ready connections
$write,
$except,
$select_timeout_sec,
$select_timeout_usec
); // wait
if ($num_changed_sockets === false) {
/* Error handling */
logmsg ("Error: socket_select returned false!");
sleep (1);
continue;
} else if ($num_changed_sockets > 0) {
/* At least at one of the sockets something interesting happened */
$active_connections = array();
if (in_array($GLOBALS[SOCK_GOGGLES], $read)) {
$active_connections[SOCK_GOGGLES] = socket_accept($GLOBALS[SOCK_GOGGLES]);
}
if (in_array($GLOBALS[SOCK_REMOTE_CONTROL], $read)) {
$active_connections[SOCK_REMOTE_CONTROL] = socket_accept($GLOBALS[SOCK_REMOTE_CONTROL]);
}
// now $active_connections contain one or two temporary sockets, to read command through and respond, if empty - close
foreach ($active_connections as $name=>$conn) {
logmsg("Processing connection $name");
processConnection($conn, $name);
}
} else { // do housekeeping functions
logmsg ("No incoming commands - do housekeeping routines");
}
} // end of while (1) -main loop
function processConnection($conn, $name){
// Just read lines and respond with the name to each until read empty string
while (1) {
$sr = socket_read($conn, 1000);
logmsg($name." -> ".$sr." (".strlen($sr)." bytes)");
if (!$sr){
break; // happens when timeout and websocket is closed (or page refreshed)
}
if (strlen($sr) < 2){
break;
}
$sw = socket_write($conn, $name.", got ".$sr." from you");
}
socket_close($conn);
logmsg($name." closed");
}
function logmsg($msg){
file_put_contents(LOGFILE, time().': '.$msg."\n", FILE_APPEND);
}
function init(){
// Add all required initialization before establishing connection to the clients
}
?>
......@@ -358,7 +358,7 @@ EOT;
// TODO: use lwir16.ini
$eo_quality = 97;
$exposure = 1000; // 1 ms
$autoExposureMax = 500000;
$autoExposureMax = 25000; // 500000; ~28ms - max for 10Hz
$autoExp = 1;
$gain = 2 * 0x10000;
$rScale = 1 * 0x10000;
......
<!DOCTYPE html>
<meta charset="utf-8"/>
<!-- modified from example in https://github.com/joewalnes/websocketd README.md -->
<pre id="log"></pre>
<script>
// helper function: log message to screen
var logelt = document.getElementById('log');
function log(msg) { logelt.textContent += msg + '\n'; }
// helper function: send websocket msg with count (1 .. 5)
var host = location.hostname;
log('SERVER: '+host);
var ll = 0;
function send_msg() {
if (++ll <= 5) {
log('SEND: '+ll);
ws.send(ll+'\n');
} else if (ll <=6){
ws.send('\n');
log('SEND: '+ll);
}
console.log("ll="+ll);
}
// setup websocket with callbacks
var ws = new WebSocket('ws://'+host+':80/ws-nobin/');
ws.onopen = function() { log('CONNECT\n'); send_msg(); };
ws.onclose = function() { log('DISCONNECT'); };
ws.onmessage = function(event) { log('RECV: ' + event.data); send_msg(); };
</script>
<!DOCTYPE html>
<meta charset="utf-8"/>
<!-- modified from example in https://github.com/joewalnes/websocketd README.md -->
<pre id="log"></pre>
<script>
// helper function: log message to screen
var logelt = document.getElementById('log');
function log(msg) { logelt.textContent += msg + '\n'; }
// helper function: send websocket msg with count (1 .. 5)
var host = location.hostname;
log('SERVER: '+host);
var ll = 0;
function send_msg() {
if (++ll <= 5) {
log('SEND: '+ll);
ws.send(ll+'\n');
} else if (ll <=6){
ws.send('\n');
log('SEND: '+ll);
}
console.log("ll="+ll);
}
// setup websocket with callbacks
var ws = new WebSocket('ws://'+host+':80/ws-nobin1/');
ws.onopen = function() { log('CONNECT\n'); send_msg(); };
ws.onclose = function() { log('DISCONNECT'); };
ws.onmessage = function(event) { log('RECV: ' + event.data); send_msg(); };
</script>
......@@ -4,6 +4,7 @@ OWN = -o root -g root
INSTDOCS = 0644
INSTALL = install
DOCS= index.html \
index1.html \
multicam.js \
multicam.css \
multicam.php
......
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title>Multi cameras control</title>
<script src="../js/jquery-3.1.1.js"></script>
<script src="../js/elphel.js"></script>
<script src="../js/jcanvas.js"></script>
<script src="../js/UTIF.js"></script>
<script src="../js/exif.js"></script>
<script src="../js/jquery-jp4.js"></script>
<script src="../js/zip/zip.js"></script>
<link rel="stylesheet" href="../js/bootstrap/css/bootstrap.css">
<script type='text/javascript' src='multicam.js'></script>
<link rel='stylesheet' type='text/css' href='multicam.css'></link>
</head>
<!-- 192.168.0.41/multicam/index1.html?ip=192.168.0.41,192.168.0.42,192.168.0.43,192.168.0.44,192.168.0.45 -->
<body>
<div id='settings'>
<table>
<tr>
<td>
<div id='rec_button' class='rec_outer' title='start recording'>
<div class='rec_inner'></div>
</div>
</td>
<td>
<button id='snapshot' title='download snapshot' class="btn btn-sm btn-danger">snapshot</button>
</td>
</tr>
<tr id="toggle_awb" title='Auto White Balance'>
<td>Auto WB:</td>
<td>
<div id="toggle_awb" class="btn-group btn-toggle">
<button class="btn btn-xs btn-success active">ON</button>
<button class="btn btn-xs btn-default">OFF</button>
</div>
</td>
</tr>
<tr id="toggle_aexp" title='Auto Exposure'>
<td>Auto Exposure:</td>
<td>
<div id="toggle_aexp" class="btn-group btn-toggle">
<button class="btn btn-xs btn-success active">ON</button>
<button class="btn btn-xs btn-default">OFF</button>
</div>
</td>
</tr>
<tr>
<td>
<button id='system_tests' title='system info' class="btn btn-sm btn-success">tests</button>
</td>
</tr>
<tr>
<td hidden>
<br/>
<div id='edit_addrs_input' hidden>
<div id='eai_text_div'>
<textarea id='eai_text' rows='4' cols='30'></textarea>
</div>
<div id='eai_ok_div'>
<button id='eai_ok' class="btn btn-sm btn-success">ok</button>
</div>
</div>
<div id='edit_addrs' title='edit ip addresses'>
<button id='ea_btn' class="btn btn-sm btn-success">+</button>
</div>
<div id='addrs'>
</div>
</td>
</tr>
</table>
</div>
<div id='display'>
<div id='display_status'></div>
<hr/>
<div id='display_previews'></div>
</div>
</body>
</html>
\ No newline at end of file
......@@ -352,6 +352,19 @@ function init_port(cam_i,port_i){
}
});
var url = "http://"+cams[cam_i].ip+"/parsedit.php?immediate&sensor_port="+cams[cam_i].ports[port_i].index+"&BITS";
$.ajax({
url: url,
cam_i: cam_i,
port_i: port_i,
success: function(res){
bits = parseInt($(res).find("BITS").text());
cams[this.cam_i].ports[this.port_i].bits = bits;
}
});
}
// * if any attribute is not initialized it will be NaN
......@@ -477,6 +490,7 @@ function refresh_previews(){
if (cams[i].init){
for(var j=0;j<cams[i].ports.length;j++){
var cam = cams[i];
var is_lwir = cam.ports[j].bits > 8;
//var img_src = 'http://'+cam.ip+':'+cam.ports[j].port+'/img?'+ts;
var hst_src = 'http://'+cam.ip+'/pnghist.cgi?sensor_port='+cam.ports[j].index+'&sqrt=1&scale=5&average=5&height=128&fillz=1&linterpz=0&draw=2&colors=41&_time='+ts;
......@@ -486,10 +500,15 @@ function refresh_previews(){
if (!cam.ports[j].preview){
//console.log("preview does not exist");
var jp4prev = elem.find(".port_preview[index="+j+"]");
var imgsrv_img = "/img";
if (is_lwir){
imgsrv_img = "/tiff_palette=2/tiff_telem=1/tiff_auto=33/tiff_convert/bimg";
}
var preview = jp4prev.jp4({
//ip: cam.ip,
//port: cam.ports[j].port,
src: "http://"+cam.ip+":"+cam.ports[j].port+"/img",
// src: "http://"+cam.ip+":"+cam.ports[j].port+"/img",
src: "http://"+cam.ip+":"+cam.ports[j].port+imgsrv_img,
width: 200,
fast: true,
lowres:4,
......@@ -503,11 +522,10 @@ function refresh_previews(){
cam.ports[j].preview.data.refresh();
}
//console.log(jp4prev.data.getAddr());
elem.find(".hist_preview[index="+j+"]").attr('src',hst_src);
if (!is_lwir) {
elem.find(".hist_preview[index="+j+"]").attr('src',hst_src);
}
}
}
}
......