1

I am using GPS as a clock for NTP. It works great and NTP opens /dev/gps0 and reads it fine. I also have a program that can open /dev/gps0 to read (and write) to the GPS device so I can process the information and configure it. How can I run both at the same time?

I do not want to use gpsd and I would like to find some way to share the serial port without doing something that could break NTP. Socat, pseudo terminal? How can I accomplish this easily?

  • NTP supports a software clock that communicates with NTP using shared memory. If your GPS software can put time information into shared memory, NTP can get it. Here is some example code I wrote ages ago. – David Schwartz Jun 17 '16 at 20:22
  • I have actually done this before with shared memory (gpsd also uses shared memory). The issue is the "customer" wants NTP to run and then wants a second program that can "tap into" the serial device as needed. I was thinking of posix_openpt, but was wondering if there was some better way. – Ozean Jun 18 '16 at 12:57
  • You could either modify the NTP code or write your own code to function as a tee. – David Schwartz Jun 18 '16 at 18:24
  • depending on the machine you could install another physical serial port then use one for nema and pps the other as a serial port then as others have indicated use the shares memory driver from ntp. – user3788685 Jun 19 '16 at 11:50
  • 1
    Thanks for the help. I solved this by opening pseudo-terminals, for for ntp and one for the process that parses the nmea strings. i.e. ntpfd = posix_openpt(O-RDWR | O_NOCTTY); grantpt(ntpfd); unlockpt(ntpfd); ptsname_r(ntpfd, buff, sizeof(buff)). Buff holds the name of the pseudo-terminal. Same for parserfd, I then open and read the gps and send what I get to these fd's. Linked the pseudo-terminal associated with ntpfd to /dev/gps0. – Ozean Jun 21 '16 at 15:47
-1

I ignore the reason why you do not wand to use gpsd. Myself, I suggest you to use it because this probably the simplest solution. If you want to have access to the NMEA sentences, use the program "gpspipe" while gpsd is running. You will probably have what you want.

  • Welcome to Super User. Your post needs to be expanded. A good answer includes specific instructions (not just links to them) and an explanation as to how or why the answer addresses the OPs question. Please edit your post to add detail explaining how your solution addresses the OPs question. – Twisty Impersonator Aug 8 '16 at 15:38

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.