static void read_sample(int sockfd, int event, void *anything) { struct sock_sample sample; RCL_Instance instance; int s; instance = (RCL_Instance)anything; s = recv(sockfd, &sample, sizeof (sample), 0); if (s < 0) { LOG(LOGS_ERR, LOGF_Refclock, "Could not read SOCK sample : %s", strerror(errno)); return; } if (s != sizeof (sample)) { LOG(LOGS_WARN, LOGF_Refclock, "Unexpected length of SOCK sample : %d != %ld", s, (long)sizeof (sample)); return; } if (sample.magic != SOCK_MAGIC) { LOG(LOGS_WARN, LOGF_Refclock, "Unexpected magic number in SOCK sample : %x != %x", sample.magic, SOCK_MAGIC); return; } if (sample.pulse) { RCL_AddPulse(instance, &sample.tv, sample.offset); } else { RCL_AddSample(instance, &sample.tv, sample.offset, sample.leap); } }
static int shm_poll(RCL_Instance instance) { struct timeval tv; struct shmTime t, *shm; double offset; shm = (struct shmTime *)RCL_GetDriverData(instance); t = *shm; if ((t.mode == 1 && t.count != shm->count) || !(t.mode == 0 || t.mode == 1) || !t.valid) { DEBUG_LOG(LOGF_Refclock, "SHM sample ignored mode=%d count=%d valid=%d", t.mode, t.count, t.valid); return 0; } shm->valid = 0; tv.tv_sec = t.receiveTimeStampSec; tv.tv_usec = t.receiveTimeStampUSec; offset = t.clockTimeStampSec - t.receiveTimeStampSec; if (t.clockTimeStampNSec / 1000 == t.clockTimeStampUSec && t.receiveTimeStampNSec / 1000 == t.receiveTimeStampUSec) offset += (t.clockTimeStampNSec - t.receiveTimeStampNSec) * 1e-9; else offset += (t.clockTimeStampUSec - t.receiveTimeStampUSec) * 1e-6; return RCL_AddSample(instance, &tv, offset, t.leap); }
static void read_sample(void *anything) { struct sock_sample sample; RCL_Instance instance; int sockfd, s; instance = (RCL_Instance)anything; sockfd = (long)RCL_GetDriverData(instance); s = recv(sockfd, &sample, sizeof (sample), 0); if (s < 0) { #if 0 LOG(LOGS_INFO, LOGF_Refclock, "Error reading from SOCK socket : %s", strerror(errno)); #endif return; } if (s != sizeof (sample)) { #if 0 LOG(LOGS_INFO, LOGF_Refclock, "Unexpected length of SOCK sample : %d != %d", s, sizeof (sample)); #endif return; } if (sample.magic != SOCK_MAGIC) { #if 0 LOG(LOGS_INFO, LOGF_Refclock, "Unexpected magic number in SOCK sample : %x != %x", sample.magic, SOCK_MAGIC); #endif return; } if (sample.pulse) { RCL_AddPulse(instance, &sample.tv, sample.offset); } else { RCL_AddSample(instance, &sample.tv, sample.offset, sample.leap); } }