home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ARM Club 3
/
TheARMClub_PDCD3.iso
/
hensa
/
time
/
gpstime_1
/
!GPS_Time
/
!RunImage
(
.txt
)
< prev
next >
Wrap
RISC OS BBC BASIC V Source
|
1997-08-01
|
2KB
|
96 lines
Reset Acorn CMOS Clock from GPS Time
------------------------------------
Last modified 1997 Jun 07 [Sat] 1021 utc
1997 J R Miller g3ruh@amsat.org
error
"Wimp_Poll",&C1972,b%
event%
event%
)
0:
check_line:
timeout
$
17:
b%!16=0
quit% =
quit%
"Wimp_CloseDown"
"Wimp_Initialise",200,&4B534154,"UTC from GPS v1.01"
"OS_SerialOp",5,6 :
4800 baud
"OS_SerialOp",1,0 :
Format 8N1
"OS_Byte", 2,2 :
Enable serial ip
"OS_Byte",21,1 :
Flush ip buffer
b% &100
8ip$="" : quit%=0: ip$="": c%=0: line$="": timeout%=
1SECoffset=2 :
This gets added to GPS time
(-2)
c%<>13
"OS_SerialOp",4
,c%:
c%<>13
c%<>10 ip$+=
c%=13
line$=ip$: ip$="": c%=0
check_line
line$<>""
ID$=
line$,1,6)
ID$="$GPRMC"
ID$="$GPGGA"
set_time: quit%=
line$=""
set_time
Scan for first comma
line$,c%,1): c%+=1:
C$=","
line$,c%,2): c%+=2
line$,c%,2): c%+=2
line$,c%,2): c%+=2
Convert to number and add in offset.
8 HR=
HR$: MI=
MI$: SE=
9+time = (HR*60 + MI)*60 + SE + SECoffset
Convert back to string
<J HR=
(time/3600): HR$=
(HR):
(HR$)=1
HR$="0"+HR$
=Jtime-=HR*3600: MI=
(time/60): MI$=
(MI):
(MI$)=1
MI$="0"+MI$
>Ltime-=MI*60: SE$=
(time):
(SE$)=1
SE$="0"+SE$
@T?b%=8: $(b%+1)=HR$+":"+MI$+":"+SE$+
(0):
Required format for RTC is "12:34:56"
"OS_Word",15,b% :
Set CMOS time and soft copy
7 :
beep
Usable messages, e.g.:
$GPRMC,203409,A,5212.4600,N,00003.5436,E,0.174,296.8,060697,3.8,W*6B
$GPGGA,203410,5212.4585,N,00003.5379,E,1,08,1.00,7.9,M,47.0,M,,*72
timeout
-timeout%) > 1000
quit%=
Quit program after 10 seconds regardless
error
txt$=
$+" at line "+
b%!0=
$(b%+4)=txt$+
"Wimp_ReportError",b%,17,"Message from !GPS_Time"