[sane-devel] Primax Colorado 2400u

Henning Meier-Geinitz henning at meier-geinitz.de
Fri Dec 23 18:34:30 UTC 2005


Hi,

On Wed, Dec 07, 2005 at 10:37:46AM -0800, Terry Roman wrote:
> I have placed the files at
> www.geocities.com/trsh0101/index.html if you want to
> have a look.  The website is something I threw
> together very quick so it's not pretty.  Maybe I can
> make changes eventually and move it to a more
> respectable server.

I had a quick look at the code now. I can't actually test the backend,
beacuse I don't have such a scanner.

primascan.h looks, well, ugly. I think just putting the data that was
captured by a USB logger into some structs and then throwing it to the
scanner is not the type of thing a SANE backend should do :-)
So your code is better than no backend at all but it can't be part of
sane-backends in its current form.

Anyway, some more comments: Something seems to be wrong with the line
endings of the source code. I get "^M" at every line (at elast in emacs).

By the way, despite your comment SANE gives a way to store
scanner-dependent data, that's the reason we have a handle, which can
be a pointer to a data structure conatining everything you want.

Also, using malloc once to get a large buffer and using this one
should work.

The code should use sanei_usb, not libusb directly.

The code does not contain any debug messages. It could become rather
tricky to analyse problems.

 colorado->name = "Primascan";

This should be the backend name (->lowercase).

  /* prevent compiler from complaining about unused parameters */
  handle = handle;
  devicename = devicename;  

This should only be done if the parameters are really unused.


if (detectDevice (&dev))
    {
      /* Open device */
      deviceHandle = usb_open (&dev);

      int status1;
      int status2;
      int status3;

Such type of code does not compile on older C compilers (mixed
variable definitions and code).

Also you don't check if usb_open succeeds before using deviceHandle.

int detectDevice (struct usb_device *device)

The test for !deviceFound at the end is bogus as that variable is
never set to true.

Using the SANE status codes for all functions that can return an error
maybe helpful (instead of inventing new error codes or using true and
false).

Never use exit() in SANE libraries. You'll leave the whole frontend!

  number1.name = "dpi";
  number1.title = "dpi setting";
  number1.desc =  "This controls the dpi setting of the scanner. 100
  if a color scan and 200 is a black and white scan";
  number1.type = SANE_TYPE_INT;
  number1.unit = SANE_UNIT_NONE;
  number1.size = sizeof (SANE_Word);
  number1.cap = SANE_CAP_SOFT_SELECT;
  number1.constraint_type = SANE_CONSTRAINT_WORD_LIST;
  number1.constraint.range = 0;

"dpi setting" is usually called "resolution". see
SANE_NAME_SCAN_RESOLUTION. It's unit should be SANE_UNIT_DPI.
With only SANE_CAP_SOFT_SELECT, the option is not readable, only
writable. In fact, this is explicitely forbidden by the SANE standard.

I don't know if the two resolutions (100 dpi at color and 200 at black and
white) are the only ones the scanner can do. Even in this case you
should use the "mode" option to select between color and black/white.

No options for geometry control?

These are the compilation warnings I get:
primascan.c:164: warning: function declaration isn't a prototype
primascan.c:165: warning: function declaration isn't a prototype
primascan.c: In function 'sane_primascan_get_devices':
primascan.c:259: warning: ISO C90 forbids mixed declarations and code
primascan.c: In function 'sane_primascan_open':
primascan.c:315: warning: ISO C90 forbids mixed declarations and code
primascan.c: In function 'sane_primascan_start':
primascan.c:473: warning: ISO C90 forbids mixed declarations and code
primascan.c:488: warning: ISO C90 forbids mixed declarations and code
primascan.c: In function 'sane_primascan_read':
primascan.c:574: warning: ISO C90 forbids mixed declarations and code
primascan.c: At top level:
primascan.c:751: warning: function declaration isn't a prototype
primascan.c: In function 'calibrate':
primascan.c:759: warning: ISO C90 forbids mixed declarations and code
primascan.c: In function 'calibrationWrite':
primascan.c:817: warning: ISO C90 forbids mixed declarations and code
primascan.c: In function 'repeatedControlTransfer':
primascan.c:868: warning: ISO C90 forbids mixed declarations and code
primascan.c: In function 'bulkRead':
primascan.c:900: warning: ISO C90 forbids mixed declarations and code
primascan.c: In function 'writeBulk0s':
primascan.c:938: warning: ISO C90 forbids mixed declarations and code
primascan.c: In function 'controlTransfer':
primascan.c:989: warning: ISO C90 forbids mixed declarations and code
primascan.c: At top level:
primascan.c:1015: warning: function declaration isn't a prototype

make libcheck reports the following errors:

Libraries exporting 'illegal' symbols:
*** backend/.libs/libsane-primascan.a:
00000700 T bulkRead
00000580 T calibrate
00000500 T calibrationWrite
000005f0 T controlTransfer
000002c0 T detectDevice
000008c0 T finalizeScanner
00000670 T repeatedControlTransfer
00000490 T writeBulk0s

Bye,
  Henning



More information about the sane-devel mailing list