[sane-devel] deadlock with sanei_usb_read_bulk

2008-02-11 Thread m. allan noah
excellent work. please keep us informed.

allan

On 2/10/08, J?rgen Ernst jrernst at gmx.de wrote:
 Hi!
 I managed to solve the problem.
 Here it is:
 Canon driver sends a dummy bulk write as shown in the log. It only
 produces errors and I think it's only for delaying bulk reads. We can
 omit that and use a fix delay of 1 ms instead.
 Sanei_USB sets the right endpoints. I can read and write data on
 endpoint 0. It's all as it should be. Now initializing scanner and
 reading buttons is working. Getting access to scandata is following.

 J?rgen Ernst wrote:
  Hi!
 
  I'm trying to write the backend for Canon LiDE 600F and now I'm stuck
  with sanei_usb_read_bulk. I tried 10 hours but I don't understand how to
  get sanei_usb working with bulk_read. Can somebody help me out?
 
  Here are some details:
 
  Canon LiDE 600F is similar to Canon LiDE 70. I checked this with two
  guys owning a LiDE 70. So you can read some info on
  http://www.sane-project.org/unsupported/canon-lide-70.html
 
  ...
  endpoint 0
 bEndpointAddress  0x02 (out 0x02)
 bmAttributes  2 (bulk)
  ...
  endpoint 0
 bEndpointAddress  0x83 (in 0x03)
 bmAttributes  2 (bulk)
  ...
 
  For short:
  LiDE 600F has only two endpoints. Both bulk no interrupt. In the log
  file no control messages are used. Only simple bulk read and write.
 
  I programmed a perl script with which I was able to access the scanner
  and retrieve scan data.
 
  So this was the point to start writing the sane backend in C.
 
  Okay, let's look first on a perl code snippet:
 
  sub canon_get
  {
 my ( $reg ) = @_ ;
 my $data = '01 ' . $reg . ' 01 00' ;
 my $err = $dev-bulk_write(hex('02'), hex2bin($data), $timeout);
 
 my $data = \0 x 512 ;
 my $cnt = $dev-bulk_write(hex('03'), $data, $timeout);
 
 my $data = ' ' ;
 my $cnt = $dev-bulk_read(hex('83'), $data, 1, $timeout) ;
 return ( $data ) ;
  }
 
  This is the procedure to get 1 byte of data from the CP2155 chip.
  Suppose we called canon_get('91'); then $reg is '91' in hex.
  $data is set to '01 91 01 00'.
  I made it this way to better check with output from log.
  hex2bin converts this string to binary.
 
  Then a first bulk_write is made. In perl I had to give the
  bEndpointAddress '02' while in sanei_usb I saw I had to give the
  endpoint number as an integer (endpoint 0).
 
  Second is a dummy write on the other endpoint (endpoint 1) with 512
  bytes of data.
 
  Third we can get the result with a 1 byte bulk_read on endpoint 1.
 
  That's it.
 
  But it doesn't work in sane.
 
  Here's the snippet of my test procedure in C:
 
  static byte setup_buffer[] = { 0, 0, 0, 0, ... ,0 };
 
  static SANE_Status
  CP2155get (CP2155_Register reg, byte *data)
  {
 SANE_Status status;
 size_t count;
 
 setup_buffer[0] = 0x01;
 setup_buffer[1] = (reg)  0xFF;
 setup_buffer[2] = 0x01;
 setup_buffer[3] = 0x00;
 count = 4;
 
 status = sanei_usb_write_bulk (0, setup_buffer, count);
 
 if (status != SANE_STATUS_GOOD)
   DBG (1, CP2155get: sanei_usb_write_bulk.1 error\n);
 
 count = 512;
 status = sanei_usb_write_bulk (0, setup_buffer, count);
 
 if (status != SANE_STATUS_GOOD)
   DBG (1, CP2155get: sanei_usb_write_bulk.2 error\n);
 
 count = 1;
 status = sanei_usb_read_bulk (0, data, count);
 
 if (status != SANE_STATUS_GOOD)
   DBG (1, CP2155get: sanei_usb_read_bulk error\n);
 
 return status;
  }
 
  setup_buffer is an array with 512 bytes.
 
  The first two bulk_writes didn't return any error.
  It seems that they worked fine.
 
  On the last bulk_read the program hangs forever.
 
  I surely did a mistake but I don't know where and why.
  Please help.


 --
 sane-devel mailing list: sane-devel at lists.alioth.debian.org
 http://lists.alioth.debian.org/mailman/listinfo/sane-devel
 Unsubscribe: Send mail with subject unsubscribe your_password
  to sane-devel-request at lists.alioth.debian.org



