Sharing the GPS NMEA String with NTP

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?

Ozean

Posted 2016-06-17T19:25:59.140

Reputation: 11

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 – 2016-06-17T20:22:09.107

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 – 2016-06-18T12:57:36.367

You could either modify the NTP code or write your own code to function as a tee. – David Schwartz – 2016-06-18T18:24:24.540

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 – 2016-06-19T11:50:09.523

1Thanks 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 – 2016-06-21T15:47:56.667

@Ozean Please post this solution as an answer to your question for the benefit of future users with the same question. Thanks for contributing to SuperUser. – I say Reinstate Monica – 2016-08-08T15:35:50.673

Answers

-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.

Claude Frantz

Posted 2016-06-17T19:25:59.140

Reputation: 154

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.

– I say Reinstate Monica – 2016-08-08T15:38:14.703