[LinuxPPS] [LInuxPPS] Oncore error message on Ubuntu 11.04

reg at dwf.com reg at dwf.com
Mon Jul 11 23:21:39 CEST 2011


Sorry I cant be specific, but I haven't rebuilt my kernel under Linux since
2.6.32.9 (or possibly 2.6.35).

But, looking at my code in the ONCORE driver, I have made several calls
to ntpd at this point, so it would seem that you have the appropriate
interface in the kernel.  However, this is the first time that I try to
WRITE to the kernel.

Now that never made any difference in the past, but it seems to now.
I would try running the following piece of code (which is equivalent to 
someting in the linuxPPS library), It needs the arguments

      ppsapitest8 ttyS0 pps0

where the device ttyS0 may be different on your OS,

--------

#include <stdio.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <err.h>
#include <sys/types.h>
#include <time.h>
#include <timepps.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <termios.h>
#include <errno.h>
#include <sys/ioctl.h>

/* PPSAPI test */

void exit();

int
main(int argc, char **argv)
{
	int i, fd2, mode, fd1, ldisc;
	char Msg[200];
	struct stat stat1, stat2;
	u_int olda, oldc;
	pps_info_t pi;
	pps_params_t pp;
	pps_handle_t ph;
	char    *serial, *pps;

	olda = oldc = 0;
	if (argc != 3) {
		fprintf (stderr, "USAGE: <serial tty> <pps>\n");
		exit(1);
	}

	serial = argv[1];
	pps = argv[2];

	if ((fd1=open(serial, B9600, O_RDWR))< 0) {
		fprintf(stderr, "Cant open %s, error = %d\n", serial, fd1);
		perror("aa");
		exit(1);
	}

	i = ioctl(fd1, TIOCGETD, &ldisc);
	fprintf (stderr, "See TIOCGETD, i = %d, ldisc = %d\n", i, ldisc);

	/* can I stat a N_PPS ??? */

	i = stat (serial, &stat1);
	fprintf(stderr, "stat returns %d\n", i);

#define N_PPS 18
	fprintf(stderr, ">>>> Inside ifdef\n");
	/* linuxPPS specific Code */

	stat2.st_dev = stat2.st_ino = -1;
	ldisc = N_PPS;
fprintf(stderr, "Before IOCTL\n");
	if (ioctl(fd1, TIOCSETD, &ldisc)) {

		/* here could not set the line discipline, treat as tty */

		sprintf(Msg, "unable to set line discipline \"%d\" for device %s\n", ldisc, 
serial);
		fprintf(stderr, Msg);
		fprintf(stderr, "hope it's ok\n");
	}

fprintf(stderr, "After IOCTL\n");
	sleep(5);

	if ((fd2=open(pps, O_RDWR)) < 0) {
		fprintf(stderr, "Can't open fd2 (%s)\n", pps);
		exit(1);
	}

fprintf (stderr, "fd2 = %d\n", fd2);
	if ((i = time_pps_create(fd2, &ph)) < 0) {
		fprintf(stderr, "create returns %d\n", i);
		fprintf(stderr, "FAIL: time_pps_create\n");
		exit(1);
	}

/***************************************/

	if ((i = time_pps_getcap(ph, &mode)) < 0) {
		printf("FAIL: getcap %d\n", i);
		exit(1);
	}

	printf("getcap says 0x%x\n", mode);

/***************************************/

	if ((i = time_pps_getparams(ph, &pp)) <0) {
		printf("time_pps_getparams\n");
		perror("getparams:");
		exit (1);
	}

	printf("getparam is 0x%x\n", pp.mode);

/***************************************/

	mode =        PPS_CAPTURECLEAR ;     /* */
	pp.mode = mode;

	printf("set mode to 0x%x\n", pp.mode);

	if ((i = time_pps_setparams(ph, &pp)) <0) {
		printf("time_pps_setparams\n");
		perror("setparams:");
		exit (1);
	}

	if ((i = time_pps_getparams(ph, &pp)) <0) {
		printf("time_pps_getparams\n");
		perror("getparams:");
		exit (1);
	}

	printf("getparam is 0x%x\n", pp.mode);

/***************************************/

	mode =        PPS_CAPTUREBOTH  ;     /* */
	pp.mode = mode;

	printf("set mode to 0x%x\n", pp.mode);

	if ((i = time_pps_setparams(ph, &pp)) <0) {
		printf("time_pps_setparams\n");
		perror("setparams:");
		exit (1);
	}

	if ((i = time_pps_getparams(ph, &pp)) <0) {
		printf("time_pps_getparams\n");
		perror("getparams:");
		exit (1);
	}

	printf("getparam is 0x%x\n", pp.mode);

/***************************************/
	printf("Enter loop\n\n");

	while (1) {
		i = time_pps_fetch(ph, PPS_TSFMT_TSPEC, &pi, NULL);
		if (i < 0) {
			err(1, "time_pps_fetch");
			perror("fetch:");
		}

		if (olda != pi.assert_sequence || oldc != pi.clear_sequence) {
			if ((i = time_pps_getparams(ph, &pp)) <0) {
				printf("time_pps_getparams\n");
				perror("getparams:");
				exit (1);
			}
			printf("getparam is 0x%x\n", pp.mode);
			printf("getparam assert is %ld  %07ld\n", pp.assert_offset.tv_sec, 
pp.assert_offset.tv_nsec);
			printf("getparam clear  is %ld  %07ld\n", pp.clear_offset.tv_sec, 
pp.clear_offset.tv_nsec);

			printf("A: %lu.%09ld #%lu     C: %lu.%09ld #%lu\n",
			    pi.assert_timestamp.tv_sec,
			    pi.assert_timestamp.tv_nsec,
			    pi.assert_sequence,

			    pi.clear_timestamp.tv_sec,
			    pi.clear_timestamp.tv_nsec,
			    pi.clear_sequence);

			olda = pi.assert_sequence;
			oldc = pi.clear_sequence;
		}
	}

	exit(0);
}


--------------]

It should help us point directly at the problem.

-- 
                                        Reg.Clemens
                                        reg at dwf.com





More information about the LinuxPPS mailing list