summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Kocialkowski <contact@paulk.fr>2012-08-14 10:45:49 (GMT)
committerPaul Kocialkowski <contact@paulk.fr>2012-08-14 10:45:49 (GMT)
commitd745cfbec3d6acecdd7943a6c2991a164ce03bb8 (patch)
treeee0cc4811ec42343de1897e4698d1bf88fd63eb7
parentf952dde8f3a29634be1c8fa19b8eed367c1ad878 (diff)
downloadbcm4751-d745cfbec3d6acecdd7943a6c2991a164ce03bb8.zip
bcm4751-d745cfbec3d6acecdd7943a6c2991a164ce03bb8.tar.gz
bcm4751-d745cfbec3d6acecdd7943a6c2991a164ce03bb8.tar.bz2
GPSD: Fix autobaud and avoid select while writing
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
-rw-r--r--bcm4751_gpsd.c21
1 files changed, 6 insertions, 15 deletions
diff --git a/bcm4751_gpsd.c b/bcm4751_gpsd.c
index 6462525..d7cdc9c 100644
--- a/bcm4751_gpsd.c
+++ b/bcm4751_gpsd.c
@@ -203,36 +203,27 @@ int bcm4751_serial_read(int fd, void *data, int length, struct timeval *timeout)
return rc;
}
-int bcm4751_serial_write(int fd, void *data, int length, struct timeval *timeout)
+int bcm4751_serial_write(int fd, void *data, int length)
{
- fd_set fds;
- int rc = -1;
-
- FD_ZERO(&fds);
- FD_SET(fd, &fds);
-
- rc = select(fd + 1, NULL, &fds, NULL, timeout);
- if(rc > 0) {
- rc = write(fd, data, length);
- }
-
- return rc;
+ return write(fd, data, length);
}
int bcm4751_autobaud(int fd)
{
struct timeval timeout;
- uint8_t autobaud[20] = { 0x80 };
+ uint8_t autobaud[20];
int ready = 0;
int rc = -1;
+ memset(autobaud, 0x80, sizeof(autobaud));
+
// TODO: limit the number of attempts
timeout.tv_sec = 1;
timeout.tv_usec = 0;
while(!ready) {
- bcm4751_serial_write(fd, autobaud, sizeof(autobaud), NULL);
+ bcm4751_serial_write(fd, autobaud, sizeof(autobaud));
rc = bcm4751_serial_read(fd, NULL, 0, &timeout);
if(rc > 0)