# HG changeset patch # User Brett Gordon # Date 1479853679 18000 # Node ID 7702bb8a82161640097d4a74f3a66db33d842c25 # Parent f8226a33698d152d9028f03b86850e20a2ef4c57 Add transactional delay in lwwire_write() This value could be smaller, but some laggy usb uarts work better at 50us. diff -r f8226a33698d -r 7702bb8a8216 src/lwwire.c --- 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);