-- 
The truth is an offense, but not a sin



[sane-devel] deadlock with sanei_usb_read_bulk

2008-02-10 Thread Jürgen Ernst
Hi!

I'm trying to write the backend for Canon LiDE 600F and now I'm stuck 
with sanei_usb_read_bulk. I tried 10 hours but I don't understand how to 
get sanei_usb working with bulk_read. Can somebody help me out?

Here are some details:

Canon LiDE 600F is similar to Canon LiDE 70. I checked this with two 
guys owning a LiDE 70. So you can read some info on
http://www.sane-project.org/unsupported/canon-lide-70.html

...
endpoint 0
   bEndpointAddress  0x02 (out 0x02)
   bmAttributes  2 (bulk)
...
endpoint 0
   bEndpointAddress  0x83 (in 0x03)
   bmAttributes  2 (bulk)
...

For short:
LiDE 600F has only two endpoints. Both bulk no interrupt. In the log 
file no control messages are used. Only simple bulk read and write.

I programmed a perl script with which I was able to access the scanner 
and retrieve scan data.

So this was the point to start writing the sane backend in C.

Okay, let's look first on a perl code snippet:

sub canon_get
{
   my ( $reg ) = @_ ;
   my $data = '01 ' . $reg . ' 01 00' ;
   my $err = $dev-bulk_write(hex('02'), hex2bin($data), $timeout);

   my $data = \0 x 512 ;
   my $cnt = $dev-bulk_write(hex('03'), $data, $timeout);

   my $data = ' ' ;
   my $cnt = $dev-bulk_read(hex('83'), $data, 1, $timeout) ;
   return ( $data ) ;
}

This is the procedure to get 1 byte of data from the CP2155 chip.
Suppose we called canon_get('91'); then $reg is '91' in hex.
$data is set to '01 91 01 00'.
I made it this way to better check with output from log.
hex2bin converts this string to binary.

Then a first bulk_write is made. In perl I had to give the 
bEndpointAddress '02' while in sanei_usb I saw I had to give the 
endpoint number as an integer (endpoint 0).

Second is a dummy write on the other endpoint (endpoint 1) with 512 
bytes of data.

Third we can get the result with a 1 byte bulk_read on endpoint 1.

That's it.

But it doesn't work in sane.

Here's the snippet of my test procedure in C:

static byte setup_buffer[] = { 0, 0, 0, 0, ... ,0 };

static SANE_Status
CP2155get (CP2155_Register reg, byte *data)
{
   SANE_Status status;
   size_t count;

   setup_buffer[0] = 0x01;
   setup_buffer[1] = (reg)  0xFF;
   setup_buffer[2] = 0x01;
   setup_buffer[3] = 0x00;
   count = 4;

   status = sanei_usb_write_bulk (0, setup_buffer, count);

   if (status != SANE_STATUS_GOOD)
 DBG (1, CP2155get: sanei_usb_write_bulk.1 error\n);

   count = 512;
   status = sanei_usb_write_bulk (0, setup_buffer, count);

   if (status != SANE_STATUS_GOOD)
 DBG (1, CP2155get: sanei_usb_write_bulk.2 error\n);

   count = 1;
   status = sanei_usb_read_bulk (0, data, count);

   if (status != SANE_STATUS_GOOD)
 DBG (1, CP2155get: sanei_usb_read_bulk error\n);

   return status;
}

setup_buffer is an array with 512 bytes.

The first two bulk_writes didn't return any error.
It seems that they worked fine.

On the last bulk_read the program hangs forever.

I surely did a mistake but I don't know where and why.
Please help.

-- 
Ciao
J?rgen

Microsoft is not the answer. Microsoft is the question.
NO is the answer.



