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
9389820e
Commit
9389820e
authored
Jul 04, 2023
by
Andrey Filippov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more debugging
parent
3ed8b3eb
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
75 additions
and
14 deletions
+75
-14
lwir16.php
src/lwir16/lwir16.php
+60
-8
Makefile
src/php_top/Makefile
+0
-1
capture_range.php
src/php_top/capture_range.php
+15
-5
No files found.
src/lwir16/lwir16.php
View file @
9389820e
...
@@ -270,7 +270,7 @@
...
@@ -270,7 +270,7 @@
printf
(
$rslt
);
printf
(
$rslt
);
exit
(
0
);
exit
(
0
);
}
else
if
(
$cmd
==
'capture'
){
}
else
if
(
$cmd
==
'capture'
){
$results
=
runCapture
(
$GLOBALS
[
FFC
],
$nowait
);
// runCapture($run_ffc, $nowait = 0, $debug=0) // single-run?
$results
=
runCapture
(
$GLOBALS
[
FFC
],
$nowait
,
true
,
$GLOBALS
[
DEBUG
]
);
// runCapture($run_ffc, $nowait = 0, $debug=0) // single-run?
$xml
=
new
SimpleXMLElement
(
"<?xml version='1.0' standalone='yes'?><capture_range/>"
);
$xml
=
new
SimpleXMLElement
(
"<?xml version='1.0' standalone='yes'?><capture_range/>"
);
$xml
->
addChild
(
'ffc'
,
$GLOBALS
[
FFC
]);
$xml
->
addChild
(
'ffc'
,
$GLOBALS
[
FFC
]);
$xml
->
addChild
(
FFC_GROUPS
,
$GLOBALS
[
FFC_GROUPS
]);
$xml
->
addChild
(
FFC_GROUPS
,
$GLOBALS
[
FFC_GROUPS
]);
...
@@ -533,7 +533,7 @@ EOT;
...
@@ -533,7 +533,7 @@ EOT;
return
$results
;
return
$results
;
}
}
function
runCapture
(
$run_ffc
,
$nowait
=
0
,
$debug
=
0
)
{
// works, but the main script hangs
function
runCapture
(
$run_ffc
,
$nowait
=
0
,
$
first_run
=
0
,
$
debug
=
0
)
{
// works, but the main script hangs
// TODO: use lwir16.ini
// TODO: use lwir16.ini
// $eo_quality = 97;
// $eo_quality = 97;
// $exposure = 1000; // 1 ms
// $exposure = 1000; // 1 ms
...
@@ -581,7 +581,7 @@ EOT;
...
@@ -581,7 +581,7 @@ EOT;
}
}
// $timestamp = $this_timestamp + $GLOBALS[PRE_DELAY]; // this will be a delay between capture sequences (default - 3s)
// $timestamp = $this_timestamp + $GLOBALS[PRE_DELAY]; // this will be a delay between capture sequences (default - 3s)
$urls
=
array
();
$urls
=
array
();
for
(
$i
=
0
;
$i
<
count
(
$GLOBALS
[
IPS
]);
$i
++
)
{
for
(
$i
=
0
;
$i
<
count
(
$GLOBALS
[
IPS
]);
$i
++
)
if
(
$GLOBALS
[
RUN_MODES
][
$GLOBALS
[
IPS
][
$i
]]
>
0
){
// 0 - do not use this camera at all
// $_SERVER[SCRIPT_NAME] STARTS WITH '/'
// $_SERVER[SCRIPT_NAME] STARTS WITH '/'
$url
=
'http://'
.
$GLOBALS
[
IPS
][
$i
]
.
'/'
.
SCRIPT_CAPTURE_RANGE
.
'?sensor_port='
.
$sensor_port
;
//
$url
=
'http://'
.
$GLOBALS
[
IPS
][
$i
]
.
'/'
.
SCRIPT_CAPTURE_RANGE
.
'?sensor_port='
.
$sensor_port
;
//
if
(
$GLOBALS
[
I_AM_MASTER
])
{
if
(
$GLOBALS
[
I_AM_MASTER
])
{
...
@@ -592,6 +592,16 @@ EOT;
...
@@ -592,6 +592,16 @@ EOT;
// $url .= '&port_mask=15'; // .$port_mask[$i];
// $url .= '&port_mask=15'; // .$port_mask[$i];
$url
.=
'&port_mask='
.
$GLOBALS
[
PORT_MASKS
][
$GLOBALS
[
IPS
][
$i
]];
//indexed by IPs
$url
.=
'&port_mask='
.
$GLOBALS
[
PORT_MASKS
][
$GLOBALS
[
IPS
][
$i
]];
//indexed by IPs
$dur
=
(
$i
<
4
)
?
$GLOBALS
[
DURATION
]
:
$GLOBALS
[
DURATION_EO
];
// maybe turn on EO forever
$dur
=
(
$i
<
4
)
?
$GLOBALS
[
DURATION
]
:
$GLOBALS
[
DURATION_EO
];
// maybe turn on EO forever
if
(
$GLOBALS
[
RUN_MODES
][
$GLOBALS
[
IPS
][
$i
]]
==
2
)
{
// continuous run mode
/*
if ($first_run) {
$dur = -1; // start only, no stop
} else {
continue; // nothing to do for this camera, it is supposed to already be running. Or just enable compressor anyway?
}
*/
$dur
=
-
1
;
// start only, no stop
}
$url
.=
'&duration='
.
$dur
;
$url
.=
'&duration='
.
$dur
;
// $url .= '&maxahead='. $maxahead;
// $url .= '&maxahead='. $maxahead;
// $url .= '&minahead='. $minahead;
// $url .= '&minahead='. $minahead;
...
@@ -724,6 +734,7 @@ EOT;
...
@@ -724,6 +734,7 @@ EOT;
}
}
$left_frames
=
0
;
$left_frames
=
0
;
$abort_sequence
=
0
;
$abort_sequence
=
0
;
$need_service
=
0
;
// set by commands START, STOP, ABORT, reset when served
// exit(0);
// exit(0);
$from_pipe
=
false
;
// first commands are form INI
$from_pipe
=
false
;
// first commands are form INI
while
(
$GLOBALS
[
DAEMON_RUN
]){
while
(
$GLOBALS
[
DAEMON_RUN
]){
...
@@ -747,13 +758,16 @@ EOT;
...
@@ -747,13 +758,16 @@ EOT;
$GLOBALS
[
CAPTURE_RUN
]
=
1
;
$GLOBALS
[
CAPTURE_RUN
]
=
1
;
$GLOBALS
[
CAPTURE_WAIT
]
=
0
;
$GLOBALS
[
CAPTURE_WAIT
]
=
0
;
$left_frames
=
0
;
$left_frames
=
0
;
$need_service
=
1
;
}
else
if
(
$cmd
==
CMD_STOP
){
}
else
if
(
$cmd
==
CMD_STOP
){
$GLOBALS
[
CAPTURE_RUN
]
=
0
;
// should continue waiting
$GLOBALS
[
CAPTURE_RUN
]
=
0
;
// should continue waiting
$abort_sequence
=
0
;
$abort_sequence
=
0
;
$need_service
=
1
;
}
else
if
(
$cmd
==
CMD_ABORT
){
}
else
if
(
$cmd
==
CMD_ABORT
){
$GLOBALS
[
CAPTURE_RUN
]
=
0
;
// should continue waiting
$GLOBALS
[
CAPTURE_RUN
]
=
0
;
// should continue waiting
$abort_sequence
=
1
;
$abort_sequence
=
1
;
}
else
if
(
$cmd
==
CMD_CONTINUE
){
// $need_service = 1;
}
else
if
(
$cmd
==
CMD_CONTINUE
){
// not used, designed for notification from capture_range.php
$GLOBALS
[
CAPTURE_WAIT
]
=
0
;
$GLOBALS
[
CAPTURE_WAIT
]
=
0
;
$left_frames
=
0
;
$left_frames
=
0
;
}
else
if
(
$from_pipe
&&
(
$cmd
==
CMD_STATUS
)){
// generate status data and send over response pipe
}
else
if
(
$from_pipe
&&
(
$cmd
==
CMD_STATUS
)){
// generate status data and send over response pipe
...
@@ -867,8 +881,10 @@ EOT;
...
@@ -867,8 +881,10 @@ EOT;
$GLOBALS
[
CAPTURE_WAIT
]
=
0
;
$GLOBALS
[
CAPTURE_WAIT
]
=
0
;
}
}
if
(
$abort_sequence
&&
$GLOBALS
[
CAPTURE_WAIT
])
{
// still not stopped
if
(
$abort_sequence
&&
$GLOBALS
[
CAPTURE_WAIT
])
{
// still not stopped
$sensor_port
=
0
;
$urls
=
array
();
$urls
=
array
();
for
(
$i
=
0
;
$i
<
count
(
$GLOBALS
[
IPS
]);
$i
++
){
// stop all started cameras, including started-only, but not inactive. TODO - add inactive to skip initialization?
for
(
$i
=
0
;
$i
<
count
(
$GLOBALS
[
IPS
]);
$i
++
)
if
(
$GLOBALS
[
RUN_MODES
][
$GLOBALS
[
IPS
][
$i
]]
>
0
){
// 0 - do not use this camera at all
// $_SERVER[SCRIPT_NAME] STARTS WITH '/'
// $_SERVER[SCRIPT_NAME] STARTS WITH '/'
$url
=
'http://'
.
$GLOBALS
[
IPS
][
$i
]
.
'/'
.
SCRIPT_CAPTURE_RANGE
.
'?sensor_port='
.
$sensor_port
;
//
$url
=
'http://'
.
$GLOBALS
[
IPS
][
$i
]
.
'/'
.
SCRIPT_CAPTURE_RANGE
.
'?sensor_port='
.
$sensor_port
;
//
$url
.=
'&port_mask='
.
$GLOBALS
[
PORT_MASKS
][
$GLOBALS
[
IPS
][
$i
]];
//indexed by IPs
$url
.=
'&port_mask='
.
$GLOBALS
[
PORT_MASKS
][
$GLOBALS
[
IPS
][
$i
]];
//indexed by IPs
...
@@ -884,14 +900,16 @@ EOT;
...
@@ -884,14 +900,16 @@ EOT;
$enable_echo
=
false
;
$enable_echo
=
false
;
$results
=
curl_multi_finish
(
$curl_data
,
true
,
0
,
$enable_echo
);
// Switch true -> false if errors are reported (other output damaged XML)
$results
=
curl_multi_finish
(
$curl_data
,
true
,
0
,
$enable_echo
);
// Switch true -> false if errors are reported (other output damaged XML)
if
(
$GLOBALS
[
DEBUG
]
>
0
){
if
(
$GLOBALS
[
DEBUG
]
>
0
){
printf
(
"---
capture_run
: ---
\n
"
);
printf
(
"---
aborting runCapture result
: ---
\n
"
);
print_r
(
$result
);
print_r
(
$result
);
}
}
}
}
/// if (($left_frames > 0) && !$abort_sequence){
if
(
$left_frames
>
0
)
{
if
(
$left_frames
>
0
)
{
// skip some frames as there is nothing to do
// skip some frames as there is nothing to do
$rslt
=
skipFrames
(
array
(
$GLOBALS
[
IPS
][
0
]),
$GLOBALS
[
FRAMES_IDLE
]);
// just master camera IP
$rslt
=
skipFrames
(
array
(
$GLOBALS
[
IPS
][
0
]),
$GLOBALS
[
FRAMES_IDLE
]);
// just master camera IP
}
}
$abort_sequence
=
0
;
}
else
if
(
$GLOBALS
[
CAPTURE_RUN
]){
// run next cycle
}
else
if
(
$GLOBALS
[
CAPTURE_RUN
]){
// run next cycle
$ffc_due
=
$GLOBALS
[
LAST_FFC
]
+
$GLOBALS
[
FFC_PERIOD
];
$ffc_due
=
$GLOBALS
[
LAST_FFC
]
+
$GLOBALS
[
FFC_PERIOD
];
...
@@ -902,7 +920,8 @@ EOT;
...
@@ -902,7 +920,8 @@ EOT;
$GLOBALS
[
LAST_FFC
]
=
$now
;
$GLOBALS
[
LAST_FFC
]
=
$now
;
}
}
// $result = runCapture($run_ffc, false, $GLOBALS[$GLOBALS[DEBUG]]);
// $result = runCapture($run_ffc, false, $GLOBALS[$GLOBALS[DEBUG]]);
$result
=
runCapture
(
$run_ffc
,
false
,
$GLOBALS
[
DEBUG
]);
$result
=
runCapture
(
$run_ffc
,
false
,
$need_service
,
$GLOBALS
[
DEBUG
]);
$need_service
=
0
;
$GLOBALS
[
SEQUENCE_NUM
]
++
;
$GLOBALS
[
SEQUENCE_NUM
]
++
;
if
(
$GLOBALS
[
DEBUG
]
>
0
){
if
(
$GLOBALS
[
DEBUG
]
>
0
){
printf
(
"--- capture_run: ---
\n
"
);
printf
(
"--- capture_run: ---
\n
"
);
...
@@ -910,6 +929,39 @@ EOT;
...
@@ -910,6 +929,39 @@ EOT;
}
}
$GLOBALS
[
CAPTURE_WAIT
]
=
1
;
$GLOBALS
[
CAPTURE_WAIT
]
=
1
;
}
else
{
}
else
{
if
(
$GLOBALS
[
DEBUG
]
>
0
){
printf
(
"--- idle: need_service=
$need_service
: ---
\n
"
);
}
if
(
$need_service
)
{
// need to stop those that were continuously running. FIXME: now will not wor if all are continuously running
$sensor_port
=
0
;
$urls
=
array
();
// stop all continuously run cameras, but not inactive. TODO - add inactive to skip initialization?
for
(
$i
=
0
;
$i
<
count
(
$GLOBALS
[
IPS
]);
$i
++
)
if
(
$GLOBALS
[
RUN_MODES
][
$GLOBALS
[
IPS
][
$i
]]
==
2
)
{
// only continuously running
// $_SERVER[SCRIPT_NAME] STARTS WITH '/'
$url
=
'http://'
.
$GLOBALS
[
IPS
][
$i
]
.
'/'
.
SCRIPT_CAPTURE_RANGE
.
'?sensor_port='
.
$sensor_port
;
//
$url
.=
'&port_mask='
.
$GLOBALS
[
PORT_MASKS
][
$GLOBALS
[
IPS
][
$i
]];
//indexed by IPs
$url
.=
'&frame=0&duration=0'
;
// immediately stop compressors, do not use daemon
$urls
[]
=
$url
;
}
if
(
$GLOBALS
[
DEBUG
]
>
0
){
printf
(
"--- stopping continuously running cameras: URLs:
\n
"
);
print_r
(
$urls
);
}
if
(
count
(
$urls
)
>
0
)
{
$curl_data
=
curl_multi_start
(
$urls
);
$enable_echo
=
false
;
$results
=
curl_multi_finish
(
$curl_data
,
true
,
0
,
$enable_echo
);
// Switch true -> false if errors are reported (other output damaged XML)
if
(
$GLOBALS
[
DEBUG
]
>
0
){
printf
(
"--- capture_stop_continuously_running: ---
\n
"
);
print_r
(
$result
);
}
}
else
{
if
(
$GLOBALS
[
DEBUG
]
>
0
){
printf
(
"--- No continuously runnong cameras to stop ---
\n
"
);
}
}
$need_service
=
0
;
}
// skip some frames as there is nothing to do
// skip some frames as there is nothing to do
$rslt
=
skipFrames
(
array
(
$GLOBALS
[
IPS
][
0
]),
$GLOBALS
[
FRAMES_IDLE
]);
// just master camera IP
$rslt
=
skipFrames
(
array
(
$GLOBALS
[
IPS
][
0
]),
$GLOBALS
[
FRAMES_IDLE
]);
// just master camera IP
}
}
...
...
src/php_top/Makefile
View file @
9389820e
...
@@ -16,7 +16,6 @@ PHP_SCRIPTS=i2c.php \
...
@@ -16,7 +16,6 @@ PHP_SCRIPTS=i2c.php \
ccam.php
\
ccam.php
\
diag_utils.php
\
diag_utils.php
\
framepars.php
\
framepars.php
\
frame_to_ts.php
\
parsedit.php
\
parsedit.php
\
phpinfo.php
\
phpinfo.php
\
raw.php
\
raw.php
\
...
...
src/php_top/capture_range.php
View file @
9389820e
...
@@ -52,6 +52,13 @@
...
@@ -52,6 +52,13 @@
// $f = fopen ( "/var/log/capture_range.log", 'a' );
// $f = fopen ( "/var/log/capture_range.log", 'a' );
// fwrite($f,"elphel_capture_range($sensor_port, $port_mask, $frame, $duration);\n");
// fwrite($f,"elphel_capture_range($sensor_port, $port_mask, $frame, $duration);\n");
// fclose ( $f );
// fclose ( $f );
/**
* Program multiple channels (according to 'port_mask') to start compressor at absolute (or relative) 'frame', run it for 'duration' frames
* and then stop. If 'duration'==0 - just stop compressor, if 'duration' <0 - only start.
* This function is intended to be executed in a background process (such as in capture_range.php) not to hold http client
* BUG: frame number after stop is 2 less than expected (ahead applied in wrong place?)
*/
elphel_capture_range
(
$sensor_port
,
$port_mask
,
$frame
,
$duration
);
elphel_capture_range
(
$sensor_port
,
$port_mask
,
$frame
,
$duration
);
// $f = fopen ( "/var/log/capture_range.log", 'a' );
// $f = fopen ( "/var/log/capture_range.log", 'a' );
// fwrite($f,"elphel_capture_range DONE\n");
// fwrite($f,"elphel_capture_range DONE\n");
...
@@ -211,7 +218,7 @@ USAGE;
...
@@ -211,7 +218,7 @@ USAGE;
$duration
=
(
integer
)
$duration_list
;
// single valude
$duration
=
(
integer
)
$duration_list
;
// single valude
}
}
// convert provided timestamp to
even
number of frame timestamp
// convert provided timestamp to
integer
number of frame timestamp
if
((
$frame
!=
0
)
||
(
$timestamp
!=
0.0
))
{
if
((
$frame
!=
0
)
||
(
$timestamp
!=
0.0
))
{
if
((
$frame
<=
0
)
&&
(
$timestamp
>
0.0
)){
if
((
$frame
<=
0
)
&&
(
$timestamp
>
0.0
)){
$frame
=
elphel_ts2frame
(
$sensor_port
,
$timestamp
);
$frame
=
elphel_ts2frame
(
$sensor_port
,
$timestamp
);
...
@@ -263,7 +270,7 @@ USAGE;
...
@@ -263,7 +270,7 @@ USAGE;
if
(
isset
(
$port_mask
))
{
// start or stop compressor
if
(
isset
(
$port_mask
))
{
// start or stop compressor
$this_frame
=
elphel_get_frame
(
$sensor_port
);
$this_frame
=
elphel_get_frame
(
$sensor_port
);
if
(
!
$use_daemon
)
{
// e.g. to stop ASAP $frame=0, $duration !=0 - start ASAP
if
(
!
$use_daemon
)
{
// e.g. to stop ASAP $frame=0, $duration !=0 - start ASAP
if
(
isset
(
$duration
)
)
{
if
(
$duration
<
0
)
{
elphel_compressor_run
(
$sensor_port
,
0
,
$flags
,
$port_mask
);
// turn on ASAP
elphel_compressor_run
(
$sensor_port
,
0
,
$flags
,
$port_mask
);
// turn on ASAP
$xml
->
addChild
(
'compressor'
,
1
);
$xml
->
addChild
(
'compressor'
,
1
);
}
else
{
// frame = 0; duration ==0 - stop ASAP
}
else
{
// frame = 0; duration ==0 - stop ASAP
...
@@ -271,12 +278,12 @@ USAGE;
...
@@ -271,12 +278,12 @@ USAGE;
$xml
->
addChild
(
'compressor'
,
0
);
$xml
->
addChild
(
'compressor'
,
0
);
}
}
$frame
=
$this_frame
+
$minahead
;
$frame
=
$this_frame
+
$minahead
;
}
}
$ahead
=
$frame
-
$this_frame
;
$ahead
=
$frame
-
$this_frame
;
if
(
$use_daemon
&&
(
$ahead
<
$minahead
))
{
if
(
$use_daemon
&&
(
$ahead
<
$minahead
)
&&
(
!
isset
(
$ahead_now
))
)
{
$xml
->
addChild
(
'error'
,
'TOO LATE'
);
$xml
->
addChild
(
'error'
,
'TOO LATE'
);
$xml
->
addChild
(
'ahead'
,
$ahead
);
$xml
->
addChild
(
'ahead'
,
$ahead
);
}
else
{
// OK, enough time to program
}
else
{
// OK, enough time to program
or no-daemon mode, or ASAP
if
(
!
isset
(
$duration
))
{
if
(
!
isset
(
$duration
))
{
$duration
=
0
;
$duration
=
0
;
}
}
...
@@ -290,6 +297,9 @@ USAGE;
...
@@ -290,6 +297,9 @@ USAGE;
// $xml->addChild ('notify_url', $notify_url); // urlencode($notify_url)); // dry run, do nothing
// $xml->addChild ('notify_url', $notify_url); // urlencode($notify_url)); // dry run, do nothing
// } else {
// } else {
if
(
$use_daemon
)
{
if
(
$use_daemon
)
{
if
(
isset
(
$ahead_now
)
&&
(
$ahead_now
==
0
)){
$frame
=
0
;
// ASAP
}
exec
(
"/www/pages/capture_range.php
$sensor_port
$port_mask
$frame
$duration
'
$notify_url
'> /dev/null 2>&1 &"
);
exec
(
"/www/pages/capture_range.php
$sensor_port
$port_mask
$frame
$duration
'
$notify_url
'> /dev/null 2>&1 &"
);
// }
// }
// $f = fopen ( "/var/log/capture_range.log", 'a' );
// $f = fopen ( "/var/log/capture_range.log", 'a' );
...
...
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