add new backend for Corex CardScan 800c, small-format sheetfed usb scanner

for cards/receipts, etc.
merge-requests/1/head
m. allan noah 2007-07-15 01:46:47 +00:00
rodzic 5973ebe12d
commit 41761fede4
9 zmienionych plików z 1990 dodań i 5 usunięć

Wyświetl plik

@ -1,3 +1,9 @@
2007-07-14 m. allan noah <kitno455 a t gmail d o t com>
* doc/sane-cardscan.man,doc/Makefile.in,doc/descriptions/cardscan.desc,
backend/cardscan.*,backend/Makefile.in,configure.in:
add new v1.0.0 backend for Corex CardScan 800c
2007-07-14 m. allan noah <kitno455 a t gmail d o t com>
* doc/sane-fujitsu.man: add more known models, fix bug #304450

Wyświetl plik

@ -92,8 +92,10 @@ DISTFILES = abaton.c abaton.conf.in abaton.h agfafocus.c agfafocus.conf.in \
as6e.h avision.c avision.conf.in avision.h bh.c bh.conf.in bh.h canon.c \
canon.conf.in canon.h canon-sane.c canon-scsi.c canon630u.c canon630u-common.c \
canon630u.conf.in canon_pp.conf.in canon_pp.h canon_pp.c canon_pp-dev.c \
canon_pp-dev.h canon_pp-io.c canon_pp-io.h coolscan.c \
coolscan.conf.in coolscan.h coolscan-scsidef.h coolscan2.c coolscan2.conf.in \
canon_pp-dev.h canon_pp-io.c canon_pp-io.h \
cardscan.c cardscan.conf.in cardscan.h \
coolscan.c coolscan.conf.in coolscan.h coolscan-scsidef.h \
coolscan2.c coolscan2.conf.in \
dc210.c dc210.conf.in dc210.h \
dc240.c dc240.conf.in dc240.h dc25.c dc25.conf.in dc25.h dell1600n_net.c\
dell1600n_net.conf.in dll.aliases dll.c dll.conf.in dmc.c dmc.conf.in dmc.h \
@ -355,6 +357,9 @@ libsane-canon.la: ../sanei/sanei_scsi.lo
libsane-canon630u.la: ../sanei/sanei_constrain_value.lo
libsane-canon630u.la: ../sanei/sanei_usb.lo
libsane-canon_pp.la: $(addsuffix .lo,$(EXTRA_canon_pp))
libsane-cardscan.la: ../sanei/sanei_config2.lo
libsane-cardscan.la: ../sanei/sanei_constrain_value.lo
libsane-cardscan.la: ../sanei/sanei_usb.lo
libsane-coolscan.la: ../sanei/sanei_config2.lo
libsane-coolscan.la: ../sanei/sanei_constrain_value.lo
libsane-coolscan.la: ../sanei/sanei_scsi.lo

1633
backend/cardscan.c 100644

Plik diff jest za duży Load Diff

Wyświetl plik

@ -0,0 +1,12 @@
# For scanners connected via USB on a known device (kernel driver):
#usb /dev/usb/scanner0
# For scanners connected via USB using vendor and device ids (libusb):
#usb VENDORID PRODUCTID
# NOTE: if you have to add your device here- please send the id and model
# to the author via email, so it can be included in next version. kitno455 at
# gmail dot com - with cardscan in the subject line
# Corex Cardscan 800c
usb 0x08f0 0x0005

202
backend/cardscan.h 100644
Wyświetl plik

