ldattach -t for msts line discipline

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

ldattach -t for msts line discipline

Maurice Janssen-2
Hi,

I have a time receiver that sends time information in MSTS format to the
serial port of an OpenBSD system.
The receiver sends 1 PPS pulses on the DCD pin and I'm trying to use
these pulses to increase the accuracy (not that a simple DCF77 receiver
will ever be very accurate, but at least I can try to get the most out
of it).

However, there seem to be no difference when I start ldattach with or
without the -t dcd option.

When reading the source of ldattach.c, I noticed this piece of code:

        /* line discpline specific setup */
        switch (ldisc) {
        case NMEADISC:
        case ENDRUNDISC:
                if (ioctl(fd, TIOCSTSTAMP, &tstamps) < 0) {
                        warnx("TIOCSTSTAMP");
                        goto bail_out;
                }
                tty.c_cflag |= CLOCAL;
                /* FALLTHROUGH */
        case SLIPDISC:
                tty.c_iflag = 0;
                tty.c_lflag = 0;
                tty.c_oflag = 0;
                tty.c_cc[VMIN] = 1;
                tty.c_cc[VTIME] = 0;
                break;
        }


As you can see, MSTSDISC is not mentioned here.  I'm not a programmer
and I don't understand much of this, but it seems odd that MSTSDISC is
missing here.
Does this mean that the -t dcd option has no effect for MSTS?

regards,
Maurice

Reply | Threaded
Open this post in threaded view
|

Re: ldattach -t for msts line discipline

Maurice Janssen-2
On Fri, Aug 01, 2014 at 01:26:46PM +0200, Maurice Janssen wrote:

>Hi,
>
>I have a time receiver that sends time information in MSTS format to
>the serial port of an OpenBSD system.
>The receiver sends 1 PPS pulses on the DCD pin and I'm trying to use
>these pulses to increase the accuracy (not that a simple DCF77
>receiver will ever be very accurate, but at least I can try to get
>the most out of it).
>
>However, there seem to be no difference when I start ldattach with or
>without the -t dcd option.
>
>When reading the source of ldattach.c, I noticed this piece of code:
>
> /* line discpline specific setup */
> switch (ldisc) {
> case NMEADISC:
> case ENDRUNDISC:
> if (ioctl(fd, TIOCSTSTAMP, &tstamps) < 0) {
> warnx("TIOCSTSTAMP");
> goto bail_out;
> }
> tty.c_cflag |= CLOCAL;
> /* FALLTHROUGH */
> case SLIPDISC:
> tty.c_iflag = 0;
> tty.c_lflag = 0;
> tty.c_oflag = 0;
> tty.c_cc[VMIN] = 1;
> tty.c_cc[VTIME] = 0;
> break;
> }
>
>
>As you can see, MSTSDISC is not mentioned here.  I'm not a programmer
>and I don't understand much of this, but it seems odd that MSTSDISC
>is missing here.
>Does this mean that the -t dcd option has no effect for MSTS?
>
>regards,
>Maurice
>

Well, I gave it a try and my msts clock seems to perform much better with
the patch below.
The timedelta has much less jitter and also the delay is smaller.  So
it seems that without the patch below the PPS signal is ignored and
only the msts string on the serial port is used the mark the start of
the second.
Can this be applied to -current?

Thanks,
Maurice


Index: ldattach.c
===================================================================
RCS file: /cvs/src/sbin/ldattach/ldattach.c,v
retrieving revision 1.14
diff -u -p -u -r1.14 ldattach.c
--- ldattach.c 31 Oct 2009 02:53:11 -0000 1.14
+++ ldattach.c 2 Aug 2014 19:03:04 -0000
@@ -272,6 +272,7 @@ main(int argc, char *argv[])
  /* line discpline specific setup */
  switch (ldisc) {
  case NMEADISC:
+ case MSTSDISC:
  case ENDRUNDISC:
  if (ioctl(fd, TIOCSTSTAMP, &tstamps) < 0) {
  warnx("TIOCSTSTAMP");