Mercurial > hg > index.cgi
changeset 13:7702bb8a8216
Add transactional delay in lwwire_write()
This value could be smaller, but some laggy usb uarts work better at
50us.
author | Brett Gordon |
---|---|
date | Tue, 22 Nov 2016 17:27:59 -0500 |
parents | f8226a33698d |
children | e4d98cbf95eb |
files | src/lwwire.c |
diffstat | 1 files changed, 17 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lwwire.c Fri Nov 18 19:51:43 2016 -0700 +++ b/src/lwwire.c Tue Nov 22 17:27:59 2016 -0500 @@ -566,7 +566,23 @@ int rv; fd_set fdset; struct timeval timeout; - + struct timespec sltime; + struct timespec rtime; + + + // Sleep for 50us to client has time to start + // listening + sltime.tv_sec = 0; + sltime.tv_nsec = 50000; + while (nanosleep(&sltime, &rtime) < 0) + { + // anything other than EINTR indicates something seriously messed up + if (errno != EINTR) + return -1; + sltime = rtime; + } + + while (towrite > 0) { rv = write(1, buf, towrite);