Getting the FS time

chat about arc/risc pc gaming & RISC OS software here (NOT the core OS!)

Related forum: adventures


gazzaD
Posts: 20
Joined: Sun Jun 18, 2017 11:37 am

Getting the FS time

Postby gazzaD » Tue Jun 27, 2017 6:06 pm

Until I get around to fixing the RTC in my A3000 I thought I'd have a go at syncing the clock to the Level 4 server on boot up using this code to get the network time:

Code: Select all

DIM fstime% 5, rotime% 5, format% 33, result% 26, rsize% 4

SYS "NetFS_DoFSOp", 16, fstime%, 5, 5
SYS "NetFS_ConvertDate", fstime%, rotime%

$format%="%W3,%DY %M3 %CE%YR.%24:%MI:%SE"+CHR$(0)
SYS "OS_ConvertDateAndTime", rotime%, result%, rsize%, format% TO ,rsize%
?rsize%=13

PRINT "Server time    :";$result%


It very nearly works, except the date returned is 28 years into the future. While I could just subtract 28 from the year, as the offset seems to remain consistent when I change the FS clock, it would also be nice to know what I've done wrong here so I can make it work without fudging it.

Thanks,
Gareth.
Gareth

User avatar
BeebMaster
Posts: 2475
Joined: Sun Aug 02, 2009 4:59 pm
Location: Lost in the BeebVault!
Contact:

Re: Getting the FS time

Postby BeebMaster » Tue Jun 27, 2017 8:32 pm

I haven't had the chance to check, I'm not sure doing this trying to read a Level 3 server time would give the same results, but according to p.725 of PRM volume 2, the file server interface returns a 7-byte block to the read time call. So maybe it should be:

Code: Select all

SYS "NetFS_DoFSOp", 16, fstime%, 5, 7

?
Image

User avatar
BeebMaster
Posts: 2475
Joined: Sun Aug 02, 2009 4:59 pm
Location: Lost in the BeebVault!
Contact:

Re: Getting the FS time

Postby BeebMaster » Tue Jun 27, 2017 8:56 pm

Nope, that didn't make any difference, but actually it works very nicely with the Level 3 file server:

TimeConv.jpg


So maybe check your Level 4 file server clock isn't actually 28 years ahead!!
Image

gazzaD
Posts: 20
Joined: Sun Jun 18, 2017 11:37 am

Re: Getting the FS time

Postby gazzaD » Wed Jun 28, 2017 7:21 pm

Increasing the buffer to 7 bytes hasn't helped.

Looking at the values returned by DoFSOp and comparing them to the PRM, the FS is returning the wrong year, rather than it being incorrectly converted. I've just fudged the code for now, but maybe when I get more time I'll give it a try with another Level 4 release (I'm using release 2 V1.24 at the moment).

Thanks,
Gareth

User avatar
BeebMaster
Posts: 2475
Joined: Sun Aug 02, 2009 4:59 pm
Location: Lost in the BeebVault!
Contact:

Re: Getting the FS time

Postby BeebMaster » Wed Jun 28, 2017 7:52 pm

Upgrade to Level 3, it's the only way forward!
Image

gazzaD
Posts: 20
Joined: Sun Jun 18, 2017 11:37 am

Re: Getting the FS time

Postby gazzaD » Sat Jul 01, 2017 1:44 pm

BeebMaster wrote:Upgrade to Level 3, it's the only way forward!


A FileStore and you might be talking :)

But back to the issue at hand. I've now had a chance to try a few different dates on the A3020, and it looks like Level 4 isn't fully Y2K compliant, as it returns all dates > 31st December 2000 as being 28 years into the future for the FSOp. File timestamps and log entries all look OK though.

Easy enough to work around I suppose, but not ideal. I'll consider it a little more encouragement to fix the RTC on the machine where it's broken.

Gareth.
Gareth

User avatar
jgharston
Posts: 2756
Joined: Thu Sep 24, 2009 11:22 am
Location: Whitby/Sheffield

Re: Getting the FS time

Postby jgharston » Sat Jul 01, 2017 6:09 pm

gazzaD wrote:But back to the issue at hand. I've now had a chance to try a few different dates on the A3020, and it looks like Level 4 isn't fully Y2K compliant, as it returns all dates > 31st December 2000 as being 28 years into the future for the FSOp. File timestamps and log entries all look OK though.

That sounds like it might be the Y97 bug. The 'year' component is stored in two fields, (year-1981)AND15 and (year-1981)DIV16, and the lower field wrapped in 1997 with many badly-written programs getting caught out.

What does your code actually return? What is the result of:

SYS "NetFS_DoFSOp", 16, fstime%, 5, 5
PRINT ~fstime%!0, ~fstime%?4


