From e67e4118a0cbb5b5cecc62e7440299d0b5b35a37 Mon Sep 17 00:00:00 2001 From: "Gary E. Miller" Date: Mon, 15 Aug 2016 16:53:40 -0700 Subject: usleep() is removed from POSIX-2008. Replace with nanosleep() I sure hope I did not drop a zero anywhere... --- contrib/motosend.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'contrib/motosend.c') 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 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"); -- cgit v1.2.1