Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
elphel-apps-autocampars
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-apps-autocampars
Commits
1a7baa9c
Commit
1a7baa9c
authored
Jan 22, 2021
by
Andrey Filippov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adding boson
parent
31d99405
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
111 additions
and
11 deletions
+111
-11
autocampars.php
src/autocampars.php
+101
-1
autocampars.py
src/autocampars.py
+10
-10
No files found.
src/autocampars.php
View file @
1a7baa9c
...
...
@@ -768,7 +768,25 @@ function detect_camera(){
// sensor's code from c313a.h
$sensor_code
=
68
;
// TODO: ************** Import as PHP constant? ***********
}
else
if
(
$GLOBALS
[
'camera_state_arr'
][
'is_boson640'
]){
// 2018/02/09: TODO: test
log_msg
(
"Initializing FPGA for Boson640 iface"
,
3
);
unset
(
$output
);
// /usr/local/verilog/hargs-hispi - does not exist yet
exec
(
'autocampars.py localhost py393 hargs-boson'
,
$output
,
$retval
);
$GLOBALS
[
'camera_state_arr'
][
'state'
]
=
'BITSTREAM'
;
write_php_ini
(
$GLOBALS
[
'camera_state_arr'
],
$GLOBALS
[
'camera_state_path'
]
);
foreach
(
$output
as
$k
=>
$v
){
$output
[
$k
]
=
str_replace
(
'\n'
,
"
\n
"
,
$v
);
}
log_msg
(
"COMMAND_OUTPUT for 'autocampars.py localhost py393 hargs-boson':
\n
"
.
print_r
(
$output
,
1
)
.
"
\n
command return value="
.
$retval
.
"
\n
"
);
// sensor's code from c313a.h
$sensor_code
=
0x48
;
// TODO: ************** Import as PHP constant? ***********
}
else
{
respond_xml
(
''
,
'Do not know how to initialize master camera '
.
print_r
(
$GLOBALS
[
'camera_state_arr'
][
'is_mt9p006'
],
1
)
...
...
@@ -956,6 +974,74 @@ function detect_camera(){
if
(
$GLOBALS
[
'STOP_AFTER'
][
$GLOBALS
[
'camera_state_arr'
][
'state'
]])
break
;
// will break anyway
break
;
}
if
(
$GLOBALS
[
'camera_state_arr'
][
'is_boson640'
]){
log_msg
(
'Temporary Lepton 3.5 code'
);
foreach
(
$GLOBALS
[
'ports'
]
as
$port
)
{
if
(
$port
==
$GLOBALS
[
'master_port'
]){
elphel_set_P_value
(
$port
,
ELPHEL_TRIG_MASTER
,
$GLOBALS
[
'master_port'
],
ELPHEL_CONST_FRAME_IMMED
);
elphel_set_P_value
(
$port
,
ELPHEL_TRIG_PERIOD
,
0
,
ELPHEL_CONST_FRAME_IMMED
);
elphel_set_P_value
(
$port
,
ELPHEL_TRIG_BITLENGTH
,
0
,
ELPHEL_CONST_FRAME_IMMED
);
elphel_set_P_value
(
$port
,
ELPHEL_EXTERN_TIMESTAMP
,
1
,
ELPHEL_CONST_FRAME_IMMED
);
elphel_set_P_value
(
$port
,
ELPHEL_XMIT_TIMESTAMP
,
1
,
ELPHEL_CONST_FRAME_IMMED
);
elphel_set_P_value
(
$port
,
ELPHEL_TRIG_OUT
,
0x00000
,
ELPHEL_CONST_FRAME_IMMED
);
elphel_set_P_value
(
$port
,
ELPHEL_TRIG_CONDITION
,
0x00000
,
ELPHEL_CONST_FRAME_IMMED
);
}
elphel_set_P_value
(
$port
,
ELPHEL_TRIG_DELAY
,
0
,
ELPHEL_CONST_FRAME_IMMED
);
}
usleep
(
$GLOBALS
[
'camera_state_arr'
][
'max_frame_time'
]);
// > 1 frame, so all channels will get trigger parameters
/*
* Mo snapshot mode in Lepton
foreach ($GLOBALS['ports'] as $port) {
elphel_set_P_value ( $port, ELPHEL_TRIG, ELPHEL_CONST_TRIGMODE_SNAPSHOT, ELPHEL_CONST_FRAME_IMMED);
}
elphel_set_P_value ( $GLOBALS['master_port'], ELPHEL_TRIG_PERIOD, 1, ELPHEL_CONST_FRAME_IMMED, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC);
usleep ($GLOBALS['camera_state_arr']['max_frame_time']);
*/
//Check that now all frame parameters are the same?
// reset sequencers
log_msg
(
"Before reset sequencers:
\n
"
.
trim
(
file_get_contents
(
'/sys/devices/soc0/elphel393-framepars@0/all_frames'
)));
/*
for ($port=0; $port < 4; $port++){
$f = fopen ( $GLOBALS['sysfs_frame_seq'].$port, 'w' ); fwrite($f,'0',1); fclose ( $f );
$f = fopen ( $GLOBALS['sysfs_i2c_seq'].$port, 'w' ); fwrite($f,'3',1); fclose ( $f ); // reset+run (copy frame number from frame_seq)
if (!in_array($port, $GLOBALS['ports'])) {
log_msg("Disabling sensor port ".$port);
$f = fopen ( $GLOBALS['sysfs_chn_en'].$port, 'w' ); fwrite($f,'0',1); fclose ( $f ); // disable sensor channel
}
}
*/
log_msg
(
"After reset sequencers (not reset for Lepton):
\n
"
.
trim
(
file_get_contents
(
'/sys/devices/soc0/elphel393-framepars@0/all_frames'
)));
// ======= First trigger, frame # = 1 ========.
/*
* // no trigger mode in Lepton
elphel_set_P_value ( $GLOBALS['master_port'], ELPHEL_TRIG_PERIOD, 1, ELPHEL_CONST_FRAME_IMMED, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC);
usleep ($GLOBALS['camera_state_arr']['max_frame_time']); // > 1 frame, so all channels will get trigger parameters? // 0 0 0 0 -> 1 1 1 1
log_msg("After single trigger:\n" .trim(file_get_contents('/sys/devices/soc0/elphel393-framepars@0/all_frames')));
//echo "9. frames:\n"; for ($ii=0;$ii<4;$ii++) $frame_nums[$ii]=elphel_get_frame($ii); print_r($frame_nums);
*/
$GLOBALS
[
'camera_state_arr'
][
'state'
]
=
'SENSORS_SYNCHRONIZED'
;
write_php_ini
(
$GLOBALS
[
'camera_state_arr'
],
$GLOBALS
[
'camera_state_path'
]
);
log_msg
(
'Frames: '
.
implode
(
", "
,
$frame_nums
));
log_msg
(
'Reached state: '
.
$GLOBALS
[
'camera_state_arr'
][
'state'
]);
if
(
isset
(
$curl_data
)){
// wait and collect responses
$enable_echo
=
!
array_key_exists
(
'REQUEST_METHOD'
,
$_SERVER
);
if
(
$enable_echo
)
echo
colorize
(
"Waiting slaves to finish (number left): "
,
'YELLOW'
,
0
);
$results
=
curl_multi_finish
(
$curl_data
,
true
,
0
,
$enable_echo
);
// Switch true -> false if errors are reported (other output damaged XML)
if
(
$enable_echo
)
echo
colorize
(
" DONE
\n
"
,
'GREEN'
,
0
);
log_msg
(
'curl_multi returned: '
.
print_r
(
$results
,
1
),
0
);
}
if
(
$GLOBALS
[
'camera_state_arr'
][
'exit_stage'
]
==
$GLOBALS
[
'camera_state_arr'
][
'state'
]){
respond_xml
(
$GLOBALS
[
'camera_state_arr'
][
'state'
]);
}
if
(
$GLOBALS
[
'STOP_AFTER'
][
$GLOBALS
[
'camera_state_arr'
][
'state'
]])
break
;
// will break anyway
break
;
}
...
...
@@ -1637,6 +1723,8 @@ function get_application_mode() {
return
get_eyesis_mode
();
case
'LEPTON35'
:
return
get_lepton35_mode
();
case
'BOSON640'
:
return
get_boson640_mode
();
default
:
respond_xml
(
''
,
'Unknown camera type, '
.
print_r
(
$GLOBALS
[
'camera_state_arr'
],
1
));
...
...
@@ -1717,6 +1805,17 @@ function get_lepton35_mode() {
return
$mode
;
}
function
get_boson640_mode
()
{
$mode
=
get_mt9p006_mode
();
$GLOBALS
[
'camera_state_arr'
][
'is_mt9p006'
]
=
0
;
$GLOBALS
[
'camera_state_arr'
][
'is_boson640'
]
=
1
;
write_php_ini
(
$GLOBALS
[
'camera_state_arr'
],
$GLOBALS
[
'camera_state_path'
]
);
return
$mode
;
}
/**
* Eyesis application modes:
...
...
@@ -2897,7 +2996,8 @@ function curl_multi_finish($data, $use_xml=true, $ntry=0, $echo = false) {
function
createDefaultConfig
(
$version
,
$port
,
$multisensor
=
false
,
$eyesis_mode
=
0
)
{
// / 0 - not eyesis, 1-3 - camera number
$lepton35
=
$GLOBALS
[
'camera_state_arr'
][
'is_lepton35'
];
$SENSOR_RUN
=
ELPHEL_CONST_SENSOR_RUN_CONT
;
// / turn on sensor in continuous mode
$boson640
=
$GLOBALS
[
'camera_state_arr'
][
'is_boson640'
];
$SENSOR_RUN
=
ELPHEL_CONST_SENSOR_RUN_CONT
;
// / turn on sensor in continuous mode
$COMPRESSOR_RUN
=
ELPHEL_CONST_COMPRESSOR_RUN_CONT
;
// / run compressor in continuous mode
$HISTMODE_Y
=
ELPHEL_CONST_TASKLET_HIST_ONCE
;
$HISTMODE_C
=
ELPHEL_CONST_TASKLET_HIST_ONCE
;
...
...
src/autocampars.py
View file @
1a7baa9c
...
...
@@ -120,7 +120,7 @@ def process_pyCmd(args):
try
:
with
open
(
STATE_FILE
,
"r"
)
as
f
:
content
=
f
.
read
()
except
Exception
,
e
:
except
Exception
as
e
:
err
=
str
(
e
)
if
not
err
:
for
line
in
content
.
split
(
"
\n
"
):
#split it into lines
...
...
@@ -138,13 +138,13 @@ def process_pyCmd(args):
if
'autocampars.php'
in
subprocess
.
check_output
(
"ps -w"
,
shell
=
True
):
v
=
ET
.
SubElement
(
xml
,
'autocampars'
)
v
.
text
=
'"Running"'
except
Exception
,
e
:
except
Exception
as
e
:
err
=
str
(
e
)
elif
fname
==
"start_gps_compass"
:
try
:
rslt
=
subprocess
.
check_output
(
"start_gps_compass.php"
,
shell
=
True
)
except
Exception
,
e
:
except
Exception
as
e
:
err
=
str
(
e
)
elif
fname
==
"disable_gpio_10389"
:
with
open
(
GPIO_10389
,
"w"
)
as
f
:
...
...
@@ -160,25 +160,25 @@ def process_pyCmd(args):
time
.
sleep
(
2
)
# check if needed
with
open
(
SATA_MODULE_CTRL
,
"w"
)
as
f
:
print
(
'1'
,
file
=
f
)
except
Exception
,
e
:
except
Exception
as
e
:
err
=
str
(
e
)
elif
fname
==
"init_sata_0"
:
#first step
try
:
rslt
+=
subprocess
.
check_output
(
PYDIR
+
"/x393sata.py"
,
shell
=
True
)
subprocess
.
call
(
"modprobe ahci_elphel &"
,
shell
=
True
)
except
Exception
,
e
:
except
Exception
as
e
:
err
=
str
(
e
)
elif
fname
==
"init_sata_1"
:
#second step (after some delay)
try
:
with
open
(
SATA_MODULE_CTRL
,
"w"
)
as
f
:
print
(
'1'
,
file
=
f
)
rslt
+=
"OK"
except
Exception
,
e
:
except
Exception
as
e
:
err
=
str
(
e
)
elif
fname
==
"ls"
:
#just for testing
try
:
rslt
=
subprocess
.
check_output
(
"ls -all"
,
shell
=
True
)
except
Exception
,
e
:
except
Exception
as
e
:
err
=
str
(
e
)
if
not
xml
:
...
...
@@ -210,7 +210,7 @@ def process_shell(args):
cmd
+=
' '
+
' '
.
join
(
str
(
e
)
for
e
in
fargs
)
try
:
rslt
+=
subprocess
.
check_output
(
cmd
,
shell
=
True
)
except
Exception
,
e
:
except
Exception
as
e
:
err
=
str
(
e
)
if
rslt
:
result
=
ET
.
SubElement
(
xml
,
'result'
)
...
...
@@ -246,7 +246,7 @@ def remote_parallel_urls(urls, timeout=0): #imeout will restart for each next ur
def
read_url
(
index
,
queue
,
url
):
try
:
queue
.
put
((
index
,
urllib2
.
urlopen
(
url
)
.
read
()))
except
Exception
,
e
:
except
Exception
as
e
:
# create xml with error message
xml
=
ET
.
Element
(
'root'
)
emsg
=
ET
.
SubElement
(
xml
,
'error'
)
...
...
@@ -266,7 +266,7 @@ def remote_parallel_urls(urls, timeout=0): #imeout will restart for each next ur
try
:
rslt
=
queue
.
get
(
block
=
True
,
timeout
=
timeout
)
rslts
[
rslt
[
0
]]
=
rslt
[
1
]
except
Exception
,
e
:
except
Exception
as
e
:
# print ("***** Error: ",str(e),rslt) ## Only timeout errors should be here
break
## print("*** remote_parallel_urls(): got ",rslts)
...
...
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