?

Code: Select all

$ bbcbasic
PDP11 BBC BASIC IV Version 0.25
(C) Copyright J.G.Harston 1989,2005-2015
>_

gazzaD
Posts: 20
Joined: Sun Jun 18, 2017 11:37 am

Re: Getting the FS time

Postby gazzaD » Sun Jul 02, 2017 12:19 pm

jgharston wrote:
What does your code actually return? What is the result of:

SYS "NetFS_DoFSOp", 16, fstime%, 5, 5
PRINT ~fstime%!0, ~fstime%?4


?


Here is what gets returned across the 2000/2001 transition, where 'raw fstime' is your print statement. The FS clock has been advanced 24 hours between the two runs:

Code: Select all

>RUN
raw fstime     : C3C3F         2
extracted year : 19
Server time    :Sun,31 Dec 2000.13:00:02
>RUN
raw fstime     : C0161         6
extracted year : 48
Server time    :Mon,01 Jan 2029.13:00:06
>

To extract the year I'm using: (?fstime% >>1) AND %01110000)+(?(fstime% +1)>>4)

Thanks,

Gareth
Gareth

User avatar
jgharston
Posts: 2756
Joined: Thu Sep 24, 2009 11:22 am
Location: Whitby/Sheffield

Re: Getting the FS time

Postby jgharston » Sun Jul 02, 2017 4:22 pm

Odd, that's definitely returning the wrong data:

Code: Select all

 02000C   3C3F
  time    date
 ssmmhh   00111100 00111111
12:00:02 0011 1100 001 11111
         yrLo mnth yrHi day
           31/12/1981+1*16+3
           31/12/2000

 06000C   0161
  time    date
 ssmmhh   0000000101100001
12:00:06 0000 0001 011 00001
         yrLo mnth yrHi day
           01/01/1981+3*16+0
           01/01/2029

It should return:

Code: Select all

           01/01/2001
           01/01/1981+20
           01/01/1981+1*16+4
         yrLo mnth yrHi day
         0100 0001 001 00001
          01000001 00100001
          date
          4121


(?fstime% >>1) AND %01110000)+(?(fstime% +1)>>4) - that's correct. Or, in pre-BASIC-IV-speak:
(?fstime% AND &E0)DIV2 + (fstime%?1 AND &F0)DIV16

Could you run through all dates and report what it returned. Something like:
FOR year%=1981 TO 1981+127
set file server date to 01-Jan-year%
SYS "NetFS_DoFSOp", 16, fstime%, 5, 5
PRINT year%,~fstime%!0
NEXT year%

then we can see if there's a pattern that can worked around.

Code: Select all

$ bbcbasic
PDP11 BBC BASIC IV Version 0.25
(C) Copyright J.G.Harston 1989,2005-2015
>_

gazzaD
Posts: 20
Joined: Sun Jun 18, 2017 11:37 am

Re: Getting the FS time

Postby gazzaD » Sun Jul 09, 2017 6:36 pm

I've not run through the possible dates to confirm, but what appears to happen is the reported time remains 28 years ahead of the hardware clock on the fileserver until 2079. Then at 2080 the reported time wraps back around to 1980, which sort of makes sense as the 7 bit Econet year wraps at this value.


Gareth.
Gareth

User avatar
jgharston
Posts: 2756
Joined: Thu Sep 24, 2009 11:22 am
Location: Whitby/Sheffield

Re: Getting the FS time

Postby jgharston » Sun Jul 09, 2017 8:21 pm

gazzaD wrote:Then at 2080 the reported time wraps back around to 1980, which sort of makes sense as the 7 bit Econet year wraps at this value.
No, the 7-bit date wraps round in 1981+128=2109.

It does look like there's a bug in the Level 4 File Server code.

Code: Select all

$ bbcbasic
PDP11 BBC BASIC IV Version 0.25
(C) Copyright J.G.Harston 1989,2005-2015
>_

gazzaD
Posts: 20
Joined: Sun Jun 18, 2017 11:37 am

Re: Getting the FS time

Postby gazzaD » Sun Jul 09, 2017 10:38 pm

jgharston wrote:
gazzaD wrote:Then at 2080 the reported time wraps back around to 1980, which sort of makes sense as the 7 bit Econet year wraps at this value.
No, the 7-bit date wraps round in 1981+128=2109.

It does look like there's a bug in the Level 4 File Server code.


It makes sense in as much as the value returned is 28 years ahead of the actual date, and so the wrap point is 28 years earlier than expected.

Gareth
Gareth


Return to “software”

Who is online

Users browsing this forum: No registered users and 2 guests