@ -0,0 +1,202 @@
#ifndef CARDSCAN_H
#define CARDSCAN_H
/*
* Part of SANE - Scanner Access Now Easy.
* Please see opening comment in cardscan.c
*/
/* -------------------------------------------------------------------------
* This option list has to contain all options for all scanners supported by
* this driver. If a certain scanner cannot handle a certain option, there's
* still the possibility to say so, later.
*/
enum scanner_Option
{
OPT_NUM_OPTS = 0,
OPT_MODE_GROUP,
OPT_MODE, /*mono/gray/color*/
/* must come last: */
NUM_OPTIONS
};
/* values common to calib and image data */
#define HEADER_SIZE 64
#define PIXELS_PER_LINE 1208
/* values for calib data */
#define CAL_COLOR_SIZE (PIXELS_PER_LINE * 3)
#define CAL_GRAY_SIZE PIXELS_PER_LINE
/* values for image data */
#define LINES_PER_PASS 16
#define COLOR_BLOCK_SIZE (LINES_PER_PASS * PIXELS_PER_LINE * 3)
#define GRAY_BLOCK_SIZE (LINES_PER_PASS * PIXELS_PER_LINE)
#define MAX_PAPERLESS_LINES 210
struct scanner
{
/* --------------------------------------------------------------------- */
/* immutable values which are set during init of scanner. */
struct scanner *next;
char *device_name; /* The name of the scanner device for sane */
/* --------------------------------------------------------------------- */
/* immutable values which are set during inquiry probing of the scanner. */
SANE_Device sane;
char * vendor_name;
char * product_name;
/* --------------------------------------------------------------------- */
/* changeable SANE_Option structs provide our interface to frontend. */
/* long array of option structs */
SANE_Option_Descriptor opt[NUM_OPTIONS];
/* --------------------------------------------------------------------- */
/* some options require lists of strings or numbers, we keep them here */
/* instead of in global vars so that they can differ for each scanner */
/*mode group*/
SANE_String_Const mode_list[3];
/* --------------------------------------------------------------------- */
/* changeable vars to hold user input. modified by SANE_Options above */
/*mode group*/
int mode; /*color,lineart,etc*/
/* --------------------------------------------------------------------- */
/* values which are derived from setting the options above */
/* the user never directly modifies these */
/* this is defined in sane spec as a struct containing:
SANE_Frame format;
SANE_Bool last_frame;
SANE_Int lines;
SANE_Int depth; ( binary=1, gray=8, color=8 (!24) )
SANE_Int pixels_per_line;
SANE_Int bytes_per_line;
*/
SANE_Parameters params;
/* --------------------------------------------------------------------- */
/* calibration data read once */
unsigned char cal_color_b[CAL_COLOR_SIZE];
unsigned char cal_gray_b[CAL_GRAY_SIZE];
unsigned char cal_color_w[CAL_COLOR_SIZE];
unsigned char cal_gray_w[CAL_GRAY_SIZE];
/* --------------------------------------------------------------------- */
/* values which are set by scanning functions to keep track of pages, etc */
int started;
int paperless_lines;
/* buffer part of image */
unsigned char buffer[COLOR_BLOCK_SIZE];
/* how far we have read from scanner into buffer */
int bytes_rx;
/* how far we have written from buffer to frontend */
int bytes_tx;
/* --------------------------------------------------------------------- */
/* values used by the command and data sending function */
int fd; /* The scanner device file descriptor. */
};
#define USB_COMMAND_TIME 10000
#define USB_DATA_TIME 10000
#define MODE_COLOR 0
#define MODE_GRAYSCALE 1
/* ------------------------------------------------------------------------- */
#define MM_PER_INCH 25.4
#define MM_PER_UNIT_UNFIX SANE_UNFIX(SANE_FIX(MM_PER_INCH / 1200.0))
#define MM_PER_UNIT_FIX SANE_FIX(SANE_UNFIX(SANE_FIX(MM_PER_INCH / 1200.0)))
#define SCANNER_UNIT_TO_FIXED_MM(number) SANE_FIX((number) * MM_PER_UNIT_UNFIX)
#define FIXED_MM_TO_SCANNER_UNIT(number) SANE_UNFIX(number) / MM_PER_UNIT_UNFIX
#define CONFIG_FILE "cardscan.conf"
#ifndef PATH_MAX
# define PATH_MAX 1024
#endif
#ifndef PATH_SEP
#ifdef HAVE_OS2_H
# define PATH_SEP '\\'
#else
# define PATH_SEP '/'
#endif
#endif
/* ------------------------------------------------------------------------- */
SANE_Status sane_init (SANE_Int * version_code, SANE_Auth_Callback authorize);
SANE_Status sane_get_devices (const SANE_Device *** device_list,
SANE_Bool local_only);
SANE_Status sane_open (SANE_String_Const name, SANE_Handle * handle);
SANE_Status sane_set_io_mode (SANE_Handle h, SANE_Bool non_blocking);
SANE_Status sane_get_select_fd (SANE_Handle h, SANE_Int * fdp);
const SANE_Option_Descriptor * sane_get_option_descriptor (SANE_Handle handle,
SANE_Int option);
SANE_Status sane_control_option (SANE_Handle handle, SANE_Int option,
SANE_Action action, void *val,
SANE_Int * info);
SANE_Status sane_start (SANE_Handle handle);
SANE_Status sane_get_parameters (SANE_Handle handle,
SANE_Parameters * params);
SANE_Status sane_read (SANE_Handle handle, SANE_Byte * buf, SANE_Int max_len,
SANE_Int * len);
void sane_cancel (SANE_Handle h);
void sane_close (SANE_Handle h);
void sane_exit (void);
/* ------------------------------------------------------------------------- */
static SANE_Status attach_one (const char *devicename);
static SANE_Status connect_fd (struct scanner *s);
static SANE_Status disconnect_fd (struct scanner *s);
static SANE_Status
do_cmd(struct scanner *s, int shortTime,
unsigned char * cmdBuff, size_t cmdLen,
unsigned char * outBuff, size_t outLen,
unsigned char * inBuff, size_t * inLen
);
static SANE_Status load_calibration (struct scanner *s);
static SANE_Status heat_lamp_color(struct scanner *s);
static SANE_Status heat_lamp_gray(struct scanner *s);
static SANE_Status read_from_scanner_color(struct scanner *s);
static SANE_Status read_from_scanner_gray(struct scanner *s);
static SANE_Status power_down(struct scanner *s);
static void hexdump (int level, char *comment, unsigned char *p, int l);
static size_t maxStringSize (const SANE_String_Const strings[]);
#endif /* CARDSCAN_H */