[sane-devel] deadlock with sanei_usb_read_bulk

2008-02-10 Thread Jürgen Ernst
Hi!
I managed to solve the problem.
Here it is:
Canon driver sends a dummy bulk write as shown in the log. It only 
produces errors and I think it's only for delaying bulk reads. We can 
omit that and use a fix delay of 1 ms instead.
Sanei_USB sets the right endpoints. I can read and write data on 
endpoint 0. It's all as it should be. Now initializing scanner and 
reading buttons is working. Getting access to scandata is following.

J?rgen Ernst wrote:
 Hi!
 
 I'm trying to write the backend for Canon LiDE 600F and now I'm stuck 
 with sanei_usb_read_bulk. I tried 10 hours but I don't understand how to 
 get sanei_usb working with bulk_read. Can somebody help me out?
 
 Here are some details:
 
 Canon LiDE 600F is similar to Canon LiDE 70. I checked this with two 
 guys owning a LiDE 70. So you can read some info on
 http://www.sane-project.org/unsupported/canon-lide-70.html
 
 ...
 endpoint 0
bEndpointAddress  0x02 (out 0x02)
bmAttributes  2 (bulk)
 ...
 endpoint 0
bEndpointAddress  0x83 (in 0x03)
bmAttributes  2 (bulk)
 ...
 
 For short:
 LiDE 600F has only two endpoints. Both bulk no interrupt. In the log 
 file no control messages are used. Only simple bulk read and write.
 
 I programmed a perl script with which I was able to access the scanner 
 and retrieve scan data.
 
 So this was the point to start writing the sane backend in C.
 
 Okay, let's look first on a perl code snippet:
 
 sub canon_get
 {
my ( $reg ) = @_ ;
my $data = '01 ' . $reg . ' 01 00' ;
my $err = $dev-bulk_write(hex('02'), hex2bin($data), $timeout);
 
my $data = \0 x 512 ;
my $cnt = $dev-bulk_write(hex('03'), $data, $timeout);
 
my $data = ' ' ;
my $cnt = $dev-bulk_read(hex('83'), $data, 1, $timeout) ;
return ( $data ) ;
 }
 
 This is the procedure to get 1 byte of data from the CP2155 chip.
 Suppose we called canon_get('91'); then $reg is '91' in hex.
 $data is set to '01 91 01 00'.
 I made it this way to better check with output from log.
 hex2bin converts this string to binary.
 
 Then a first bulk_write is made. In perl I had to give the 
 bEndpointAddress '02' while in sanei_usb I saw I had to give the 
 endpoint number as an integer (endpoint 0).
 
 Second is a dummy write on the other endpoint (endpoint 1) with 512 
 bytes of data.
 
 Third we can get the result with a 1 byte bulk_read on endpoint 1.
 
 That's it.
 
 But it doesn't work in sane.
 
 Here's the snippet of my test procedure in C:
 
 static byte setup_buffer[] = { 0, 0, 0, 0, ... ,0 };
 
 static SANE_Status
 CP2155get (CP2155_Register reg, byte *data)
 {
SANE_Status status;
size_t count;
 
setup_buffer[0] = 0x01;
setup_buffer[1] = (reg)  0xFF;
setup_buffer[2] = 0x01;
setup_buffer[3] = 0x00;
count = 4;
 
status = sanei_usb_write_bulk (0, setup_buffer, count);
 
if (status != SANE_STATUS_GOOD)
  DBG (1, CP2155get: sanei_usb_write_bulk.1 error\n);
 
count = 512;
status = sanei_usb_write_bulk (0, setup_buffer, count);
 
if (status != SANE_STATUS_GOOD)
  DBG (1, CP2155get: sanei_usb_write_bulk.2 error\n);
 
count = 1;
status = sanei_usb_read_bulk (0, data, count);
 
if (status != SANE_STATUS_GOOD)
  DBG (1, CP2155get: sanei_usb_read_bulk error\n);
 
return status;
 }
 
 setup_buffer is an array with 512 bytes.
 
 The first two bulk_writes didn't return any error.
 It seems that they worked fine.
 
 On the last bulk_read the program hangs forever.
 
 I surely did a mistake but I don't know where and why.
 Please help.