[Elphel-support] DateTimeOrignal TAG in EXIF
Andrey Filippov
andrey at elphel.com
Sun Feb 14 17:53:23 PST 2010
Robbert,
Below is a snippet from the /etc/init.d/usb (sorry - it should be
moved to some other script) that runs at system boot time. You can
use similar method (PHP extension function elphel_set_fpga_time() ):
...
begin "Setting time from NTP server"
/usr/local/bin/sntpdate 2> /dev/null
NTP_RESULT=$?
if [ "$NTP_RESULT" = "0" ]; then
sleep 1;
echo -e "${OKPOS}${BRACKET}[ ${GOOD}`date`${BRACKET} ]${NORMAL}"
information "Setting FPGA time from the system time"
echo "<?php elphel_set_fpga_time(time()+0.0); ?>" | php -a -q > /dev/null
else
echo -e "${FAILPOS}${BRACKET}[ ${WARN}unavailable${BRACKET} ]${WARN}"
fi
Next is that function implementation (
http://elphel.cvs.sourceforge.net/viewvc/elphel/elphel353-8.0/apps/php-5.2.9/ext/elphel/elphel_php.c?revision=1.2&view=markup
) :
1995 //! set FPGA clock. Input parameter - (double) seconds (i.e.
from 01/01/1970)
1996 //! This clock is used to timestamp each image
1997 //! returns same time rounded to microseconds (as written to FPGA)
1998 PHP_FUNCTION(elphel_set_fpga_time) {
1999 unsigned long write_data[8]= {FRAMEPARS_SETFRAME, 0,
2000 G_SECONDS, 0,
2001 G_MICROSECONDS, 0,
2002 FRAMEPARS_SETFPGATIME, 0};
2003 double dtime;
2004 long ltime_sec,ltime_usec;
2005 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d",
&dtime) == FAILURE) {
2006 RETURN_NULL();
2007 }
2008 ltime_sec=dtime;
2009 ltime_usec=(dtime-ltime_sec)*1000000;
2010 write_data[3]=ltime_sec;
2011 write_data[5]=ltime_usec;
2012
2013 long rslt=write(ELPHEL_G(fd_fparmsall), write_data, sizeof(write_data));
2014 if (rslt<0) RETURN_LONG(-errno);
2015 dtime=ltime_usec;
2016 dtime=ltime_sec+0.000001*dtime;
2017 RETURN_DOUBLE(dtime);
2018 }
Andrey
>
More information about the Support-list
mailing list