Commit 1a7baa9c authored by Andrey Filippov's avatar Andrey Filippov

adding boson

parent 31d99405
...@@ -768,7 +768,25 @@ function detect_camera(){ ...@@ -768,7 +768,25 @@ function detect_camera(){
// sensor's code from c313a.h // sensor's code from c313a.h
$sensor_code = 68; // TODO: ************** Import as PHP constant? *********** $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)."\ncommand return value=".$retval."\n");
// sensor's code from c313a.h
$sensor_code = 0x48; // TODO: ************** Import as PHP constant? ***********
}else { }else {
respond_xml ('', 'Do not know how to initialize master camera ' respond_xml ('', 'Do not know how to initialize master camera '
.print_r($GLOBALS['camera_state_arr']['is_mt9p006'],1) .print_r($GLOBALS['camera_state_arr']['is_mt9p006'],1)
...@@ -956,6 +974,74 @@ function detect_camera(){ ...@@ -956,6 +974,74 @@ function detect_camera(){
if ($GLOBALS['STOP_AFTER'][$GLOBALS['camera_state_arr']['state']]) break; // will break anyway 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; break;
} }
...@@ -1637,6 +1723,8 @@ function get_application_mode() { ...@@ -1637,6 +1723,8 @@ function get_application_mode() {
return get_eyesis_mode(); return get_eyesis_mode();
case 'LEPTON35': case 'LEPTON35':
return get_lepton35_mode(); return get_lepton35_mode();
case 'BOSON640':
return get_boson640_mode();
default: default:
respond_xml('','Unknown camera type, '.print_r($GLOBALS['camera_state_arr'],1)); respond_xml('','Unknown camera type, '.print_r($GLOBALS['camera_state_arr'],1));
...@@ -1717,6 +1805,17 @@ function get_lepton35_mode() { ...@@ -1717,6 +1805,17 @@ function get_lepton35_mode() {
return $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: * Eyesis application modes:
...@@ -2897,7 +2996,8 @@ function curl_multi_finish($data, $use_xml=true, $ntry=0, $echo = false) { ...@@ -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 function createDefaultConfig($version, $port, $multisensor = false, $eyesis_mode = 0) { // / 0 - not eyesis, 1-3 - camera number
$lepton35 = $GLOBALS['camera_state_arr']['is_lepton35']; $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 $COMPRESSOR_RUN = ELPHEL_CONST_COMPRESSOR_RUN_CONT; // / run compressor in continuous mode
$HISTMODE_Y = ELPHEL_CONST_TASKLET_HIST_ONCE; $HISTMODE_Y = ELPHEL_CONST_TASKLET_HIST_ONCE;
$HISTMODE_C = ELPHEL_CONST_TASKLET_HIST_ONCE; $HISTMODE_C = ELPHEL_CONST_TASKLET_HIST_ONCE;
......
...@@ -120,7 +120,7 @@ def process_pyCmd(args): ...@@ -120,7 +120,7 @@ def process_pyCmd(args):
try: try:
with open (STATE_FILE,"r") as f: with open (STATE_FILE,"r") as f:
content = f.read() content = f.read()
except Exception, e: except Exception as e:
err=str(e) err=str(e)
if not err: if not err:
for line in content.split("\n"): #split it into lines for line in content.split("\n"): #split it into lines
...@@ -138,13 +138,13 @@ def process_pyCmd(args): ...@@ -138,13 +138,13 @@ def process_pyCmd(args):
if 'autocampars.php' in subprocess.check_output("ps -w",shell=True): if 'autocampars.php' in subprocess.check_output("ps -w",shell=True):
v=ET.SubElement(xml, 'autocampars') v=ET.SubElement(xml, 'autocampars')
v.text='"Running"' v.text='"Running"'
except Exception, e: except Exception as e:
err=str(e) err=str(e)
elif fname == "start_gps_compass": elif fname == "start_gps_compass":
try: try:
rslt = subprocess.check_output("start_gps_compass.php",shell=True) rslt = subprocess.check_output("start_gps_compass.php",shell=True)
except Exception, e: except Exception as e:
err=str(e) err=str(e)
elif fname == "disable_gpio_10389": elif fname == "disable_gpio_10389":
with open (GPIO_10389,"w") as f: with open (GPIO_10389,"w") as f:
...@@ -160,25 +160,25 @@ def process_pyCmd(args): ...@@ -160,25 +160,25 @@ def process_pyCmd(args):
time.sleep(2) # check if needed time.sleep(2) # check if needed
with open (SATA_MODULE_CTRL,"w") as f: with open (SATA_MODULE_CTRL,"w") as f:
print ('1',file=f) print ('1',file=f)
except Exception, e: except Exception as e:
err=str(e) err=str(e)
elif fname == "init_sata_0": #first step elif fname == "init_sata_0": #first step
try: try:
rslt += subprocess.check_output(PYDIR+"/x393sata.py",shell=True) rslt += subprocess.check_output(PYDIR+"/x393sata.py",shell=True)
subprocess.call("modprobe ahci_elphel &",shell=True) subprocess.call("modprobe ahci_elphel &",shell=True)
except Exception, e: except Exception as e:
err=str(e) err=str(e)
elif fname == "init_sata_1": #second step (after some delay) elif fname == "init_sata_1": #second step (after some delay)
try: try:
with open (SATA_MODULE_CTRL,"w") as f: with open (SATA_MODULE_CTRL,"w") as f:
print ('1',file=f) print ('1',file=f)
rslt += "OK" rslt += "OK"
except Exception, e: except Exception as e:
err=str(e) err=str(e)
elif fname == "ls": #just for testing elif fname == "ls": #just for testing
try: try:
rslt = subprocess.check_output("ls -all",shell=True) rslt = subprocess.check_output("ls -all",shell=True)
except Exception, e: except Exception as e:
err=str(e) err=str(e)
if not xml: if not xml:
...@@ -210,7 +210,7 @@ def process_shell(args): ...@@ -210,7 +210,7 @@ def process_shell(args):
cmd += ' '+ ' '.join(str(e) for e in fargs) cmd += ' '+ ' '.join(str(e) for e in fargs)
try: try:
rslt += subprocess.check_output(cmd,shell=True) rslt += subprocess.check_output(cmd,shell=True)
except Exception, e: except Exception as e:
err=str(e) err=str(e)
if rslt: if rslt:
result=ET.SubElement(xml, 'result') result=ET.SubElement(xml, 'result')
...@@ -246,7 +246,7 @@ def remote_parallel_urls(urls, timeout=0): #imeout will restart for each next ur ...@@ -246,7 +246,7 @@ def remote_parallel_urls(urls, timeout=0): #imeout will restart for each next ur
def read_url(index, queue, url): def read_url(index, queue, url):
try: try:
queue.put((index, urllib2.urlopen(url).read())) queue.put((index, urllib2.urlopen(url).read()))
except Exception, e: except Exception as e:
# create xml with error message # create xml with error message
xml = ET.Element('root') xml = ET.Element('root')
emsg = ET.SubElement(xml, 'error') emsg = ET.SubElement(xml, 'error')
...@@ -266,7 +266,7 @@ def remote_parallel_urls(urls, timeout=0): #imeout will restart for each next ur ...@@ -266,7 +266,7 @@ def remote_parallel_urls(urls, timeout=0): #imeout will restart for each next ur
try: try:
rslt = queue.get(block=True, timeout=timeout) rslt = queue.get(block=True, timeout=timeout)
rslts[rslt[0]] = rslt[1] rslts[rslt[0]] = rslt[1]
except Exception, e: except Exception as e:
# print ("***** Error: ",str(e),rslt) ## Only timeout errors should be here # print ("***** Error: ",str(e),rslt) ## Only timeout errors should be here
break break
## print("*** remote_parallel_urls(): got ",rslts) ## print("*** remote_parallel_urls(): got ",rslts)
......
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