diff options
author | Gary E. Miller <gem@rellim.com> | 2016-08-15 16:53:40 -0700 |
---|---|---|
committer | Gary E. Miller <gem@rellim.com> | 2016-08-15 16:53:40 -0700 |
commit | e67e4118a0cbb5b5cecc62e7440299d0b5b35a37 (patch) | |
tree | 9aa35686f7b499ae7afd75e6b8b1f25a2aedfb32 /contrib/motosend.c | |
parent | 1721d7c431aeb471dcd3e36b09c4a432eb31dc5e (diff) | |
download | gpsd-e67e4118a0cbb5b5cecc62e7440299d0b5b35a37.tar.gz |
usleep() is removed from POSIX-2008. Replace with nanosleep()
I sure hope I did not drop a zero anywhere...
Diffstat (limited to 'contrib/motosend.c')
-rw-r--r-- | contrib/motosend.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/contrib/motosend.c b/contrib/motosend.c index 30731588..a3202dab 100644 --- a/contrib/motosend.c +++ b/contrib/motosend.c @@ -31,6 +31,7 @@ int main(int argc, char **argv) { struct termios term; char buf[BSIZ]; time_t s, t; + struct timespec delay; if (argc != 5){ fprintf(stderr, "usage: motosend <speed> <port> msgtype moto-body-hex\n"); @@ -82,8 +83,12 @@ int main(int argc, char **argv) { tcflush(fd, TCIOFLUSH); t = 0; n = 0; while (1){ - usleep(1000); - bzero(buf, BSIZ); + /* wait 1,000 uSec */ + delay.tv_sec = 0; + delay.tv_nsec = 1000000L; + nanosleep(&delay, NULL); + + bzero(buf, BSIZ); if ((l = read(fd, buf, BSIZ)) == -1) if (!(EINTR == errno || EAGAIN == errno)) err(1, "read"); |