gpsd-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gpsd-users] Issue (bug) in the PPS detection code


From: Sidney Cadot
Subject: [gpsd-users] Issue (bug) in the PPS detection code
Date: Wed, 14 Nov 2012 11:02:37 +0100

Hi all,

I found an issue in the PPS-handling code of GPSD version 3.7.

In line 638 of ntpshm.c, the bit mask "PPS_LINE_TIOC" is defined that
specifies all serial lines to be monitored for potential PPS.

In line 726, the "state" is requested via ioctl(). Then, line 732 does this:

    state = (int)((state & PPS_LINE_TIOC) != 0);

This effectively ORs all the bits specified in the PPS_LINE_TIOC
variable into a single bit. This single bit is then monitored for
changes and is a candidate PPS.

The problem is this: line 732 quietly assumes that the non-PPS bits in
the masks are fixed to zero (otherwise, the OR will always yield 1).

However, I am currently looking at a platform where the RING and DCD
bits are fixed to 1. This means that state will never be anything
other that 1, which prevents the PPS (that's incoming on the CTS line
in my case) from being used.

A better way of handling this, I think, would be to let 'state' and
'last_state' reflect the state off ALL bits in the PPS_LINE_MASK, and
do something like:

    any_rising_edge  = (~last_state &  state) != 0;
    any_falling_edge = ( last_state & ~state) != 0;

... and then work with those.

Regards, Sidney



reply via email to

[Prev in Thread] Current Thread [Next in Thread]