[sane-devel] SANE 1.0.18 and the NSLU2 running OpenWRT

David Solomon lorddavon at gmail.com
Mon Jul 23 14:25:39 UTC 2007


Here are the diffs:

rx30 at dsolomon-devbox:~/nslu2/downloads/temp/sane-backends-1.0.18/backend$
cat avision.h.diff
*** avision.h.orig      2007-07-23 10:21:01.000000000 -0400
--- avision.h   2007-07-17 12:07:25.000000000 -0400
***************
*** 57,62 ****
--- 57,65 ----
  # define PATH_MAX 1024
  #endif

+ #define PACKED8  __attribute__ ((packed,aligned(1)))
+ #define PACKED16 __attribute__ ((packed,aligned(2)))
+
  typedef enum Avision_ConnectionType {
    AV_SCSI,
    AV_USB
***************
*** 73,79 ****
      AVISION_USB_BULK_STATUS      /* bulk endp. (USB 2.0 device) status */
    } usb_status;

! } Avision_Connection;

  typedef struct Avision_HWEntry {
    const char* scsi_mfg;
--- 76,82 ----
      AVISION_USB_BULK_STATUS      /* bulk endp. (USB 2.0 device) status */
    } usb_status;

! } PACKED16 Avision_Connection;

  typedef struct Avision_HWEntry {
    const char* scsi_mfg;
***************
*** 150,156 ****
      /* maybe more ...*/
    } feature_type;

! } Avision_HWEntry;

  typedef enum {
    AV_ASIC_Cx = 0,
--- 153,159 ----
      /* maybe more ...*/
    } feature_type;

! } PACKED16 Avision_HWEntry;

  typedef enum {
    AV_ASIC_Cx = 0,
***************
*** 260,266 ****
    /* interlaced duplex scan */
    SANE_Bool interlaced_duplex;

! } Avision_Dimensions;

  /* this contains our low-level info - not relevant for the SANE interface  */
  typedef struct Avision_Device
--- 263,269 ----
    /* interlaced duplex scan */
    SANE_Bool interlaced_duplex;

! } PACKED16 Avision_Dimensions;

  /* this contains our low-level info - not relevant for the SANE interface  */
  typedef struct Avision_Device
***************
*** 347,353 ****
    u_int16_t data_dq; /* was ox0A0D - but hangs some new scanners */

    Avision_HWEntry* hw;
! } Avision_Device;

  /* all the state relevant for the SANE interface */
  typedef struct Avision_Scanner
--- 350,356 ----
    u_int16_t data_dq; /* was ox0A0D - but hangs some new scanners */

    Avision_HWEntry* hw;
! } PACKED16 Avision_Device;

  /* all the state relevant for the SANE interface */
  typedef struct Avision_Scanner
***************
*** 390,396 ****
    int write_fds;      /* pipe writing end */
    int line;                   /* current line number during scan */

! } Avision_Scanner;

  /* Some Avision driver internal defines */
  #define AV_WINID 0
--- 393,399 ----
    int write_fds;      /* pipe writing end */
    int line;                   /* current line number during scan */

! } PACKED16 Avision_Scanner;

  /* Some Avision driver internal defines */
  #define AV_WINID 0
***************
*** 439,445 ****
    u_int8_t pad0 [3];
    u_int8_t len;
    u_int8_t pad1;
! } command_header;

  typedef struct command_set_window
  {
--- 442,448 ----
    u_int8_t pad0 [3];
    u_int8_t len;
    u_int8_t pad1;
! } PACKED8 command_header;

  typedef struct command_set_window
  {
***************
*** 447,453 ****
    u_int8_t reserved0 [5];
    u_int8_t transferlen [3];
    u_int8_t control;
! } command_set_window;

  typedef struct command_read
  {
--- 450,456 ----
    u_int8_t reserved0 [5];
    u_int8_t transferlen [3];
    u_int8_t control;
! } PACKED8 command_set_window;

  typedef struct command_read
  {
***************
*** 458,464 ****
    u_int8_t datatypequal [2];
    u_int8_t transferlen [3];
    u_int8_t control;
! } command_read;

  typedef struct command_scan
  {
--- 461,467 ----
    u_int8_t datatypequal [2];
    u_int8_t transferlen [3];
    u_int8_t control;
! } PACKED8 command_read;

  typedef struct command_scan
  {
***************
*** 467,473 ****
    u_int8_t reserved0 [2];
    u_int8_t transferlen;
    u_int8_t bitset1;
! } command_scan;

  typedef struct command_send
  {
--- 470,476 ----
    u_int8_t reserved0 [2];
    u_int8_t transferlen;
    u_int8_t bitset1;
! } PACKED8 command_scan;

  typedef struct command_send
  {
***************
*** 478,484 ****
    u_int8_t datatypequal [2];
    u_int8_t transferlen [3];
    u_int8_t reserved1;
! } command_send;

  typedef struct nvram_data
  {
--- 481,487 ----
    u_int8_t datatypequal [2];
    u_int8_t transferlen [3];
    u_int8_t reserved1;
! } PACKED8 command_send;

  typedef struct nvram_data
  {
***************
*** 513,519 ****
    u_int8_t power_saving_time [2];

    u_int8_t reserved [56];
! } nvram_data;


  typedef struct command_set_window_window
