×

INDI Library v2.0.6 is Released (02 Feb 2024)

Bi-monthly release with minor bug fixes and improvements

Still weird issue with GPS time

  • Posts: 22
  • Thank you received: 1
On a previous thread, I had issues with Ekos polling data from my USB GPS receiver. Well that issue has been fixed. This one is different. I ran some tests last night with the Pi3 running headless (no ethernet /internet) this time and found that although proper location data is retrieved for my area, the time data is not. When I boot the Pi, the system time and date is way off obviously. That time and date information should correct itself once I connect to GPSD in EKOS, both in the mount UTC field and in Kstars, correct? I can see GPSD has got a fix, and latitude/longitude are correct, UTC is set to - 5, but the UTC time field is just a calculation of the incorrect system time +5. The local time in Kstars just sets itself to the system time. Clicking "update" in the GPSD driver doesn't correct things. Very weird behavior. The only way to get time to correct itself is to connect the Pi3 to the internet. cgps shows the correct UTC time after satlock whether offline or online.

Using a tutorial I found, I attempted to see if I can set the system time from GPSD at boot, but I've run into a wall because I'm getting errors from NTP. The NTP daemon will not start and any attempt to start the NTP service exits with the message:

● ntp.service - LSB: Start NTP daemon
Loaded: loaded (/etc/init.d/ntp; bad; vendor preset: enabled)
Active: failed (Result: exit-code) since pet 2017-03-24 13:24:13 CET; 3s ago
Docs: man:systemd-sysv-generator(8)
Process: 2092 ExecStart=/etc/init.d/ntp start (code=exited, status=5)

mar 24 13:24:13 tnmtv3 systemd[1]: Starting LSB: Start NTP daemon...
mar 24 13:24:13 tnmtv3 systemd[1]: ntp.service: Control process exited, code=exited status=5
mar 24 13:24:13 tnmtv3 systemd[1]: Failed to start LSB: Start NTP daemon.
mar 24 13:24:13 tnmtv3 systemd[1]: ntp.service: Unit entered failed state.
mar 24 13:24:13 tnmtv3 systemd[1]: ntp.service: Failed with result 'exit-cod

If I apt purge ntp and then reinstall ntp, everything will work... until I reboot. Then the error comes back. This is a relatively fresh Stellarmate install, so. I'm wondering if there is something wrong with MATE 16.04 for the Pi, or maybe a permissions issue?

What I want to know is if either issue is repeatable on other people's Pi3's running offline or is this exclusive to just me? I could care less about the NTP problem if I can just get EKOS/KSTARS to set to the GPS time signal once there is a satellite lock.
6 years 5 months ago #20440

Please Log in or Create an account to join the conversation.

Can you run this on the RPI3 and check if the timezone is correct for you?
sudo dpkg-reconfigure tzdata
6 years 5 months ago #20443

Please Log in or Create an account to join the conversation.

  • Posts: 983
  • Thank you received: 375
RPi does not have RTC (real time clock) so it boots at 01-01-1970 and needs to set proper time/date from some source. In a standard configuration it uses network to accomplish this goal. For many years NTP service has been used to sync operating system time to network based source. NTPD service also supports non-network sources such as GPSD service, so you can set operating system time even if you don't have Internet connection e.g. from gps device. So it is NTP service that sets your operating system time, not indi-gpsd driver. indi-gpsd driver reads operating system time and timezone to calculate offset and DST - if they are not correct you get the issues exactly you have described.

However NTP service has been replaced by timesyncd service in the recent ubuntu releases (which I believe is insane). For the sake of compatibility, timesyncd disables execution bit on ntpd service at the boot time. As the result NTP service runs fine after reinstallation and will not run after reboot. Moreover timesyncd service requires Internet connection and cannot use gps as a time/date source. To fix it you need to revert from timesyncd service to NTP service to support off-line time/date setting from gps. See example approach here
The following user(s) said Thank You: Jasem Mutlaq, Chad Andrist
Last edit: 6 years 5 months ago by Radek Kaczorek.
6 years 5 months ago #20446

Please Log in or Create an account to join the conversation.

  • Posts: 22
  • Thank you received: 1

Ohhhh, well then this pieces it together for me. I guess I'll be purging timesyncd and reinstalling NTP! Without your sage knowledge I would've never known. I will try to see if I can get proper time to set after satellite lock. I have modified my ntp.conf file to use GPSD as a means to set the local time via NTP, once I get NTP running hopefully this works

Thanks!
6 years 5 months ago #20447

Please Log in or Create an account to join the conversation.

  • Posts: 22
  • Thank you received: 1
