]> mj.ucw.cz Git - arexx.git/commitdiff
Sleep 1ms between send and receive
authorMartin Mares <mj@ucw.cz>
Sat, 3 Mar 2012 17:38:51 +0000 (18:38 +0100)
committerMartin Mares <mj@ucw.cz>
Sat, 3 Mar 2012 17:38:51 +0000 (18:38 +0100)
Otherwise, some versions of logger firmware can get confused.

arexxd.c

index 0358db145ba9d1d36953c9123f7f71c61918a486..9fcae6e0806963534892ffded8fdcea55befd227 100644 (file)
--- a/arexxd.c
+++ b/arexxd.c
@@ -410,6 +410,12 @@ static void dump_packet(byte *pkt)
        }
 }
 
+static void my_msleep(int ms)
+{
+       struct timespec ts = { .tv_sec = ms/1000, .tv_nsec = (ms%1000) * 1000000 };
+       nanosleep(&ts, NULL);
+}
+
 static int send_and_receive(byte *req, byte *reply)
 {
        if (debug_packets) {
@@ -436,6 +442,7 @@ static int send_and_receive(byte *req, byte *reply)
                log_pkt(">> xmit %d bytes\n", transferred);
                dump_packet(req);
        }
+       my_msleep(1);
        if (err = libusb_bulk_transfer(devh, rx_endpoint, reply, 64, &transferred, 200)) {
                if (err == LIBUSB_ERROR_TIMEOUT) {
                        log_pkt("<< recv timed out\n");
@@ -555,8 +562,7 @@ static void sigterm_handler(int sig __attribute__((unused)))
 static void interruptible_msleep(int ms)
 {
        sigprocmask(SIG_UNBLOCK, &term_sigs, NULL);
-       struct timespec ts = { .tv_sec = ms/1000, .tv_nsec = (ms%1000) * 1000000 };
-       nanosleep(&ts, NULL);
+       my_msleep(ms);
        sigprocmask(SIG_BLOCK, &term_sigs, NULL);
 }