[common] Working towards merging common code.

This commit is contained in:
Solomon Peachy 2012-10-27 10:38:36 -04:00
parent 013703f08a
commit b5644910db
3 changed files with 18 additions and 17 deletions

View File

@ -65,7 +65,8 @@ static const int foot_lengths[P_END] = { 0, 0, 12, 12, 0 };
/* Does NOT include header length! */
#define RDBUF_LEN 12
#define BUF_LEN 4096
static const int es40_plane_lengths[4] = { 2227456, 1601600, 698880, 2976512 };
static const int16_t init_readbacks[P_END][RDBUF_LEN] = { { 0x02, 0x00, 0x00, 0x00, 0x02, 0x01, -1, 0x01, 0x00, 0x00, 0x00, 0x00 },

View File

@ -38,6 +38,8 @@
#include "es_print_common.h"
#define dump_data dump_data_libusb
/* USB Identifiers */
#define USB_VID_CANON 0x04a9
#define USB_PID_CANON_ES1 0x3141
@ -52,11 +54,9 @@
#define ENDPOINT_UP 0x81
#define ENDPOINT_DOWN 0x02
#define BUF_LEN 4096
static int dump_data_libusb (int remaining, int present, int data_fd,
struct libusb_device_handle *dev,
uint8_t *buf, uint16_t buflen) {
static int dump_data_libusb(int remaining, int present, int data_fd,
struct libusb_device_handle *dev,
uint8_t *buf, uint16_t buflen) {
int cnt;
int i;
int wrote;
@ -346,7 +346,7 @@ top:
fprintf(stderr, "Sending BLACK plane\n");
else
fprintf(stderr, "Sending YELLOW plane\n");
dump_data_libusb(plane_len, MAX_HEADER-init_lengths[printer_type], data_fd, dev, buffer, BUF_LEN);
dump_data(plane_len, MAX_HEADER-init_lengths[printer_type], data_fd, dev, buffer, BUF_LEN);
state = S_PRINTER_Y_SENT;
break;
case S_PRINTER_Y_SENT:
@ -359,7 +359,7 @@ top:
break;
case S_PRINTER_READY_M:
fprintf(stderr, "Sending MAGENTA plane\n");
dump_data_libusb(plane_len, 0, data_fd, dev, buffer, BUF_LEN);
dump_data(plane_len, 0, data_fd, dev, buffer, BUF_LEN);
state = S_PRINTER_M_SENT;
break;
case S_PRINTER_M_SENT:
@ -369,7 +369,7 @@ top:
break;
case S_PRINTER_READY_C:
fprintf(stderr, "Sending CYAN plane\n");
dump_data_libusb(plane_len, 0, data_fd, dev, buffer, BUF_LEN);
dump_data(plane_len, 0, data_fd, dev, buffer, BUF_LEN);
state = S_PRINTER_C_SENT;
break;
case S_PRINTER_C_SENT:
@ -380,7 +380,7 @@ top:
case S_PRINTER_DONE:
if (foot_lengths[printer_type]) {
fprintf(stderr, "Sending cleanup sequence\n");
dump_data_libusb(foot_lengths[printer_type], 0, data_fd, dev, buffer, BUF_LEN);
dump_data(foot_lengths[printer_type], 0, data_fd, dev, buffer, BUF_LEN);
}
state = S_FINISHED;
break;

View File

@ -38,10 +38,10 @@
#include "es_print_common.h"
#define BUF_LEN 4096
#define dump_data dump_data_linux
int dump_data_new(int remaining, int present, int data_fd,
int dev_fd, uint8_t *buf, uint16_t buflen)
int dump_data_linux(int remaining, int present, int data_fd,
int dev_fd, uint8_t *buf, uint16_t buflen)
{
int cnt;
int i;
@ -243,7 +243,7 @@ top:
fprintf(stderr, "Sending BLACK plane\n");
else
fprintf(stderr, "Sending YELLOW plane\n");
dump_data_new(plane_len, MAX_HEADER-init_lengths[printer_type], data_fd, dev_fd, buffer, BUF_LEN);
dump_data(plane_len, MAX_HEADER-init_lengths[printer_type], data_fd, dev_fd, buffer, BUF_LEN);
state = S_PRINTER_Y_SENT;
break;
case S_PRINTER_Y_SENT:
@ -256,7 +256,7 @@ top:
break;
case S_PRINTER_READY_M:
fprintf(stderr, "Sending MAGENTA plane\n");
dump_data_new(plane_len, 0, data_fd, dev_fd, buffer, BUF_LEN);
dump_data(plane_len, 0, data_fd, dev_fd, buffer, BUF_LEN);
state = S_PRINTER_M_SENT;
break;
case S_PRINTER_M_SENT:
@ -266,7 +266,7 @@ top:
break;
case S_PRINTER_READY_C:
fprintf(stderr, "Sending CYAN plane\n");
dump_data_new(plane_len, 0, data_fd, dev_fd, buffer, BUF_LEN);
dump_data(plane_len, 0, data_fd, dev_fd, buffer, BUF_LEN);
state = S_PRINTER_C_SENT;
break;
case S_PRINTER_C_SENT:
@ -277,7 +277,7 @@ top:
case S_PRINTER_DONE:
if (foot_lengths[printer_type]) {
fprintf(stderr, "Sending cleanup sequence\n");
dump_data_new(foot_lengths[printer_type], 0, data_fd, dev_fd, buffer, BUF_LEN);
dump_data(foot_lengths[printer_type], 0, data_fd, dev_fd, buffer, BUF_LEN);
}
state = S_FINISHED;
break;