*** refclock_nmea.c.orig 2003-07-17 06:27:29.000000000 -0400 --- refclock_nmea.c 2003-11-25 21:02:25.000000000 -0500 *************** *** 23,28 **** --- 23,30 ---- #include #include + #include + #ifdef HAVE_PPSAPI # ifdef HAVE_TIMEPPS_H # include *************** *** 153,160 **** (void)sprintf(device, DEVICE, unit); fd = refclock_open(device, SPEED232, LDISC_CLK); ! if (fd < 0) ! return (0); /* * Allocate and initialize unit structure --- 155,208 ---- (void)sprintf(device, DEVICE, unit); fd = refclock_open(device, SPEED232, LDISC_CLK); ! if (fd <= 0) { ! #ifdef HAVE_READLINK ! /* nmead support added by Jon Miner (cp_n18@yahoo.com) ! * ! * See http://home.hiwaay.net/~taylorc/gps/nmea-server/ ! * for information about nmead ! * ! * To use this, you need to create a link from /dev/gpsX to ! * the server:port where nmead is running. Something like this: ! * ! * ln -s server:port /dev/gps1 ! */ ! char buffer[80]; ! char *nmea_host; ! int nmea_port; ! int len; ! struct hostent *he; ! struct protoent *p; ! struct sockaddr_in so_addr; ! socklen_t so_addr_len = sizeof(so_addr); ! ! if ((len = readlink(device,buffer,sizeof(buffer))) == -1) ! return(0); ! buffer[len] = 0; ! ! if ((nmea_host = strtok(buffer,":")) == NULL) ! return(0); ! ! nmea_port = atoi(strtok(NULL,":")); ! ! if ((he = gethostbyname(nmea_host)) == NULL) ! return(0); ! if ((p = getprotobyname("ip")) == NULL) ! return(0); ! so_addr.sin_family = AF_INET; ! so_addr.sin_port = htons(nmea_port); ! so_addr.sin_addr = *((struct in_addr *) he->h_addr); ! ! if ((fd = socket(PF_INET,SOCK_STREAM,p->p_proto)) == -1) ! return(0); ! if (connect(fd,(struct sockaddr *)&so_addr,so_addr_len) == -1) { ! close(fd); ! return (0); ! } ! #else ! return (0); ! #endif ! } /* * Allocate and initialize unit structure