[LinuxPPS] 17Jun Patch
Rodolfo Giometti
giometti at enneenne.com
Tue Jun 24 08:37:54 CEST 2008
On Sun, Jun 22, 2008 at 11:50:21PM -0600, clemens at dwf.com wrote:
>
> OK, I retract my previous posting.
> the 17Jun patch seems to work fine.
Great. I'll prepare an official patch soon. :)
> I have multiple GPS units, and the one I was connected to had hung.
> That doesnt happen often, but it happens.
Do you think it could be LinuxPPS related?
> In any case I power cycled it and all is well, the patch seems to work fine.
> (this is with the IRQ code on)
Can you please test also the «IRQ code off» case?
On Mon, Jun 23, 2008 at 06:34:19AM +0000, Cirilo Bernardo wrote:
> On Mon, Jun 23, 2008 at 6:00 AM, <clemens at dwf.com> wrote:
> > The important point here is that the line discipline change only stay
> > effective as long as /dev/ttyS0 (or whatever) stays open.
> >
> > You can't just do ttyctrl (without -X) as the line discipline gets set, then
> > goes away. But I consider it ugly having ttyctrl hanging forever (with -X),
> > and it would be worse to add code to ntpd to do this 'more elegantly'.
> >
> > What I would suggest would be a third option for ttyctrl, in addition to
> > (nothing) and (-X). Perhaps even -X <number> but thats really not necessary,
> > just an option so that the program hangs for say 60seconds and then drops
> > away. Thats more than enough time for ntpd to start and open the device
> > /dev/ttyS0, and it would get rid of this 'thing' that people are going to
> > notice and ask about. ttyctrl could then be part of the startup script for
> > ntpd, rather than a once only thing.
> >
> > I could do that, but it would be nice if we were all playing with the same
> > set of subroutines.
> >
>
> As ugly as it may be, I think the ntpd start script will have to
> change the ldisc on 'start' and switch it back to N_TTY on 'stop'. I
> can't recall if the NTPD code itself ever checks what the ldisc is.
>
> Another possible option is to have a PPS-ldisc related callback for
> pps_core to call when a pps device is opened; the callback can be used
> to set N_PPS on the first open and N_TTY when the last reference is
> closed. If the device does not need ldisc support, it simply uses a
> 'NULL' for the callback pointer. This would be the most transparent
> method and the best if it can be implemented cleanly. The pppd code
> does something similar (except of course that is a userspace program,
> while the PPS thing would be in kernel space).
This is not possible.
Lines discipline work as follow:
1) At serial port open the default ldisc is N_TTY. At close the
currently selected ldisc is switched automagically to N_TTY again.
2) The only one that may select the ldisc is the only one that needs
it: that is NTPD. You should modify the NTPD code in order to call
something like:
#ifdef N_PPS
ldisc = N_PPS;
ret = ioctl(fd, TIOCSETD, &ldisc);
if (ret < 0) {
P_WARN("unable to set line discipline \"%d\" for device \"%s\" (%m)", ldisc, dev);
P_WARN("hope it's ok...");
}
#endif
after accessing the serial port and before accessing the PPS device.
NTPD guys should accept it since line disciplines are across several
UNIX implementation:
http://en.wikibooks.org/wiki/Serial_Programming:Unix/V7#Line_Discipline
Ciao,
Rodolfo
--
GNU/Linux Solutions e-mail: giometti at enneenne.com
Linux Device Driver giometti at linux.it
Embedded Systems phone: +39 349 2432127
UNIX programming skype: rodolfo.giometti
More information about the LinuxPPS
mailing list