FreeBSD/contrib/ntp/ntpd/refclock_mx4200.c
/*
 * mx4200_ref - Reconfigure unit as a reference station at a known position.
 */
Reconfigure unit as a reference station at a known position.
Reconfigure unit as a reference station at a known position .
static void
mx4200_ref(
	struct peer *peer
	)
{
	register struct mx4200unit *up;
	struct refclockproc *pp;
	double minute, lat, lon, alt;
	char lats[16], lons[16];
	char nsc, ewc;
	pp = peer->procptr;
	up = pp->unitptr;
	if (up->moving) return;
	up->log_time    = current_time + SLEEPTIME;
	mx4200_send(peer, "%s,%03d,%03d,%d,%d,,,,,", pmvxg,
	    PMVXG_S_PORTCONF,
	    PMVXG_D_PHV, 
	    0,		
	    2);		
	mx4200_send(peer, "%s,%03d,%d,,%.1f,%.1f,%d,%d,%d,%c,%d",
	    pmvxg, PMVXG_S_INITMODEB,
	    2,		
	    0.1,	
	    0.1,	
	    10,		
	    10,		
	    5,		
	    'U',	
	    0);		
	mx4200_send(peer, "%s,%03d,%c,%c,%c,%d,%d,%d,", pmvxg,
	    PMVXG_S_TRECOVCONF,
	    'K',	
	    'U',	
	    'A',	
	    500,	
	    0,		
	    1);		
	if (up->central_meridian != NOT_INITIALIZED) {
		up->avg_lon += up->central_meridian;
		if (up->avg_lon < -180.0) up->avg_lon += 360.0;
		if (up->avg_lon >  180.0) up->avg_lon -= 360.0;
	}
	if (up->avg_lat >= 0.0) {
		lat = up->avg_lat;
		nsc = 'N';
	} else {
		lat = up->avg_lat * (-1.0);
		nsc = 'S';
	}
	if (up->avg_lon >= 0.0) {
		lon = up->avg_lon;
		ewc = 'E';
	} else {
		lon = up->avg_lon * (-1.0);
		ewc = 'W';
	}
	alt = up->avg_alt;
	minute = (lat - (double)(int)lat) * 60.0;
	snprintf(lats, sizeof(lats), "%02d%02.4f", (int)lat, minute);
	minute = (lon - (double)(int)lon) * 60.0;
	snprintf(lons, sizeof(lons), "%03d%02.4f", (int)lon, minute);
	mx4200_send(peer, "%s,%03d,,,,,%s,%c,%s,%c,%.2f,%d", pmvxg,
	    PMVXG_S_INITMODEA,
	    lats,	
	    nsc,	
	    lons,	
	    ewc,	
	    alt,	
	    1);		
	msyslog(LOG_DEBUG,
	    "mx4200: reconfig to fixed location: %s %c, %s %c, %.2f m",
		lats, nsc, lons, ewc, alt );
}
static void mx4200_ref ( struct peer * peer ) { register struct mx4200unit * up ; struct refclockproc * pp ; double minute , lat , lon , alt ; char lats [ 16 ] , lons [ 16 ] ; char nsc , ewc ; pp = peer -> procptr ; up = pp -> unitptr ; if ( up -> moving ) return ; up -> log_time = current_time + SLEEPTIME ; mx4200_send ( peer , " " , pmvxg , PMVXG_S_PORTCONF , PMVXG_D_PHV , 0 , 2 ) ; mx4200_send ( peer , " " , pmvxg , PMVXG_S_INITMODEB , 2 , 0.1 , 0.1 , 10 , 10 , 5 , ' ' , 0 ) ; mx4200_send ( peer , " " , pmvxg , PMVXG_S_TRECOVCONF , ' ' , ' ' , ' ' , 500 , 0 , 1 ) ; if ( up -> central_meridian != NOT_INITIALIZED ) { up -> avg_lon += up -> central_meridian ; if ( up -> avg_lon < -180.0 ) up -> avg_lon += 360.0 ; if ( up -> avg_lon > 180.0 ) up -> avg_lon -= 360.0 ; } if ( up -> avg_lat >= 0.0 ) { lat = up -> avg_lat ; nsc = ' ' ; } else { lat = up -> avg_lat * ( -1.0 ) ; nsc = ' ' ; } if ( up -> avg_lon >= 0.0 ) { lon = up -> avg_lon ; ewc = ' ' ; } else { lon = up -> avg_lon * ( -1.0 ) ; ewc = ' ' ; } alt = up -> avg_alt ; minute = ( lat - ( double ) ( int ) lat ) * 60.0 ; snprintf ( lats , sizeof ( lats ) , " " , ( int ) lat , minute ) ; minute = ( lon - ( double ) ( int ) lon ) * 60.0 ; snprintf ( lons , sizeof ( lons ) , " " , ( int ) lon , minute ) ; mx4200_send ( peer , " " , pmvxg , PMVXG_S_INITMODEA , lats , nsc , lons , ewc , alt , 1 ) ; msyslog ( LOG_DEBUG , " " , lats , nsc , lons , ewc , alt ) ; }
mx4200_ref - Reconfigure unit as a reference station at a known position.
mx4200_ref - Reconfigure unit as a reference station at a known position .
/* Should never happen! */ /*
	 * Set up to output status information in the near future
	 */ /*
	 * "007" Control Port Configuration
	 * Stop outputting "021" position, height, velocity reports
	 */ /* control port output block Label */ /* clear current output control list (0=no) */ /* add/delete sentences from list (2=delete) */ /* must be null */ /* sentence output rate (sec) */ /* precision for position output */ /* nmea version for cga & gll output */ /* pass-through control */ /*
	 * "001" Initialization/Mode Control, Part B
	 * Put receiver in fully-constrained 2d nav mode
	 */ /* 2d nav */ /* reserved */ /* hor accel fact as per Steve (m/s**2) */ /* ver accel fact as per Steve (m/s**2) */ /* vdop */ /* hdop limit as per Steve */ /* elevation limit as per Steve (deg) */ /* time output mode (UTC) */ /* local time offset from gmt (HHHMM) */ /*
	 * "023" Time Recovery Configuration
	 * Get UTC time from a stationary receiver.  Solve for time only.
	 * This should improve the time resolution dramatically.
	 */ /* known position: solve for time only */ /* synchronize to UTC */ /* always output a time pulse */ /* max time error in ns */ /* user bias in ns */ /* output "830" sentences to control port */ /* Multi-satellite mode */ /*
	 * "000" Initialization/Mode Control - Part A
	 * Fix to our averaged position.
	 */ /* day of month */ /* month of year */ /* year */ /* gmt */ /* latitude   DDMM.MMMM */ /* north/south */ /* longitude DDDMM.MMMM */ /* east/west */ /* Altitude */ /* Altitude Reference (0=WGS84 ellipsoid, 1=MSL geoid)*/