FreeBSD/contrib/ntp/ntpd/refclock_mx4200.c
/*
 * mx4200_start - open the devices and initialize data for processing
 */
open the devices and initialize data for processing
open the devices and initialize data for processing
static int
mx4200_start(
	int unit,
	struct peer *peer
	)
{
	register struct mx4200unit *up;
	struct refclockproc *pp;
	int fd;
	char gpsdev[20];
	snprintf(gpsdev, sizeof(gpsdev), DEVICE, unit);
	fd = refclock_open(gpsdev, SPEED232, LDISC_PPS);
	if (fd <= 0)
		return 0;
	up = emalloc_zero(sizeof(*up));
	pp = peer->procptr;
	pp->io.clock_recv = mx4200_receive;
	pp->io.srcclock = peer;
	pp->io.datalen = 0;
	pp->io.fd = fd;
	if (!io_addclock(&pp->io)) {
		close(fd);
		pp->io.fd = -1;
		free(up);
		return (0);
	}
	pp->unitptr = up;
	peer->precision = PRECISION;
	pp->clockdesc = DESCRIPTION;
	memcpy((char *)&pp->refid, REFID, 4);
	return mx4200_config(peer);
}
static int mx4200_start ( int unit , struct peer * peer ) { register struct mx4200unit * up ; struct refclockproc * pp ; int fd ; char gpsdev [ 20 ] ; snprintf ( gpsdev , sizeof ( gpsdev ) , DEVICE , unit ) ; fd = refclock_open ( gpsdev , SPEED232 , LDISC_PPS ) ; if ( fd <= 0 ) return 0 ; up = emalloc_zero ( sizeof ( * up ) ) ; pp = peer -> procptr ; pp -> io . clock_recv = mx4200_receive ; pp -> io . srcclock = peer ; pp -> io . datalen = 0 ; pp -> io . fd = fd ; if ( ! io_addclock ( & pp -> io ) ) { close ( fd ) ; pp -> io . fd = -1 ; free ( up ) ; return ( 0 ) ; } pp -> unitptr = up ; peer -> precision = PRECISION ; pp -> clockdesc = DESCRIPTION ; memcpy ( ( char * ) & pp -> refid , REFID , 4 ) ; return mx4200_config ( peer ) ; }
mx4200_start - open the devices and initialize data for processing
mx4200_start - open the devices and initialize data for processing
/*
	 * Open serial port
	 */ /*
	 * Allocate unit structure
	 */ /*
	 * Initialize miscellaneous variables
	 */ /* Ensure the receiver is properly configured */