NetTime has no effect on bootup
Steve Pampling (1551) 8172 posts |
The thing is that since it fits with what I do at work I set machines at home to use DHCP and allow the network systems to do the rest and set the time system to use NTP and allow the NTP system to set the time. Question, how many of the people having time problems use manually assigned addresses? |
Rick Murray (539) 13850 posts |
I bet the NTP people would say the same. It’s a bit like “lucked out” / “lucked in”.
I actually doubt many people would notice.
I don’t know if you can use wget to read NTP. It works using UDP, does wget support that? Alternatively – you can connect to time.nist.gov and it will reply with a few bytes which are the count of seconds since UnixTime (Jan 1st 1970 IIRC). Or, easier to parse, you can connect to time.nist.gov on port 13 and it will reply with: 56974 14-11-13 19:17:46 00 0 0 685.6 UTC(NIST) * which is the modified Julian date, the date in YY-MM-DD format (two digit year? seriously?), the time, some code to show if the US is in winter time (0x) or summer time (5x), a flag for leap second addition at the end of the day (0=none, 1=add, 2=remove), a “server health” report (if non-zero, don’t trust the time given), how many milliseconds the time was advanced for network delays, "UTC(NIST)" for timezone and origin (this does not change), and a “*” at the end to mean “it is this time now” or something. I’ve telnetted to the server a dozen times and the star is always there, maybe the server delays replying until the time is exactly as given?
Err… So we are blaming the users because there is no “just set the time and shuttup” option? ;-) At the very least, RISC OS probably ought to trap/fault dates prior to 2014.
For what? The client? The gateway? The DNS? The time server? “All of the above”? |
Steve Pampling (1551) 8172 posts |
Looking for triggers. When diagnosing there is no right or wrong, merely “this” “that” and “the other”
Check the code – I believe it has an NTP zero point of “2003 ish”
Well I was thinking client, but since you mention it “all of the above” :) Information is the key. 1 Somewhere comparable in duration to the time required for RISC OS being fully multi-threaded running on 32 core systems may be adequate |
Rick Murray (539) 13850 posts |
This doesn’t appear to be borne out by Martin’s experience if NetTime fails and the date is left at 1970.
I wouldn’t wager on that – it would be a little less than sane for a group of interested companies to design a board for use with RISC OS that has a multi-core processor and not be planning (at some random future date) to make use of all of the resources available. As we know, ROOL had support for the Pi B+ ready for the release of the B+, so for all we know the intelligent coders here1 are already bashing out a specification to implement. Which is probably better than asking opinions on a forum! ;-) Aaaanyway – I rather suspect that for some seemingly random reason, Martin’s time fetching fails. Like how sometimes when my EeePC connects to the Livebox, it ends up with the address 169.254.0.1. To dig in further, Martin would need to immediately look at all of his IP configuration values (I think Given that this has happened more than once2, and given that it has caused loss of data, if I was Martin I would write a small program to either abort the boot if the clock was set way in the past, or (if using BASIC), just call OS_Reset if the clock is bad. Sure, this might leave the machine in a loop of constant resets if the network is down, so add in a check for INKEY(-3) to override this if an ALT key is held down. Or hammer ESC as RISC OS starts. Either will get you to a desktop. ;-) 1 Which pretty much rules me out then! 2 I cannot say if my NetTime fails. It provides no obvious notification other than the possibility that the RTC won’t be exactly accurate; but without constantly comparing it to something… unlike with Windows, there is no clock on my iconbar, so it could be minutes out and I wouldn’t know. |
jim lesurf (2082) 1438 posts |
What you say makes sense but probably examples a critical assumption behind NetTime. In essence it takes for granted that the user will be in a situation like the one you outline. Having a set of connected machines that are essentially ‘always on’ and you need to closely synch their times as well as have those times close to external references. But I normally only turn on a machine when I want to use it. Use it. Then switch it off again. So generally one machine on at a time, and no need to synch them with great precision. And most of the time, all the machines are powered down. In this context what NetTime does is futile. It tries to ‘set’ the clock by actually nudging the rate. But long before that magical future state of perfection, I’ve powered down the machine and its back on its hardware real time clock. Since my experience is that even when minutes in error it often fails to actually set the clock, its useless. Because it makes assumptions about my situation which are wrong and doesn’t cater for my real situation. All made worse by the misleading ‘set’ claim. So for some people, its fine. For others it is practically useless. Worse if people think it has really set the clock and need it to have done so but it didn’t. Jim |
jim lesurf (2082) 1438 posts |
Rick: Again, my apologies but a lot of what you explain wrt being able to connect, etc, I simply don’t know how to do. You are assuming I know what it meant by things like:
But I don’t. “Connect” how? I have no real understanding of how to do such things at present. So when I look at things people point me to I don’t even know the language a lot of the time. I accept this is my ignorance, and aplogise for it, but it means I’m unclear how to proceed. If I understood I might be able to make something that behaves (from the user’s POV) like the old !FreeTime. But when I look at that I get lost for similar reasons. I can follow each line of ‘C’ but not what they actually do at this level. Jim |
jim lesurf (2082) 1438 posts |
So, can someone explain or point me to a simple explanation of how to do what I say I don’t understand above? I’d welcome help. Jim |
Rick Murray (539) 13850 posts |
I got that information simply by using telnet to the appropriate address and port. I don’t know if wget will do this. If not, perhaps I could put something together? It’s a simple open connection, read data, close type of thing… You might be able to have a crack at it by looking at the code that you already have? |
jim lesurf (2082) 1438 posts |
I have a port of wget which allows me to give it a URL and fetch a file. But I’ve only managed to get this to work with http://… addresses to fetch html or text pages. i.e. Much like using a browser, but saves just the specified file to a local file. I don’t have a specific telnet program. I’ve looked at the innards of !FreeTime but don’t understand it well enough to attempt to try using parts as a basis for something new that might work. How would I use a telnet like connection with wget? Change the http:// part to something else? Or does that make no sense and I need something specific? FWIW The method I’m using at present simply issues a command for wget of the form wget -i <TimeWget$urlfile> -P <TimeWget$ResultsDir> -O <TimeWget$ResultsDir>.navytime -o <TimeWget$ResultsDir>.report in a TaskWindow having had !Boot define Set TimeWget$Dir <Obey$Dir) The ‘timeurl’ file contains http://tycho.usno.navy.mil/cgi-bin/timer.pl So all I do at present is use wget with no real idea how wget’s actual code operates above it being a ‘black box’. It clearly isn’t satisfactory as sometimes I get nothing back. But when it works I get a ‘navytime’ file which specifies the time from their clock, datestamped with my local machine’s time. Its clumsy, but the best I’ve managed. At least it lets me set the time. If I can find a better way I can then have the process either timeout or set the time after asking if the user wants it and the error is more than a user-defined amount. Jim |
jim lesurf (2082) 1438 posts |
FWIW I just tried
And it just retried and failed a few times. So I’m obviously doing something wrong or the above isn’t able to work. So far as I know the wget only uses http and ftp. I’m guessing how to add the port number because I recall using a colon or similar for radio streams. But you can see I don’t know much about this area! :-/ I also looked at the list of *nix ports but no telnet. Long time since I’ve used it. Is there a current RO program for it? Apologies again for the ignorance. Jim |
Martin Bazley (331) 379 posts |
I knew I shouldn’t have forgotten about this thread again. In my absence, a lot of Chinese whispers seem to have gone about regarding the nature of my problem. To elaborate:
I’ve confirmed through boot sequence hackery in the past that the TimeSetup file and whatever I’m currently using to issue the NetTime_Kick command are being executed, in their entirety, after the network has been initialised. I do not believe race conditions are a plausible answer, because the network setup happens in PreDesk and NetTime is run in Tasks, and while the boot sequence does have non-deterministic elements one of the few things it does guarantee is that everything in PreDesk happens before everything in Tasks. (I should know, I had to go to some lengths to exploit this in MBBack.) |
jim lesurf (2082) 1438 posts |
FWIW I’ve been experimenting with !HearSay to telnet. That works OK for getting a response from nist showing the time. But I’ve only managed that in a terminal and there are now no manuals explaining the scripting system or how I might get it to run the same fetch as something I can launch and then use the result to set the time. David Pilling has said I can probably do it via a block driver. But I have zero understanding of that! I’ve also tried an ancient ‘telnet’ absolute. This works. But I have no idea of its ancestry. Hence could not distribute it, or even be sure it is OK for me to use it. And it requires Aemulor as it isn’t 32-bit. Anyone able to advise? Jim |
Rick Murray (539) 13850 posts |
In I have some time tonight, I’ll throw together something for you when waiting for Akatsuki no Yona. |
jim lesurf (2082) 1438 posts |
Hi Rick, Yes, I have and use the ‘Acorn’ set of C/C++, etc, as now supplied by ROOL. Thanks. :-) And apologies again that I’m so clueless about this area! Jim |
Rick Murray (539) 13850 posts |
Right-o. I would have been quicker, but something messed up files on my SD card. Recovered most of the animé (and copied off to harddisc), refetched the damaged files. And Yona. ;-) Here is the C file:
And here is the MakeFile that builds it:
When run, it does this: *JimTime time.nist.gov says: 56986 14-11-25 20:27:33 00 0 0 :-) * So, it’s up to you to parse the data sent. I described the format a few messages back. It looks like a constant format, so plucking out stuff to sent to atoi() should work. If it was me, I would do this:
You may need to play around with DST. I don’t know if RISC OS (Territory) is smart enough to set this by itself when given a within-DST date. Okay, I’m going to click “Save reply” and see how much Textile messes this up. ;-) [edit: could have been worse…] |
jim lesurf (2082) 1438 posts |
Thanks, Rick! :-) Jim |
jim lesurf (2082) 1438 posts |
Sorry to be such a numpty, but I’ve having a problem which I guess stems from my never I saved the above from
(The above lines should start with hashes but textile turns them and typed it as a MakeFile. Then put the main C code into a c directory beside it along with o and h directories. Running the MakeFile give an error Format of make file is incorrect then displays a window with the lines AMU: * ‘JimTime’ not re-made because of errors * Jim |
Chris Johnson (125) 825 posts |
There are two things here. Firstly, by typing the makefile as a MakeFile and double clicking on it, it is probably being handled by the AcornC/C++ !Make application. However, the format of the makefile is not that which would be expected by !Make. You should probably be running AMU directly (from an obey file). Something like amu -f <Obey$Dir>.Makefileshould do it. The error ‘No writable memory at this address’ is most likely due to the Next wimpslot being too small. On modern machines it make sense to keep the Next slot to something like 5000K. I find in general that a next slot of 7000K eliminates the occurrence of this error when running binaries. |
jim lesurf (2082) 1438 posts |
Bingo. Yes! Thanks, Chris. That works OK. Afraid I’ve simply never used either Make or amu. My own programs are simply enough to just either It now works as Rick explained and I can do some experiments. Many thanks, Jim |
David Pitt (102) 743 posts |
Reply superseded & now deleted, except one can’t. |
Rick Murray (539) 13850 posts |
Your programs must be fairly simple then. ;-) When it comes to including other libraries (you’ll notice the Internet stuff pulls in three libraries!) or splitting the code up into modules of related functions, you’ll find MakeFiles are invaluable. It’s a lot of horrid fiddling around otherwise. I suspect Acorn only gave us !Make to handle programs written elsewhere. Make is awful – stupid pile of junk is only too happy to whinge about MakeFiles that it created. Sheesh!
I wouldn’t know. Yes, that is the reason, but when I need to compile a project, I just hit Ctrl-Shift-C in !Zap and Zap saves the file and starts the build process. I can’t remember the last time I started a build manually.
Let us know when you have something good that sets the time reliably. ;-) |
Steve Pampling (1551) 8172 posts |
Firstly, very much on baby steps myself, however I like nice repeatable setups. This obey file seems to work nicely if the file is in the same directory as the Makefile and gives you nice helpful reports of errors and warnings (if you have an editor that allows throwback like StrongED) Dir <Obey$Dir> Wimpslot 5000K amu_machine all THROWBACK=-throwback COMPONENT=yourtargetfile Note: no amu -f required if your obey file sits in the same directory as the makefile and you change to that directory, however specifying the makefile is good practice. As others have intimated making sure the file type of the makefile is NOT “makefile” is helpful in not using !Make. Text file &FFF is a good one to use as editing becomes easier :) probably not the recommended method. I’d also say that Rick including the objasm line for something that doesn’t appear to contain any assembler is a bit misleading when offering help for someone who has already stated they don’t understand most of this stuff. include CApp LIBS = tbox:o.wimplib tbox:o.eventlib tbox:o.toolboxlib oslib:o.oslib That include CApp includes the makefile elements required for a C app. Of course you have to download a build directory from ROOL and set it up as per instructions on the site. Thereafter you can create directories with a simple makefile and obey file. Creation of required directories like “o” and “od” etc is done automatically. This will even clean up old stuff and build a new – handy when you’re fiddling with multiple build attempts and looking for build errors. Dir <Obey$Dir> amu_machine clean stripdepnd Wimpslot 5000K amu_machine all THROWBACK=-throwback COMPONENT= |
David Pitt (102) 743 posts |
Building Rick’s source is very easy, I am using the recently released DDE25. Filetype the “MakeFile” as text, run !Amu, drop the makefile on !Amu. Job done. P.S. Oops, missed a bit, an ‘o’ directory needs to be created alongside the ‘c’ source directory. |
Rick Murray (539) 13850 posts |
It is a copy of the “standard” (for me) MakeFile that I have been using for nearly two decades.
Good grief – have you read what is in CApp? I can understand the attraction of using a standardised set of MakeFiles, but stuff like that isn’t going to teach somebody how a MakeFile actually works, specifically if they wish to try modifying it to suit themselves (and/or other projects). You may think that specifying objasm stuff is OTT, however if you have an assembler source and you write the names of the related object files into the “s_files” entry, it will “just work” and build the project. I don’t know why you specify the object instead of the source, MakeFiles are annoying like that, but it is a minor thing.
You can do that with a few tweaks to the MakeFile. :-) |
jim lesurf (2082) 1438 posts |
That’s about the only detail I’ve understood, so I’ll do that in future. Had no idea that ‘Make’ and
Afraid so! :-) In general I shove everything into one ‘C’ file. Only exceptions are that I have a couple I’m hoping to produce a simple program that will get the ‘net’ time, and compare it If I get anywhere I will make the results available for other to chuckle over or adapt I was tempted to ask for a pointer to an idiot’s guide to amu. But I decided that Thanks, Jim |