forked from sysmocom/gpsdate
Allow user to specify a non-standard gpsd port
.. which is required on the ODU.
This commit is contained in:
parent
75cbc3d0e5
commit
019d2535b6
10
gpsdate.c
10
gpsdate.c
|
@ -168,6 +168,7 @@ enum state {
|
|||
int main(int argc, char **argv)
|
||||
{
|
||||
char *host = "localhost";
|
||||
char *port = DEFAULT_GPSD_PORT;
|
||||
int num_retries = NUM_RETRIES;
|
||||
int retry_sleep = RETRY_SLEEP;
|
||||
int i, rc;
|
||||
|
@ -199,14 +200,16 @@ int main(int argc, char **argv)
|
|||
}
|
||||
|
||||
if (optind < argc)
|
||||
host = argv[optind];
|
||||
host = argv[optind++];
|
||||
if (optind < argc)
|
||||
port = argv[optind++];
|
||||
|
||||
/* attempt up to NUM_RETRIES times to connect to gpsd while we are
|
||||
* still running in foreground. The idea is that we will block the
|
||||
* boot process (init scripts) until we have a connection */
|
||||
for (i = 1; i <= num_retries; i++) {
|
||||
printf("Attempt #%d to connect to gpsd at %s...\n", i, host);
|
||||
rc = attempt_reconnect(host, DEFAULT_GPSD_PORT, &gpsdata);
|
||||
rc = attempt_reconnect(host, port, &gpsdata);
|
||||
if (rc >= 0)
|
||||
break;
|
||||
sleep(retry_sleep);
|
||||
|
@ -236,8 +239,7 @@ int main(int argc, char **argv)
|
|||
}
|
||||
break;
|
||||
case S_RECONNECT:
|
||||
rc = attempt_reconnect(host, DEFAULT_GPSD_PORT,
|
||||
&gpsdata);
|
||||
rc = attempt_reconnect(host, port, &gpsdata);
|
||||
if (rc < 0)
|
||||
sleep(RETRY_SLEEP);
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue