[LinuxPPS] refclock jupiter patch

Rodolfo Giometti giometti at enneenne.com
Tue Mar 25 18:28:31 CET 2008


On Tue, Mar 25, 2008 at 06:15:45PM +0100, LICHTENBERGER János wrote:
> Sorry, here is the patch just for refclock_jupiter.c 

Ok, I suppose the patch has - and + swapped! :P

However, below my comments.

> --- refclock_jupiter.c	2008-03-25 18:13:09.344301159 +0100
> +++ /u/local/linux/gps/ntp/ntp-4.2.4p4/ntpd/refclock_jupiter.c	2006-12-28 13:03:46.000000000 +0100
> @@ -37,7 +37,6 @@
>  
>  #if defined(REFCLOCK) && defined(CLOCK_JUPITER) && defined(HAVE_PPSAPI)
>  
> -

Not needed. Please remove it.

>  #include "ntpd.h"
>  #include "ntp_io.h"
>  #include "ntp_refclock.h"
> @@ -82,7 +81,6 @@
>   * GPS Definitions
>   */
>  #define	DEVICE		"/dev/gps%d"	/* device name and unit */
> -#define DEVICEPPS	"/dev/pps%d"

Please, use TABs.

>  #define	SPEED232	B9600		/* baud */
>  
>  /*
> @@ -173,7 +171,6 @@
>  	NOFLAGS			/* not used */
>  };
>  
> -

Ditto.

>  /*
>   * jupiter_start - open the devices and initialize data for processing
>   */
> @@ -233,38 +230,13 @@
>  	 * Start the PPSAPI interface if it is there. Default to use
>  	 * the assert edge and do not enable the kernel hardpps.
>  	 */
> -	if (time_pps_create(pp->io.fd, &instance->pps_handle) < 0) {
> -		/* Try the alternate PPS device */
> -		(void) sprintf(gpsdev, DEVICEPPS, unit);
> -		msyslog(LOG_ERR, "refclock_jupiter: try alternate PPS device \"%s\"", gpsdev);
> -		fd = open (gpsdev, O_RDWR);
> -    		if (fd < 0) {
> -		    msyslog(LOG_ERR, "refclock_jupiter: Error open PPS device \"%s\"", gpsdev);
> -		    goto pps_error;
> -		}
> -		if (time_pps_create(fd, &instance->pps_handle) < 0) {
> -			instance->pps_handle = 0;
> -			msyslog(LOG_ERR,"refclock_jupiter: time_pps_create failed: %m");
> -			goto pps_error;
> -		}
> -		else if (!jupiter_ppsapi(instance)){
> -		    msyslog(LOG_ERR, "refclock_jupiter: Error after found alternate PPS device");
> -
> -		    goto clean_up;
> -		}
> -
> +	if (time_pps_create(fd, &instance->pps_handle) < 0) {
> +		instance->pps_handle = 0;
> +		msyslog(LOG_ERR,
> +			"refclock_jupiter: time_pps_create failed: %m");
>  	}
> -	else {
> -	    (void) sprintf(gpsdev, DEVICE, unit);
> -	    msyslog(LOG_ERR, "refclock_jupiter: found PPS source \"%s\"", gpsdev);
> -	    
> -	    if (!jupiter_ppsapi(instance)){
> -		msyslog(LOG_ERR, "refclock_jupiter: Error after found primary PPS device");
> -	    
> +	else if (!jupiter_ppsapi(instance))
>  		goto clean_up;
> -	    }
> -	}
> -	
>  #endif /* HAVE_PPSAPI */

The code inside the if/else is duplicated, please use goto instead for
better readability.

>  
>  	/* Ensure the receiver is properly configured */
> @@ -272,7 +244,7 @@
>  		goto clean_up;
>  
>  	return (1);
> -pps_error:
> +
>  clean_up:
>  	jupiter_shutdown(unit, peer);
>  	pp->unitptr = 0;
> @@ -588,7 +560,6 @@
>  		switch (getshort(hp->id)) {
>  
>  		case JUPITER_O_PULSE:
> -		

Ditto.

>  			if (size != sizeof(struct jpulse)) {
>  				jupiter_debug(peer,
>  				    "jupiter_receive", "pulse: len %d != %u",
> @@ -597,7 +568,6 @@
>  				break;
>  			}
>  
> -

Ditto.

>  			/*
>  			 * There appears to be a firmware bug related
>  			 * to the pulse message; in addition to the one

Please, fix up the patch and provide a patch also for the wiki (see
here http://wiki.enneenne.com/index.php/LinuxPPS_support#How_to_contribute)
so I can add it quickly to the LinuxPPS project! ;)

Ciao,

Rodolfo

-- 

GNU/Linux Solutions                  e-mail:    giometti at enneenne.com
Linux Device Driver                             giometti at gnudd.com
Embedded Systems                     		giometti at linux.it
UNIX programming                     phone:     +39 349 2432127



More information about the LinuxPPS mailing list