--- 516,522 ----
    u_int8_t power_saving_time [2];

    u_int8_t reserved [56];
! } PACKED8 nvram_data;


  typedef struct command_set_window_window
***************
*** 521,527 ****
    struct {
      u_int8_t reserved0 [6];
      u_int8_t desclen [2];
!   } header;

    struct {
      u_int8_t winid;
--- 524,530 ----
    struct {
      u_int8_t reserved0 [6];
      u_int8_t desclen [2];
!   } PACKED8 header;

    struct {
      u_int8_t winid;
***************
*** 548,554 ****
      /* Avision specific parameters */
      u_int8_t vendor_specific;
      u_int8_t paralen; /* bytes following after this byte */
!   } descriptor;

    struct {
      u_int8_t bitset1;
--- 551,557 ----
      /* Avision specific parameters */
      u_int8_t vendor_specific;
      u_int8_t paralen; /* bytes following after this byte */
!   } PACKED8 descriptor;

    struct {
      u_int8_t bitset1;
***************
*** 562,568 ****
        struct {
        u_int8_t bitset2;
        u_int8_t reserved;
!       } old;

        struct {
        u_int8_t bitset2;
--- 565,571 ----
        struct {
        u_int8_t bitset2;
        u_int8_t reserved;
!       } PACKED8 old;

        struct {
        u_int8_t bitset2;
***************
*** 578,584 ****
        u_int8_t line_width_msb;
        u_int8_t line_count_msb;
        u_int8_t edge_threshold; /* background lines? */
!       } normal;

        struct {
        u_int8_t reserved0 [4];
--- 581,587 ----
        u_int8_t line_width_msb;
        u_int8_t line_count_msb;
        u_int8_t edge_threshold; /* background lines? */
!       } PACKED8 normal;

        struct {
        u_int8_t reserved0 [4];
***************
*** 586,602 ****
        u_int8_t paperx [4];
        u_int8_t papery [4];
        u_int8_t reserved1 [2];
!       } fujitsu;
!     } type;
!   } avision;
! } command_set_window_window;

  typedef struct page_header
  {
    u_int8_t pad0 [4];
    u_int8_t code;
    u_int8_t length;
! } page_header;

  typedef struct avision_page
  {
--- 589,605 ----
        u_int8_t paperx [4];
        u_int8_t papery [4];
        u_int8_t reserved1 [2];
!       } PACKED8 fujitsu;
!     } PACKED8 type;
!   } PACKED8 avision;
! } PACKED8 command_set_window_window;

  typedef struct page_header
  {
    u_int8_t pad0 [4];
    u_int8_t code;
    u_int8_t length;
! } PACKED8 page_header;

  typedef struct avision_page
  {
***************
*** 606,612 ****
    u_int8_t delay;
    u_int8_t features;
    u_int8_t pad0;
! } avision_page;

  typedef struct calibration_format
  {
--- 609,615 ----
    u_int8_t delay;
    u_int8_t features;
    u_int8_t pad0;
! } PACKED8 avision_page;

  typedef struct calibration_format
  {
***************
*** 627,638 ****

    /* not returned but usefull in some places */
    u_int8_t channels;
! } calibration_format;

  typedef struct matrix_3x3
  {
    u_int16_t v[9];
! } matrix_3x3;

  typedef struct acceleration_info
  {
--- 630,641 ----

    /* not returned but usefull in some places */
    u_int8_t channels;
! } PACKED8 calibration_format;

  typedef struct matrix_3x3
  {
    u_int16_t v[9];
! } PACKED8 matrix_3x3;

  typedef struct acceleration_info
  {
***************
*** 645,651 ****
    u_int8_t ability;
    u_int8_t table_count;
    u_int8_t reserved[6];
! } acceleration_info;

  /* set/get SCSI highended (big-endian) variables. Declare them as an array
   * of chars endianness-safe, int-size safe ... */
--- 648,654 ----
    u_int8_t ability;
    u_int8_t table_count;
    u_int8_t reserved[6];
! } PACKED8 acceleration_info;

  /* set/get SCSI highended (big-endian) variables. Declare them as an array
   * of chars endianness-safe, int-size safe ... */




**********************************************************************************************