Wyświetl plik

@ -346,7 +346,7 @@ else
AC_MSG_NOTICE([Manually selected backends: ${BACKENDS}])
else
BACKENDS="abaton agfafocus apple artec as6e avision bh canon \
canon630u coolscan coolscan2 dc25 dmc \
canon630u cardscan coolscan coolscan2 dc25 dmc \
epson fujitsu genesys gt68xx hp leo lexmark matsushita microtek \
microtek2 mustek mustek_usb nec pie pixma plustek \
plustek_pp ricoh s9036 sceptre sharp \

Wyświetl plik

@ -54,7 +54,7 @@ SECT5 = sane-abaton.5 sane-agfafocus.5 sane-apple.5 sane-as6e.5 sane-dll.5 \
sane-ma1509.5 sane-ibm.5 sane-hp5400.5 sane-plustek_pp.5 sane-u12.5 \
sane-niash.5 sane-sm3840.5 sane-genesys.5 sane-hp4200.5 \
sane-mustek_usb2.5 sane-hp3500.5 sane-pixma.5 sane-stv680.5 \
sane-hp5590.5
sane-hp5590.5 sane-cardscan.5
SECT7 = sane.7
SECT8 = saned.8
MANPAGES = $(SECT1) $(SECT5) $(SECT7) $(SECT8)
@ -108,7 +108,7 @@ DISTFILES = Makefile.in backend-writing.txt descriptions.txt \
sane-ma1509.man sane-ibm.man sane-hp5400.man sane-plustek_pp.man \
sane-u12.man sane-niash.man sane-sm3840.man sane-genesys.man sane-hp4200.man \
sane-mustek_usb2.man sane-hp3500.man sane-pixma.man sane-stv680.man \
sane-hp5590.man
sane-hp5590.man sane-cardscan.man
.PHONY: all clean depend dist distclean html html-man install \
sane-html uninstall

