"Fossies" - the Fresh Open Source Software Archive

Member "PPSkit-2.1.7/PPSspy.pl" (21 Mar 2003, 2012 Bytes) of package /linux/misc/old/PPSkit-2.1.7.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/usr/bin/perl -w
    2 # Display PPS debugging info by reading variables from kernel using /proc
    3 # $Id: PPSspy.pl,v 1.2 2003/03/21 22:09:55 windl Exp $
    4 # Copyright (c) 2003 by Ulrich Windl <Ulrich.Windl@rz.uni-regensburg.de>
    5 use strict;
    6 local *PPS;
    7 my $ppsinfo = "/proc/sys/kernel/time/pps";
    8 my $last_line = '';
    9 my $line;
   10 my @vals;
   11 
   12 warn "$ppsinfo is an unofficial interface that may be\n";
   13 warn "removed or changed any time!\n";
   14 if (open(PPS, "<$ppsinfo")) {
   15     while (seek(PPS, 0, 0) && read(PPS, $line, 512) > 0) {
   16     select(undef, undef, undef, 0.25), next
   17         if ($line eq $last_line);
   18     @vals = split("\t", $line);
   19 
   20     my @tf;
   21     my ($freq, $lastfreq, $fcount, $jitter, $stabil, $lastsec);
   22     my ($valid, $shift, $shiftmax, $intcnt);
   23     my ($calcnt, $jitcnt, $stbcnt, $errcnt);
   24     my ($fmin, $fmax, $frange);
   25 
   26     foreach (1..3) {
   27         push(@tf, $vals[0] + $vals[1] * 1e-9); splice(@vals, 0, 2);
   28     }
   29     print "tf[]=", join(", ", map { sprintf("%20.9f", $_) } @tf), "\n";
   30 
   31     $freq = abs($vals[1]) + $vals[0] / 2**32;
   32     $freq = -$freq if ($vals[1] < 0);
   33     splice(@vals, 0, 2);
   34     $lastfreq = shift(@vals);
   35     $fcount = shift(@vals);
   36     printf("freq=%15.10f, lastfreq=$lastfreq, fcount=$fcount\n",
   37            $freq / 1000);
   38 
   39     $jitter = shift(@vals);
   40     $stabil = shift(@vals);
   41     $lastsec = shift(@vals);
   42     print "jitter=$jitter, stabil=$stabil, lastsec=$lastsec\n";
   43 
   44     $valid = shift(@vals);
   45     $shift = shift(@vals);
   46     $shiftmax = shift(@vals);
   47     $intcnt = shift(@vals);
   48     print "valid=$valid, shift=$shift, shiftmax=$shiftmax, intcnt=$intcnt\n";
   49     $calcnt = shift(@vals);
   50     $jitcnt = shift(@vals);
   51     $stbcnt = shift(@vals);
   52     $errcnt = shift(@vals);
   53     print "calcnt=$calcnt, jitcnt=$jitcnt, stbcnt=$stbcnt, errcnt=$errcnt\n";
   54 
   55     $fmin = shift(@vals) / 1000;
   56     $fmax = shift(@vals) / 1000;
   57     $frange = shift(@vals) / 1000;
   58     printf("Linux: fmin=%8.3f, fmax=%8.3f, frange=%8.3f\n",
   59            $fmin, $fmax, $frange);
   60 
   61     print join(",", @vals), "\n";   # should be empty line
   62     $last_line = $line;
   63     }
   64     close(PPS);
   65 } else {
   66     die "cannot open $ppsinfo: $!\n";
   67 }