Re: [linux-usb-devel] Kingsun KS-959 USB IrDA dongle protocol - help needed with control urb for reception

2007-07-16 Thread Alan Stern
On Mon, 16 Jul 2007, Alex Villací­s Lasso wrote:

 The problem is that I am getting a delayed -EPIPE (-32) on the 
 submission callback of the control urb on reception. This -EPIPE is 
 visible in the output of usbmon inside the tarball.
 
 This urb is prepared as follows:
 
 /* Start first reception */
 kingsun-rx_setuprequest-bRequestType = USB_DIR_OUT | 
 USB_TYPE_STANDARD | USB_RECIP_DEVICE;
 kingsun-rx_setuprequest-bRequest = KINGSUN_REQ_RECV;
 kingsun-rx_setuprequest-wValue = cpu_to_le16(0x0200);
 kingsun-rx_setuprequest-wIndex = cpu_to_le16(0x);
 kingsun-rx_setuprequest-wLength = cpu_to_le16(0);
 usb_fill_control_urb(kingsun-rx_urb, kingsun-usbdev,
 usb_rcvctrlpipe(kingsun-usbdev, 0),
 (unsigned char *)kingsun-rx_setuprequest,
 kingsun-rx_buf, KINGSUN_FIFO_SIZE,
 ks959_rcv_irq, kingsun);   
 kingsun-rx_urb-status = 0;
 err = usb_submit_urb(kingsun-rx_urb, GFP_KERNEL);
 if (err) {
 err(ks-959: first urb-submit failed: %d, err);
 goto close_irlap;
 }
 
 This tries to mimic as closely as possible what I am seeing in the 
 SnoopyPro logs. According to the logs, the driver sends a control urb 
 with 0x00 as bRequestType (USB_DIR_OUT | USB_TYPE_STANDARD | 
 USB_RECIP_DEVICE), 0x01 as bRequest, 0x0200 for wValue, 0x for 
 wIndex, 0x for wLength, and expects the device to answer with a data 
 payload that contains the received data. The actual sequence for the 
 setup packet in the logs is [00 01 00 02 00 00 00 00].
 
 The constant KINGSUN_REQ_RECV is defined as 0x01 earlier in the code. I 
 can see from the USB headers (linux/usb/ch9.h), that this value is the 
 same as USB_REQ_CLEAR_FEATURE. So my first guess is that the setup 
 packet is invalid. In particular, I am suspicious of the use of 
 USB_DIR_OUT with a request that is supposed to return data. Also, 
 USB_REQ_CLEAR_FEATURE is supposed to have an answer without any data 
 payload. So I have a couple of questions:
 
 Is this control URB valid?

No.  Of course, there's nothing to stop the device from accepting an 
invalid URB.

 Will the kernel actually send such a control URB over the wire, when 
 requested by the driver?

Yes.  This is not one of the things it checks for.

 Can the kernel handle a data payload for this particular kind of request 
 (USB_REQ_CLEAR_FEATURE)?

The kernel doesn't know or care anything about the type of the request.  
It just tries to do what the driver asks.

 If this control URB is not valid, who is responsible for answering 
 -EPIPE? The device (as a response), or the USB stack (because it rejects 
 the urb without sending it over the wire)?

The device.

 Is it possible that the SnoopyPro log is not showing correct data? How 
 can I be sure?

It seems pretty unlikely that SnoopyPro is making a mistake.  But maybe 
you have misinterpreted the data.

If you want to be sure, you have to use a USB bus analyzer.

 Any comments on this are welcome.

Can you post the portion of the SnoopyPro log containing both the UP
and DOWN reports for this questionable URB?

Alan Stern


-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel


Re: [linux-usb-devel] Kingsun KS-959 USB IrDA dongle protocol - help needed with control urb for reception

2007-07-16 Thread Alex Villací­s Lasso
Alan Stern escribió:

 Any comments on this are welcome.
 

 Can you post the portion of the SnoopyPro log containing both the UP
 and DOWN reports for this questionable URB?

 Alan Stern

   
You can download the raw USB log from 
http://www.palosanto.com/~a_villacis/ks959-2.usblog.bz2 . The XML format 
is no good because it lacks details about the setup packet.

