diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2005-07-28 19:21:19 +0000 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2005-07-28 19:21:19 +0000 |
commit | fa9132eb612cf6ab144838bded8996fcc24b9dea (patch) | |
tree | 21bf36215cef5bb80f57f18e39aabfa3c92536d6 /sirfmon.c | |
parent | c97bd780629d08ad7194887cf3b4b8be8adcc0e3 (diff) | |
download | gpsd-fa9132eb612cf6ab144838bded8996fcc24b9dea.tar.gz |
More visible hunting as Wolfgang Rupprecht suggested.
Diffstat (limited to 'sirfmon.c')
-rw-r--r-- | sirfmon.c | 19 |
1 files changed, 10 insertions, 9 deletions
@@ -142,6 +142,7 @@ static int nmea_send(int fd, const char *fmt, ... ) va_end(ap); strcat(buf, "*"); nmea_add_checksum(buf); + fputs(buf, stderr); /* so user can watch the baud hunt */ status = (size_t)write(fd, buf, strlen(buf)); if (status == strlen(buf)) { return (int)status; @@ -663,7 +664,7 @@ static unsigned int *ip, rates[] = {0, 4800, 9600, 19200, 38400, 57600}; static unsigned int hunt_open(unsigned int *pstopbits) { unsigned int trystopbits; - int st; + int st, retries; /* * Tip from Chris Kuethe: the FTDI chip used in the Trip-Nav * 200 (and possibly other USB GPSes) gets completely hosed @@ -677,15 +678,15 @@ static unsigned int hunt_open(unsigned int *pstopbits) for (trystopbits = 1; trystopbits <= 2; trystopbits++) { *pstopbits = trystopbits; for (ip = rates; ip < rates + sizeof(rates)/sizeof(rates[0]); ip++) - { - if ((st = set_speed(*ip, trystopbits)) == SIRF_PACKET) - return get_speed(&ttyset); - else if (st == NMEA_PACKET) { - (void)fprintf(stderr, "Switching to SiRF mode...\n"); - (void)nmea_send(controlfd,"$PSRF100,0,%d,8,1,0", *ip); - return *ip; + for (retries = 10; retries; retries--) { + if ((st = set_speed(*ip, trystopbits)) == SIRF_PACKET) + return get_speed(&ttyset); + else if (st == NMEA_PACKET) { + (void)fprintf(stderr, "Switching to SiRF mode...\n"); + (void)nmea_send(controlfd,"$PSRF100,0,%d,8,1,0", *ip); + usleep(10000); + } } - } } return 0; } |