*** avision.c.orig      2007-07-23 10:21:01.000000000 -0400
--- avision.c   2007-07-17 12:34:35.000000000 -0400
***************
*** 846,852 ****
      { "AVISION", "AV210C2",
        0x0638, 0x0A3A,
        "Avision", "AV210C2",
!       AV_INT_BUTTON},
      /* comment="sheetfed scanner" */
      /* status="complete" */

--- 846,852 ----
      { "AVISION", "AV210C2",
        0x0638, 0x0A3A,
        "Avision", "AV210C2",
!       AV_INT_BUTTON, AV_NO_GAMMA},
      /* comment="sheetfed scanner" */
      /* status="complete" */

***************
*** 1461,1467 ****
  static Avision_HWEntry* attaching_hw = 0;

  /* disable the usage of a custom gamma-table */
! static SANE_Bool disable_gamma_table = SANE_FALSE;

  /* disable the calibration */
  static SANE_Bool disable_calibration = SANE_FALSE;
--- 1461,1467 ----
  static Avision_HWEntry* attaching_hw = 0;

  /* disable the usage of a custom gamma-table */
! static SANE_Bool disable_gamma_table = SANE_TRUE;

  /* disable the calibration */
  static SANE_Bool disable_calibration = SANE_FALSE;
***************
*** 2264,2270 ****
        struct {
        command_header header;
        u_int8_t pad[4];
!       } sense_cmd;

        u_int8_t sense_buffer[22];

--- 2264,2270 ----
        struct {
        command_header header;
        u_int8_t pad[4];
!       } PACKED8 sense_cmd;

        u_int8_t sense_buffer[22];

***************
*** 3383,3389 ****
       u_int8_t gray_line_difference[2];
       u_int8_t lineart_line_difference[2];
       u_int8_t image_info;
!   } result;

    size_t size;
    SANE_Status status;
--- 3383,3389 ----
       u_int8_t gray_line_difference[2];
       u_int8_t lineart_line_difference[2];
       u_int8_t image_info;
!   } PACKED8 result;

    size_t size;
    SANE_Status status;
***************
*** 3433,3439 ****
    struct {
      struct command_send cmd;
      u_int8_t data[8];
!   } scmd;

    Avision_Device* dev = s->hw;
    SANE_Status status;
--- 3433,3439 ----
    struct {
      struct command_send cmd;
      u_int8_t data[8];
!   } PACKED8 scmd;

    Avision_Device* dev = s->hw;
    SANE_Status status;


On 7/18/07, René Rebe <rene at exactcode.de> wrote:
> On Tuesday 17 July 2007 18:58:03 David Solomon wrote:
> > I got it working.  I needed to use PACKED8 on the structures in the
> > avision.c file also.  Moved all of the Avision device structures to
> > PACKED16.
>
> Can you please send me a diff(1) of your modificatoins, thanks :-)
>
> Yours,
>  René
>
> > David Solomon
> >
> > On 7/16/07, m. allan noah <kitno455 at gmail.com> wrote:
> > > this webpage is all i know about it (but google will give more):
> > >
> > > http://sig9.com/articles/gcc-packed-structures
> > >
> > > allan
> > >
> > > On 7/16/07, David Solomon <lorddavon at gmail.com> wrote:
> > > > Allan,
> > > >
> > > > Do I add them to all of the command structs or just the Avision_Connection?
> > > >
> > > > David Solomon
> > > >
> > > > On 7/16/07, m. allan noah <kitno455 at gmail.com> wrote:
> > > > > On 7/16/07, David Solomon <lorddavon at gmail.com> wrote:
> > > > > > I think you are right.  I am trying some pragma pack statments to see
> > > > > > if they will help.  I looked at some of the plustek_usb header changes
> > > > > > and found that they used: "#define PACKED8  __attribute__
> > > > > > ((packed,aligned(1)))" and "#define PACKED16 __attribute__
> > > > > > ((packed,aligned(2)))" statements to pack the structures.  I may have
> > > > > > to use these myself, but I am unsure where to add (possible in the
> > > > > > sanei_usb_write_bulk?).
> > > > > >
> > > > > > Thank you for the help.  I am going to get up-to-my-elbows in code now.  ;-)
> > > > > >
> > > > >
> > > > > no- you want to add them to the command structs in avision.h
> > > > >
> > > > > allan
> > > > >
> > > > > --
> > > > > "The truth is an offense, but not a sin"
> > > > >
> > > >
> > >
> > >
> > > --
> > > "The truth is an offense, but not a sin"
> > >
> >
>
>
>
> --
>  René Rebe - ExactCODE GmbH - Europe, Germany, Berlin
>  Geschäftsführer: Susanne Klaus, René Rebe
>  Sitz: Berlin, Amtsgericht Charlottenburg HRB 105 123 B
>  USt-IdNr.: DE251602478
>  http://exactcode.de | http://t2-project.org | http://rene.rebe.name
>



More information about the sane-devel mailing list