-- 
perl -e '$x=2.4;print sprintf(%.0f + %.0f = %.0f\n,$x,$x,$x+$x);'


-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel


Re: [linux-usb-devel] Kingsun KS-959 USB IrDA dongle protocol - help needed with control urb for reception

2007-07-16 Thread Alan Stern
On Mon, 16 Jul 2007, Alex Villací­s Lasso wrote:

 You can download the raw USB log from 
 http://www.palosanto.com/~a_villacis/ks959-2.usblog.bz2 . The XML format 
 is no good because it lacks details about the setup packet.

I see your problem.  You think the contents of the Setup packet are 
displayed in the DOWN entry for the URB; that's where the 00 01 00 02 
00 00 00 00 comes from.

But you're wrong.  The actual Setup packet contents are in the URB's UP
entry.  I don't know where those other numbers come from; they are
garbage.  For example, look at URB 5.  The DOWN entry shows wLength to
be 0 together with a transfer buffer of length 8.  However the UP entry
shows wLength correctly equal to 8.  Or compare the directions shown in
the DOWN and UP entries for URB 6.

So the contents you want really are: a1 01 00 02 00 00 00 08.  It's a
class-specific request directed to interface 0.  wLength is 0x800 =
4096; a little on the large side considering that the device doesn't
send any data back.

Alan Stern


-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel


Re: [linux-usb-devel] Kingsun KS-959 USB IrDA dongle protocol - help needed with control urb for reception

2007-07-16 Thread Alex Villací­s Lasso
Alan Stern escribió:
 On Mon, 16 Jul 2007, Alex Villací­s Lasso wrote:

   
 You can download the raw USB log from 
 http://www.palosanto.com/~a_villacis/ks959-2.usblog.bz2 . The XML format 
 is no good because it lacks details about the setup packet.
 

 I see your problem.  You think the contents of the Setup packet are 
 displayed in the DOWN entry for the URB; that's where the 00 01 00 02 
 00 00 00 00 comes from.

 But you're wrong.  The actual Setup packet contents are in the URB's UP
 entry.  I don't know where those other numbers come from; they are
 garbage.  For example, look at URB 5.  The DOWN entry shows wLength to
 be 0 together with a transfer buffer of length 8.  However the UP entry
 shows wLength correctly equal to 8.  Or compare the directions shown in
 the DOWN and UP entries for URB 6.

 So the contents you want really are: a1 01 00 02 00 00 00 08.  It's a
 class-specific request directed to interface 0.  wLength is 0x800 =
 4096; a little on the large side considering that the device doesn't
 send any data back.

 Alan Stern

   
Oh, thanks! That was the problem after all. I was reading the logs 
incorrectly.

With the corrected setup packets, I was able to start discovery with 
irattach (as seen with wireshark). The name of my cellphone shows up 
correctly, so far. However, once I try to obexftp -i -l (list directory 
over IrDA transport with OBEX), my machine crashes hard... I think it is 
because I violated the rule that states that usb_control_msg() cannot 
be called from within interrupt context or with a spinlock held ... and 
I use it to implement speed change. Nothing I cannot fix overnight at home.

Thanks again!

-- 
perl -e '$x=2.4;print sprintf(%.0f + %.0f = %.0f\n,$x,$x,$x+$x);'


-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel


Re: [linux-usb-devel] Kingsun KS-959 USB IrDA dongle protocol - help needed with control urb for reception

2007-07-16 Thread Alan Stern
On Mon, 16 Jul 2007, Alex Villací­s Lasso wrote:

 Oh, thanks! That was the problem after all. I was reading the logs 
 incorrectly.

You're welcome.

 With the corrected setup packets, I was able to start discovery with 
 irattach (as seen with wireshark). The name of my cellphone shows up 
 correctly, so far. However, once I try to obexftp -i -l (list directory 
 over IrDA transport with OBEX), my machine crashes hard... I think it is 
 because I violated the rule that states that usb_control_msg() cannot 
 be called from within interrupt context or with a spinlock held ... and 
 I use it to implement speed change.

That would certainly do it.  :-)

  Nothing I cannot fix overnight at home.

Alan Stern


-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel