Commit 3abad7aa authored by Qiang Du's avatar Qiang Du

Add get-time.sh from gsi-timing-starter-kit

parent 4f605044
#! /bin/bash
# http://www.ohwr.org/projects/gsi-timing-starter-kit/wiki/Read_the_current_time
dev="$1"
FLAGS="-p -a 32 -d 32 -r 0"
EB_READ="eb-read"
while true; do
UTClo=0x`$EB_READ $FLAGS $dev 0x20308/4`
UTChi=0x`$EB_READ $FLAGS $dev 0x2030C/4`
CNT=0x`$EB_READ $FLAGS $dev 0x20304/4`
UTClon=0x`$EB_READ $FLAGS $dev 0x20308/4`
if test $UTClo == $UTClon; then break; fi
done
NS=$((CNT*8))
UTC=$(((UTChi%256)*4294967296 + UTClo))
printf "%d.%09d = " $UTC $NS
echo -n `date +"%Y-%m-%d %H:%M:%S" -d @$UTC`
printf ".%09d\n" $NS
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