diff options
author | Didier Raboud <odyx@debian.org> | 2016-10-05 09:16:08 +0200 |
---|---|---|
committer | Didier Raboud <odyx@debian.org> | 2016-10-05 09:16:08 +0200 |
commit | d69d392d8c45cdcc93e58f0e1bdbb2b66d6b9566 (patch) | |
tree | fbd96013c3d605249b167a97c8862f38f8a1cdee /src/escputil | |
parent | 7f5731038556e5b03d2a886163ca2c873c77333d (diff) |
New upstream version 5.2.12~pre3
Diffstat (limited to 'src/escputil')
-rw-r--r-- | src/escputil/Makefile.in | 1 | ||||
-rw-r--r-- | src/escputil/d4lib.c | 31 | ||||
-rw-r--r-- | src/escputil/escputil.c | 4 |
3 files changed, 24 insertions, 12 deletions
diff --git a/src/escputil/Makefile.in b/src/escputil/Makefile.in index da27b47..838b6c6 100644 --- a/src/escputil/Makefile.in +++ b/src/escputil/Makefile.in @@ -185,6 +185,7 @@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ BUILD_CUPS_PPDS = @BUILD_CUPS_PPDS@ +BZIP2 = @BZIP2@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ diff --git a/src/escputil/d4lib.c b/src/escputil/d4lib.c index 5c99409..aef85be 100644 --- a/src/escputil/d4lib.c +++ b/src/escputil/d4lib.c @@ -47,6 +47,7 @@ #include <errno.h> #include <string.h> #include <ctype.h> +#include <time.h> #include "d4lib.h" @@ -183,6 +184,14 @@ static errorMessage_t errorMessage[] = sig = signal(SIGALRM, sigAlarm); \ } +static int d4USleep(long usec) +{ + struct timespec t; + t.tv_sec = 0; + t.tv_nsec = 1000l * usec; + return nanosleep(&t, NULL); +} + /*******************************************************************/ /* Function printHexValues */ /* */ @@ -275,7 +284,7 @@ int SafeWrite(int fd, const void *data, int len) { status = write(fd, data, len); if(status < len) - usleep(d4WrTimeout); + d4USleep(d4WrTimeout); retries--; } while ((status < len) && (retries > 0)); @@ -405,7 +414,7 @@ static int writeCmd(int fd, unsigned char *cmd, int len) /* according to Glen Steward, this will solve problems */ /* for the cartridge exchange with the Stylus Color 580 */ - usleep(d4MicroTimeout); + d4USleep(d4MicroTimeout); timeoutGot = 0; errno = 0; @@ -464,7 +473,7 @@ int readAnswer(int fd, unsigned char *buf, int len, int allowExtra) int first_read = 1; int excess = 0; /* wait a little bit before reading an answer */ - usleep(d4RdTimeout); + d4USleep(d4RdTimeout); /* for error handling in case of timeout */ timeoutGot = 0; @@ -542,7 +551,7 @@ int readAnswer(int fd, unsigned char *buf, int len, int allowExtra) } } } - usleep(d4RdTimeout); + d4USleep(d4RdTimeout); } if (debugD4) printf("\n"); @@ -563,7 +572,7 @@ int readAnswer(int fd, unsigned char *buf, int len, int allowExtra) else retry_count = 0; if (status < bytes) - usleep(d4RdTimeout); + d4USleep(d4RdTimeout); if (debugD4) printHexValues("waste", (const unsigned char *) wastebuf, status); excess -= status; @@ -600,7 +609,7 @@ static void _flushData(int fd) char buf[1024]; int len = 1023; int count = 200; - usleep(d4RdTimeout); + d4USleep(d4RdTimeout); /* for error handling in case of timeout */ timeoutGot = 0; @@ -613,7 +622,7 @@ static void _flushData(int fd) printf("+++flush data: length: %i\n", len); do { - usleep(d4RdTimeout); + d4USleep(d4RdTimeout); SET_TIMER(ti,oti, d4RdTimeout); rd = read(fd, buf, len); if (debugD4) @@ -1144,7 +1153,7 @@ int askForCredit(int fd, unsigned char socketID, int *sndSize, int *rcvSize) while (credit == 0 && retries-- >= 0 ) { while((credit=CreditRequest(fd,socketID)) == 0 && count < MAX_CREDIT_REQUEST && retries-- >= 0) - usleep(d4RdTimeout); + d4USleep(d4RdTimeout); if ( credit == -1 ) { @@ -1281,7 +1290,7 @@ int readData(int fd, unsigned char socketID, unsigned char *buf, int len) if ( Credit(fd, socketID, 1) == 1 ) { /* wait a little bit */ - usleep(d4RdDataTimeout); + d4USleep(d4RdDataTimeout); ret = _readData(fd, buf, len); return ret; } @@ -1332,7 +1341,7 @@ int writeAndReadData(int fd, unsigned char socketID, /* wait a little bit */ do { - usleep(d4RdDataTimeout); + d4USleep(d4RdDataTimeout); ret = _readData(fd, buf, len); if (ret < 0) return ret; @@ -1366,7 +1375,7 @@ void flushData(int fd, unsigned char socketID) if ( Credit(fd, socketID, 1) == 1 ) { /* wait a little bit */ - usleep(d4RdDataTimeout); + d4USleep(d4RdDataTimeout); _flushData(fd); } } diff --git a/src/escputil/escputil.c b/src/escputil/escputil.c index 8f4ae9e..76c5fc8 100644 --- a/src/escputil/escputil.c +++ b/src/escputil/escputil.c @@ -31,6 +31,7 @@ #include <signal.h> #include <sys/wait.h> #include <ctype.h> +#include <time.h> #if defined(HAVE_VARARGS_H) && !defined(HAVE_STDARG_H) #include <varargs.h> #else @@ -577,7 +578,8 @@ read_from_printer(int fd, char *buf, int bufsize, int quiet) status = read(fd, buf, bufsize - 1); if (status == 0 || (status < 0 && errno == EAGAIN)) { - usleep(2000); + struct timespec tm = {0, 2000000}; + nanosleep(&tm, &tm); status = 0; /* not an error (read would have blocked) */ } } |