Wyświetl plik

@ -0,0 +1,29 @@
;
; SANE Backend specification file
;
; It's basically emacs-lisp --- so ";" indicates comment to end of line.
; All syntactic elements are keyword tokens, followed by a string or
; keyword argument, as specified.
;
; ":backend" *must* be specified.
; All other information is optional (but what good is the file without it?).
;
:backend "cardscan" ; name of backend
:url "http://www.thebility.com/cardscan/"
:version "1.0.0" ; version of backend
:manpage "sane-cardscan" ; name of manpage (if it exists)
:comment "New for sane 1.0.19"
:devicetype :scanner ; start of a list of devices....
; other types: :stillcam, :vidcam,
; :meta, :api
:mfg "Corex" ; name a manufacturer
:url "http://www.cardscan.com/"
:model "800c"
:interface "USB"
:usbid "0x08f0" "0x2110"
:status :good
:comment "4 inch wide 8bit Gray or 24bit Color simplex card/receipt scanner"

Wyświetl plik

@ -0,0 +1,98 @@
.TH sane-cardscan 5 "2007-07-14" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy"
.IX sane-cardscan
.SH NAME
sane-cardscan \- SANE backend for Corex CardScan 800c usb scanner
.SH DESCRIPTION
The
.B sane-cardscan
library implements a SANE (Scanner Access Now Easy) backend which
provides access to the Corex CardScan 800c small-format scanner.
The backend supports only grayscale and color modes and media of
(theoretically) infinite length.
This backend may support other scanners. The best
way to determine level of support is to get a trace of the windows
driver in action, and send it to the author.
.SH OPTIONS
The cardscan backend supports the following options:
.PP
mode m
.RS
Selects the mode for the scan. Options are "Gray" and "Color".
.RE
.PP
.SH CONFIGURATION FILE
The configuration file "cardscan.conf" is used to tell the backend how to look
for scanners, and provide options controlling the operation of the backend.
This file is read each time the frontend asks the backend for a list
of scanners, generally only when the frontend starts. If the configuration
file is missing, the backend will use a set of compiled defaults, which
are identical to the default configuration file shipped with SANE.
.PP
Scanners can be specified in the configuration file in 2 ways:
.PP
"usb 0x04c5 0x1042" (or other vendor/product ids)
.RS
Requests backend to search all usb busses in the system for a device
which uses that vendor and product id. The device will then be queried
to determine if it is a cardscan scanner.
.RE
.PP
"usb /dev/usb/scanner0" (or other device file)
.RS
Some systems use a kernel driver to access usb scanners. This method is untested.
.RE
.SH ENVIRONMENT
The backend uses a single environment variable, SANE_DEBUG_CARDSCAN, which
enables debugging output to stderr. Valid values are:
.PP
.RS
5 Errors
.br
10 Function trace
.br
15 Function detail
.br
20 Option commands
.br
25 SCSI/USB trace
.br
30 SCSI/USB detail
.br
35 Useless noise
.RE
.SH KNOWN ISSUES
.PP
.RS
The scanner does not seem to have much control possible, so the backend
cannot set x/y coordinate values, resolutions, etc. These things could
be simulated in the backend, but there are plenty of command line tools.
.br
.br
The backend also does not send all the commands that the windows driver
does, so it may not function the same.
.br
.br
The backend does not have the calibration or ejection options of the
windows driver.
.br
.br
.RE
.SH CREDITS
The hardware to build this driver was provided to the author by:
Jeff Kowalczyk <jtk a t yahoo d o t com>
.SH "SEE ALSO"
sane(7),
sane-usb(5)
.SH AUTHOR
m. allan noah: <kitno455 a t gmail d o t com>