NetTime has no effect on bootup
Jeff Doggett (257) 234 posts |
!Amu seems to accept the industry standard Makefiles. It even converts the unix format filenames for you. Jeff |
Rick Murray (539) 13850 posts |
It’s like GPL without the bull – so hack, fiddle, and share. https://joinup.ec.europa.eu/software/page/eupl/licence-eupl Simple PDFs. Pick a language. ;-) |
jim lesurf (2082) 1438 posts |
That may be so, but I don’t understand them, either. 8-]
OK. :-) Jim |
David Feugey (2125) 2709 posts |
Good idea. |
David Pitt (102) 743 posts |
No, but I thought I would try it out anyway. Not being a C expert of any sort I have got as far as discovering !Make is now regarded as somewhat yesterday and these new Makefiles are quite the modern way. The makefile below uses Capp and does build JimTime. # Makefile for JimTime COMPONENT = JimTime CINCLUDES = -ITCPIPLibs:,C: LIBS = TCPIPLibs:o.Socklib ${INETLIB} ${UNIXLIB} include CApp C_WARNINGS = -Wp # Dynamic dependencies: The one oddity was that
SOCK4LIB = TCPIPLibs:o.socklib SOCK5LIB = TCPIPLibs:o.socklib5
Have I found a bug or just an anomaly? |
Rick Murray (539) 13850 posts |
I have a vague recollection that something changed in the stack; so maybe it was changed to require version 4 or 5 to be specified. |
David Pitt (102) 743 posts |
With just a little more digging :- NET4LIBS = ${UNIXLIB} ${INETLIB} ${SOCK4LIB} NET5LIBS = ${UNIXLIB} ${INETLIB} ${SOCK5LIB} Assuming the ‘5’ variant is the one to use then the LIBS line can be simplified :- LIBS = ${NET5LIBS} JimTime compiles and runs. |
jim lesurf (2082) 1438 posts |
FWIW I’ve now combined Rick’s code with some that reads the realtime local clock and works out how much they differ. I’m using the Territory swis for reading the local time and the zone and offset, so may eventually also be able to take that into account. But at present I’m focussed on GMT/UT. Rick’s code waits 1 sec. I find I have to make that 2 or more as otherwise it gets no response in time fairly often. The downside is a greater error due to the wait when it responded quickly. So I may experiment with looping this until it gets a coconut or goes beyond, say, 5 sec. Not tried it yet, though, so I don’t know if it will work. But if it does, the loop delay could be less than a sec to get more accuracy. However I doubt the results will be accurate to more than a second or two anyway. So may just let it run once for two sec. Then subtract a second from the difference to split it. :-) As a result I hope to get an initial program that can set the clock if it is off by more than a couple of seconds. But only accurate to a second or so. Until I get a chance to experiment with zone effects I’ll probably limit the program to just offering to set the time when the error is less than an hour and more than, say, 2 sec. Must admit I’ve been confused a few times by the PRMs on the various ‘formats’ and ‘clocks’ on the machine. Some swis use 5-byte time, but others mention 7-byte, plus all the various string formats and ordinal representations. Maybe its me, but at present it seems a bit haphazard and I have to convert via one form into another into another. Jim |
Steve Pampling (1551) 8172 posts |
So that you know where you’re aiming – NTP is supposed to work on the basis of making the system take a large step if the reference time and the system time differ by a large amount and only use the slew method of micro adjustments when the two a close but not identical so if you produce an offer to sync to within a few seconds when the difference is large you are following the correct path. |
Rick Murray (539) 13850 posts |
You don’t need to take it much into account – Territory can tell you UTC, local, the difference, and if DST is in use on a given date. Just combine the right calls at the right time…
Hmmm… My original code specified two seconds, but it always responded for me when the delay was one second. Here’s something you can do:
The returncode is a count of how many bytes have been read. So you can replace that line with something like:
In order words, you’ll just keep calling socketread() until a timeout happens or some data turns up. You may need to check the result to ensure that all of the data has arrived, but since it’s like 40 bytes or so, it shouldn’t come in bits. See how you get on in real life use.
That ought to be sufficient. After all, the FAT filesystem is only accurate to two seconds and uses local times (brilliant in DST changes) but it served PC users… well, it still does. FAT32 can record file times to milliseconds, but any accuracy more than the old 2-sec way is “optional”. ;-)
Let’s start with the clocks and timers. There are four (!).
Something you might not have known but do now: Boot to the desktop. Open a TaskWindow…
Yup, they’re not the same ticker, though both run at 100Hz. BTW, setting the system clock is an obnoxious thing to do in a multitasking world. It belongs in the epoch where games and such would unplug every module in sight to gain a few extra kilobytes. [annoyingly common in the days of RISC OS 2, leaving you to sort out the mess if the software crashes and doesn’t restore your machine] Now for the time formats:
Generally, for what you are doing, you will want to provide Just… Use Territory Manager. I’m not sure if time and date are really something in Territory’s remit, but it does a good job so I’ll recommend it.
Well, you can, if you wish, parse the input string and construct your own count of centiseconds since 1970. Hope this helps. |
jim lesurf (2082) 1438 posts |
My approach has to be very simple. In effect at present it will be: If the time ‘offset’ is more than 1 (or 2) seconds it will ask the user if they want the time to be set. That will then simply alter the time by the determined offset. However if the offset it bigger than, say, an hour, it may warn that the error may be due to a zone problem. (This is because I may not be able to suss and test this properly initially.) I’m not going to make any attempt to regulate the clock (i.e. not change any clock rates). Just set the clock (i.e. alter the ‘current time’). For situations like my own, regulation that only works on the ‘soft clock’ until a power down is wasted effort. And by set, initially I’m just concerned with the time-of-day for simplicity. Once I can ensure I can handle zones I could then widen this to the entire time. Rick: Thanks for the suggested mod to the looping, etc. I’ll have a go at incorporating that. Its clevered than the way I’d aimed to try as I didn’t know how the buffer could be checked. Indeed, I wasn’t certain that even trying to check might not be distructive! Thanks also for the tips and info. I was baffled by the 7-byte mention in the PRMs when everything else is 5-byte, Ordinal, etc. I was going to ignore it out of ignorance, but had a nagging feeling that might bite me. I’ve not checked yet but IIUC the 5-byte time is equivalent to the 5 smallest bytes of a 64bit int that counts the monotonic time from the reference start instant. I can’t help wishing they’d just adopted a such an int from the start of RO. But I guess back then BASIC was more relevant than ‘C’. 8-] Jim |
jim lesurf (2082) 1438 posts |
Just checked and this seems fine. I can convert the 5-byte values into a time in cs OK. Since I’m currently just wanting to ‘set the time of day’ I can then adjust that by the offset between net and local time-of-day, then write the new 5-byte value to ‘correctly’ set the clock with an accuracy of a second or two. Jim |
jim lesurf (2082) 1438 posts |
I now have a program that seems to work here if I have my machine’s clock set to either GMT or BST (via the ‘BST’ flag). I need to test it a bit more and tweak a little. Then I’ll make a copy available in case anyone else wants to test it. Please note, though, that I have kept the program to just ‘checking and fixing the time of day’. So it assumes you already have to correct day and date set. The aim of the program is to just make slight adjustments of the clock in terms of mins/secs to counter the drifts we get from day to day because the RTC isn’t running at exactly the correct rate. It also works via a TaskWindow and asking the user to choose if to set the clock or not having listed and compared the nist time with the local clock’s UTC. This to let the user avoid messing up their clock if the program gets it wrong. (Should the program turn out to be useful and reliable it will be easy enough to have a ‘just do it’ mode so simply running the program sets the clock without any user interactions. But I’m not that confident as things stand! More checks and work to do.) Jim |
jim lesurf (2082) 1438 posts |
OK, for anyone whose stomach and nerves are up to it, I’ve put a copy of my current program here http://jcgl.orpheusweb.co.uk/temp/JimTime.zip It ‘mostly works’ here. But I’m sure there are still problems. It works here if I set DST or not. Occasionally earlier versions would fail in various ways. Not yet sure if I’ve fixed that entirely, but it has been OK during recent tests. Use at your own risk. :-) I’ve deliberately named the application SetTimeOfDay to make plain that it won’t handle errors in the day and date. Its just to fix offsets of some mins or secs that can accumulate if the RTC hasn’t been corrected for a while. Please read the included !Help before use. If nothing else that should reduce any sense of dissapointment when you try the program. ;→ Jim |
Christopher Bazley (2559) 6 posts |
Martin’s problem was caused by the fact that the system variable Inet$NTPServer had not been set at the time that the NetTime module was loaded (nor at the time of his *NetTime_Kick command). I believe this variable was being set after !Boot had completed, but I didn’t bother investigating further. The NetTime module can’t set the real-time clock if it doesn’t know which server to query – it’s as simple as that. It always fetches the current time when it is loaded, so a *NetTime_Kick command should be superfluous unless Inet$NTPServer is set after loading the module. I solved the problem by inserting commands to set Inet$NTPServer and *RMEnsure NetTime 0.0 RMLoad NetTime in an Obey file which contains additional Internet configuration commands set by the user, which is run during the pre-desktop part of the boot sequence. This is where I’d expected Internet configuration to occur. (This Obey file is also accessible through the Configure application plug-in for Internet configuration.) I don’t know why the TimeSetup plug-in (or whatever it’s called) stores an Obey file to be run as a task after entering the desktop rather than as part of the predesktop boot. I didn’t modify the TimeSetup Obey file, so it still does *RMEnsure NetTime (which now has no effect, since the module has already been loaded) and sets the interval between NTP queries. Christopher |
jim lesurf (2082) 1438 posts |
In the last week or two I’ve seen various comments on usenet, etc, to the effect that “something seems to have changed” wrt fetching net time. Along with this the program I wrote in 2014 – based on Rick’s fetching code – also has ceased working. The program in question is still available zipped from http://jcgl.orpheusweb.co.uk/temp/JimTime.zip However when I run it on my ARMX6 now, it freezes the machine. Almost nothing works, and even the caret ceases to flash. f12 ignored, etc. Although the mouse pointer still works. I have to do a power cycle to get a working machine. Discussion on usenet did briefly indicate that setting a larger buffer worked. I tried this, but it worked once, then never again. So I am left with the impression that – purely by luck – it still sometimes works. But almost always stiffs. Rick, can you or someone else help me with this? I don’t understand the details of the time fetching and socket use. I’m just using your code to get a value I then can compare with the local clock, and then adjust it. BTW Sorry I’ve not visited the forum for ages. Been doing other things. Mainly building a (large) new website at http://www.torrens.org.uk/ukhhsoc/AudioDocs.html which may interest those into hifi, etc. :-) I’ve not visited this forum for so long that I’d forgotten my password and had to set a new one! Thanks Jim |
Jon Abbott (1421) 2651 posts |
I’ve seen this many times, in fact I removed NetTime from all my machines back in 2013 when I first tracked it down as the cause of machine locks. Memory is a bit vague, but I believe the lockup occurs when NetTime fails to connect to the time server, possibly due to a failed DNS lookup. |
jim lesurf (2082) 1438 posts |
IIUC Rick’s code is supposed to time out after waiting 5 sec. It has done this OK in the past. But not now. Note that the code he wrote and I’m using isn’t the same as used in other time-fetching user software. The puzzle is why it has worked fine for years. But now falls over almost every time I try it. |
Sprow (202) 1158 posts |
The thread referred to is commenting on an A4000 though, which runs RISC OS 3.00 (or maybe 3.10), so the conclusion is nonsense based on that particular observation. NetTime is in !System.360.Modules.Network so wouldn’t be visible on an A4000 and the configure plugin used to enable it RMEnsures RISC OS 3.60 too, so wouldn’t run on an A4000 either. |