all: Tweak state transtition/sleeping a bit.

Now we only sleep if the readback and teh state haven't changed.
This commit is contained in:
Solomon Peachy 2013-07-16 23:19:04 -04:00
parent 2f294c6518
commit c3173703c6
4 changed files with 34 additions and 29 deletions

View File

@ -35,7 +35,7 @@
#include <fcntl.h>
#include <signal.h>
#define VERSION "0.17"
#define VERSION "0.18"
#define URI_PREFIX "kodak1400://"
#include "backend_common.c"
@ -482,7 +482,11 @@ skip_read:
/* Time for the main processing loop */
top:
/* Send State Query */
if (state != last_state) {
DEBUG("last_state %d new %d\n", last_state, state);
}
/* Send Status Query */
memset(cmdbuf, 0, CMDBUF_LEN);
cmdbuf[0] = 0x1b;
cmdbuf[1] = 0x72;
@ -509,13 +513,11 @@ top:
rdbuf[0], rdbuf[1], rdbuf[2], rdbuf[3],
rdbuf[4], rdbuf[5], rdbuf[6], rdbuf[7]);
memcpy(rdbuf2, rdbuf, READBACK_LEN);
} else {
} else if (state == last_state) {
sleep(1);
}
if (state != last_state) {
DEBUG("last_state %d new %d\n", last_state, state);
last_state = state;
}
fflush(stderr);
switch (state) {

View File

@ -35,7 +35,7 @@
#include <fcntl.h>
#include <signal.h>
#define VERSION "0.12"
#define VERSION "0.13"
#define URI_PREFIX "kodak6800://"
#define STR_LEN_MAX 64
@ -494,7 +494,11 @@ int main (int argc, char **argv)
/* Time for the main processing loop */
top:
/* Send State Query */
if (state != last_state) {
DEBUG("last_state %d new %d\n", last_state, state);
}
/* Send Status Query */
memset(cmdbuf, 0, CMDBUF_LEN);
cmdbuf[0] = 0x03;
cmdbuf[1] = 0x1b;
@ -527,13 +531,11 @@ top:
DEBUG2("%02x ", rdbuf[i]);
}
DEBUG2("\n");
} else {
} else if (state == last_state) {
sleep(1);
}
if (state != last_state) {
DEBUG("last_state %d new %d\n", last_state, state);
last_state = state;
}
fflush(stderr);
switch (state) {

View File

@ -35,7 +35,7 @@
#include <fcntl.h>
#include <signal.h>
#define VERSION "0.53"
#define VERSION "0.54"
#define URI_PREFIX "canonselphy://"
#include "backend_common.c"
@ -656,6 +656,10 @@ int main (int argc, char **argv)
2000);
top:
if (state != last_state) {
DEBUG("last_state %d new %d\n", last_state, state);
}
/* Do it twice to clear initial state */
ret = libusb_bulk_transfer(dev, endp_up,
rdbuf,
@ -675,13 +679,11 @@ top:
rdbuf[4], rdbuf[5], rdbuf[6], rdbuf[7],
rdbuf[8], rdbuf[9], rdbuf[10], rdbuf[11]);
memcpy(rdbuf2, rdbuf, READBACK_LEN);
} else {
} else if (state == last_state) {
sleep(1);
}
if (state != last_state) {
DEBUG("last_state %d new %d\n", last_state, state);
last_state = state;
}
fflush(stderr);
/* Error detection */

View File

@ -39,7 +39,7 @@
#include <fcntl.h>
#include <signal.h>
#define VERSION "0.13"
#define VERSION "0.14"
#define URI_PREFIX "shinkos2145://"
#include "backend_common.c"
@ -1334,12 +1334,15 @@ skip_read:
/* Time for the main processing loop */
top:
if (state != last_state) {
DEBUG("last_state %d new %d\n", last_state, state);
}
/* Send Status Query */
memset(cmdbuf, 0, CMDBUF_LEN);
cmd->cmd = cpu_to_le16(S2145_CMD_STATUS);
cmd->len = cpu_to_le16(0);
/* Send Status Query */
if ((ret = s2145_do_cmd(dev, endp_up, endp_down,
cmdbuf, sizeof(*cmd),
sizeof(struct s2145_status_hdr),
@ -1362,13 +1365,10 @@ top:
sts->hdr.printer_major, sts->hdr.printer_minor);
}
memcpy(rdbuf2, rdbuf, READBACK_LEN);
} else {
} else if (state == last_state) {
sleep(1);
}
if (state != last_state) {
DEBUG("last_state %d new %d\n", last_state, state);
last_state = state;
}
fflush(stderr);
@ -1421,11 +1421,10 @@ top:
if ((ret = send_data(dev, endp_down, planedata, datasize)))
goto done_claimed;
INFO("Waiting for printer to acknowledge completion\n");
state = S_PRINTER_SENT_DATA;
break;
case S_PRINTER_SENT_DATA:
INFO("Waiting for printer to acknowledge completion\n");
if (sts->hdr.result != RESULT_SUCCESS)
goto printer_error;
if (sts->hdr.status == STATUS_READY ||