Пример #1
0
void ntpshm_link_activate(struct gps_device_t *session)
/* set up ntpshm storage for a session */
{
    /* allocate a shared-memory segment for "NMEA" time data */
    session->shmIndex = ntpshm_alloc(session->context);

    if (0 > session->shmIndex) {
	gpsd_report(&session->context->errout, LOG_INF, 
                    "NTPD ntpshm_alloc() failed\n");
#if defined(PPS_ENABLE)
    } else if (session->sourcetype == source_usb || session->sourcetype == source_rs232) {
	/* We also have the 1pps capability, allocate a shared-memory segment
	 * for the 1pps time data and launch a thread to capture the 1pps
	 * transitions
	 */
	if ((session->shmIndexPPS = ntpshm_alloc(session->context)) < 0) {
	    gpsd_report(&session->context->errout, LOG_INF, 
                        "NTPD ntpshm_alloc(1) failed\n");
	} else {
	    init_hook(session);
	    session->thread_report_hook = report_hook;
	    session->thread_wrap_hook = wrap_hook;
	    pps_thread_activate(session);
	}
#endif /* PPS_ENABLE */
    }
}
Пример #2
0
void ntpshm_link_activate(struct gps_device_t *session)
/* set up ntpshm storage for a session */
{
    /* don't talk to NTP when we're running inside the test harness */
    if (session->sourcetype == source_pty)
	return;

    if (session->sourcetype != source_pps ) {
	/* allocate a shared-memory segment for "NMEA" time data */
	session->shm_clock = ntpshm_alloc(session->context);

	if (session->shm_clock == NULL) {
	    gpsd_log(&session->context->errout, LOG_WARN,
		     "NTP: ntpshm_alloc() failed\n");
	    return;
        }
    }

#if defined(PPS_ENABLE)
    if (session->sourcetype == source_usb
            || session->sourcetype == source_rs232
            || session->sourcetype == source_pps) {
	/* We also have the 1pps capability, allocate a shared-memory segment
	 * for the 1pps time data and launch a thread to capture the 1pps
	 * transitions
	 */
	if ((session->shm_pps = ntpshm_alloc(session->context)) == NULL) {
	    gpsd_log(&session->context->errout, LOG_WARN,
		     "PPS: ntpshm_alloc(1) failed\n");
	} else {
	    init_hook(session);
	    session->pps_thread.report_hook = report_hook;
	    /*
	     * The HAT kludge. If we're using the HAT GPS on a
	     * Raspberry Pi or a workalike like the ODROIDC2, and
	     * there is a static /dev/pps0, and we have access because
	     * we're root, assume we want to use KPPS.
	     */
	    if ((strcmp(session->pps_thread.devicename, MAGIC_HAT_GPS) == 0
		 || strcmp(session->pps_thread.devicename, MAGIC_LINK_GPS) == 0)
		&& access("/dev/pps0", R_OK | W_OK) == 0)
		session->pps_thread.devicename = "/dev/pps0";
	    pps_thread_activate(&session->pps_thread);
	}
    }
#endif /* PPS_ENABLE */
}