summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorChris Kuethe <chris.kuethe@gmail.com>2008-12-29 16:40:22 +0000
committerChris Kuethe <chris.kuethe@gmail.com>2008-12-29 16:40:22 +0000
commitc4b78a11c26895408871aa21a1b2c1569818eb64 (patch)
treef6b65298d04fefeacb9a078d083f8a603cb25e7a /contrib
parentf18a568fe26a30c9557e4133152e642383583f47 (diff)
downloadgpsd-c4b78a11c26895408871aa21a1b2c1569818eb64.tar.gz
garreset: for un-shooting your gps18 in the foot. ;)
Diffstat (limited to 'contrib')
-rw-r--r--contrib/README3
-rw-r--r--contrib/garreset.c34
2 files changed, 37 insertions, 0 deletions
diff --git a/contrib/README b/contrib/README
index 4432ac42..12af0b7d 100644
--- a/contrib/README
+++ b/contrib/README
@@ -51,3 +51,6 @@ screen plugged in and configured to work with lcdproc).
lla2ecef transforms latitude/longitude/altitude (aka north-east-up or local
tangential plane) coordinates into the earth-centered-earth-fixed frame. If
invoked as "ecef2lla" it will transform coordinates in the opposite manner.
+
+garreset attempts to force a garmin receiver back to NMEA mode - useful for
+recovering a receiver after sending the wrong configuration message.
diff --git a/contrib/garreset.c b/contrib/garreset.c
new file mode 100644
index 00000000..ecbc4c95
--- /dev/null
+++ b/contrib/garreset.c
@@ -0,0 +1,34 @@
+#include <sys/types.h>
+#include <sys/termios.h>
+#include <err.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+char pkt[] = {0x10, 0x0a, 0x02, 0x26, 0x00, 0xce, 0x10, 0x03};
+int speeds[] = {2400, 4800, 9600, 19200, 38400, 57600, 115200};
+
+int
+main(int argc, char **argv){
+ int fd, i, n;
+ struct termios t;
+
+ if ((fd = open(argv[1], O_RDWR | O_EXCL | O_NONBLOCK, 0600)) == -1)
+ err(1, "open");
+
+ n = sizeof(speeds) / sizeof(speeds[0]);
+ for(i = 0; i < n; i++){
+ tcgetattr(fd, &t);
+ cfmakeraw(&t);
+ cfsetspeed(&t, speeds[i]);
+ tcsetattr(fd, TCSANOW | TCSAFLUSH, &t);
+ fprintf(stderr, "%d ", speeds[i]);
+ if (write(fd, pkt, sizeof(pkt)) != sizeof(pkt))
+ err(1, "write");
+ tcdrain(fd);
+ usleep(333333);
+ }
+ fprintf(stderr, "done.\n");
+ close(fd);
+}