Umm, it appears that timesyncd is NOT a part of MATE 16.04 Pi. rm /etc/systemd/system/systemd-timesyncd.service yields:

cannot remove '/etc/systemd/system/systemd-timesyncd.service' : No such file or directory

So now I'm still baffled what is killing NTP. This may all be for naught, I read something about NTP not being able to grab time from GPSD at boot because it takes too long to sync. Sigh. Not sure a Pi is ideal for a mobile setup. It's too much of a hassle having to reset time and location every time I power up. Back to the drawing board.

Also knro, I tried sudo dpkg-reconfigure tzdata and was in the right timezone.
6 years 5 months ago #20448

Please Log in or Create an account to join the conversation.

  • Posts: 298
  • Thank you received: 46
Hi SparkyHT,

I did some tests on Ubuntu on my laptop and came to this solution.. or maybe a oneliner solution..

sudo date +%Y-%m-%dT%H:%M:%S -s $(cut -d "=" -f 2 <<< $(indi_getprop GPSD.TIME_UTC.UTC))

While playing around with my GPS I found that the time is correct even before it gets a fix, not sure if all GPS works the same and I haven't tested this on my RPi but maybe you could do the testing :)

Br
/Markku
6 years 5 months ago #20457

Please Log in or Create an account to join the conversation.

  • Posts: 22
  • Thank you received: 1
I still don't have a fix for this. I removed timesyncd service and reinstalled NTP and I'm still getting the failed to start errors. It appears I'm screwed trying to use my RPI3 out in the field because it'll never have the right time. Making this work shouldn't have to be so difficult. I thought switching from Win10 to INDI meant freedom, flexibility, and reliability, it has been anything but. I have yet to get a successful clear night out with it. Driver issues from the start, and now foiled by trying to set something as basic and essential as a clock. I guess I didn't realize I had to be a Linux master to make INDI work for me.
6 years 5 months ago #20486

Please Log in or Create an account to join the conversation.

No need to use GPSD if it is not working for you, you can use your phone as the GPS source

EDIT: I will also update StellarMate OS image to utilize NTP/GPSD and make a new image available soon.
Last edit: 6 years 5 months ago by Jasem Mutlaq.
6 years 5 months ago #20490

Please Log in or Create an account to join the conversation.

Ok so I did a little bit more research and turns out using GPS for NTP is useless unless your GPS unit provides precise timing via PPS. The majority of GPS dongles don't support this. Check if your is supported here: www.catb.org/gpsd/hardware.html

I configured NTP to use GPS on StellarMate, and when I ran ntpq -p, I got this:
It's using online NTP servers even though I attached a GPS and it can "read" from it, but because it doesn't have PPS, it's useless. So I'd say just use GPS NMEA driver for time synchronization. The ones that provide PPA can be pretty expensive and not really worth it unless you're need nanosecond timings.
6 years 4 months ago #20505

Please Log in or Create an account to join the conversation.

  • Posts: 22
  • Thank you received: 1


Here's something interesting, on my Stellarmate, I can't even go into ntpq or any other ntp related register. I always get "Connection Refused". I freshly installed the image once again and tried getting into NTP, but still get the error code=5 message. Like I said before, I tried purging timesyncd and reinstalling NTP. It just doesn't want to run on the Pi. This version of MATE is just crippled and I don't have the knowledge to make it do what I want to do.

And judging by the GPS:Smartphone thread, it doesn't look like THAT is working well either. You simply CANNOT have the Pi3 online when testing GPSD or NMEA, the results are false readings. Disconnect power to the Pi3, unplug the network cable, wait for the residual memory to clear, then apply power. The time will reset to whatever and WILL NOT COME BACK unless it is given an internet connection, PERIOD. This is not SYSTEM TIME, this is the time setting on the MOUNT location tab and KSTARS. That is my experience.
6 years 4 months ago #20526

Please Log in or Create an account to join the conversation.

So I spent a few hours on this and finally go it working reliably. You'll receive a link to an updated StellarMateOS image by the end of the day. Do not edit any files, just use the StellarMate Serial Port Assistant tool to add the GPS and then restart your StellarMate afterwards and you should be set.
6 years 4 months ago #20536

Please Log in or Create an account to join the conversation.

  • Posts: 983
  • Thank you received: 375
Why would you say this? The only difference is that without PPS you will not get precision higher than 1s, while with PPS your time precision is around 1us. All the rest would work just fine.

@SparkyHT I read your thread on CHRONY... well done!
The following user(s) said Thank You: Chad Andrist
Last edit: 6 years 4 months ago by Radek Kaczorek.
6 years 4 months ago #20555

Please Log in or Create an account to join the conversation.

Time to create page: 1.126 seconds