Pawel Kot
2007-11-20 21:28:28 UTC
Hi,
In gnokii project I make use of libusb when connecting via DKU2 cables
to Nokia phones. So far everything looked good. However recently it
turned out that usb_bulk_read() looses data. Code to read the data is:
retval = usb_bulk_read(DEVINSTANCE(state)->interface->dev_data,
DEVINSTANCE(state)->interface->data_endpoint_read,
(char *) bytes, size, USB_FBUS_TIMEOUT);
When size is big enough to store all response it's fine. But when the
buffer is to small, and I need to read twice, 64 bytes is being lost
between two calls.
Here's the example:
When size is set to 1024 I got:
[libusb] 1b 0c 00 14 01 be 01 78 00 13 00 05 01 58 02 12
[libusb] 00 53 00 6b 00 72 00 7a 00 79 00 6e 00 6b 00 61
[libusb] 00 20 00 6f 00 64 00 62 00 69 00 6f 00 72 00 63
[libusb] 00 7a 00 61 00 00 00 00 00 00 00 00 00 00 00 00
[libusb] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[libusb] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[libusb] 00 00 00 00 01 58 03 0f 00 57 00 69 00 61 00 64
[libusb] 00 6f 00 6d 00 2e 00 20 00 77 00 79 00 73 01 42
[libusb] 00 61 00 6e 00 65 00 00 00 00 00 00 00 00 00 00
[libusb] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[libusb] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[libusb] 00 00 00 00 00 00 00 00 00 00 00 00 01 58 04 13
[libusb] 00 5a 00 61 00 70 00 69 00 73 00 2e 00 20 00 77
[libusb] 00 69 00 61 00 64 00 2e 00 20 00 74 00 65 00 6b
[libusb] 00 73 00 74 00 2e 00 00 00 00 00 00 00 00 00 00
[libusb] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[libusb] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[libusb] 00 00 00 00 01 58 05 08 00 53 00 7a 00 61 00 62
[libusb] 00 6c 00 6f 00 6e 00 79 00 00 61 00 64 00 61 00
[libusb] 77 00 63 00 7a 00 61 00 00 00 00 00 00 00 00 00
[libusb] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[libusb] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[libusb] 00 00 00 00 00 00 00 00 00 00 00 00 01 58 1a 10
[libusb] 00 53 00 6b 00 72 00 7a 00 79 00 6e 00 2e 00 20
[libusb] 00 6e 00 61 00 64 00 61 00 77 00 63 00 7a 00 61
[libusb] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[libusb] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[libusb] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[libusb] 00 00 00 00
When size is set to 255 I got:
[libusb] 1b 0c 00 14 01 be 01 78 00 13 00 05 01 58 02 12
[libusb] 00 53 00 6b 00 72 00 7a 00 79 00 6e 00 6b 00 61
[libusb] 00 20 00 6f 00 64 00 62 00 69 00 6f 00 72 00 63
[libusb] 00 7a 00 61 00 00 00 00 00 00 00 00 00 00 00 00
[libusb] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[libusb] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[libusb] 00 00 00 00 01 58 03 0f 00 57 00 69 00 61 00 64
[libusb] 00 6f 00 6d 00 2e 00 20 00 77 00 79 00 73 01 42
[libusb] 00 61 00 6e 00 65 00 00 00 00 00 00 00 00 00 00
[libusb] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[libusb] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[libusb] 00 00 00 00 00 00 00 00 00 00 00 00 01 58 04 13
[libusb] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[libusb] 00 00 00 00 01 58 05 08 00 53 00 7a 00 61 00 62
[libusb] 00 6c 00 6f 00 6e 00 79 00 00 61 00 64 00 61 00
[libusb] 77 00 63 00 7a 00 61 00 00 00 00 00 00 00 00 00
[libusb] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[libusb] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[libusb] 00 00 00 00 00 00 00 00 00 00 00 00 01 58 1a 10
[libusb] 00 53 00 6b 00 72 00 7a 00 79 00 6e 00 2e 00 20
[libusb] 00 6e 00 61 00 64 00 61 00 77 00 63 00 7a 00 61
[libusb] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[libusb] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[libusb] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[libusb] 00 00 00 00
So as you can see 64 bytes are missing in the middle. It's with CVS
version from 0.1 branch and the one shipped by Ubuntu.
What am I doing wrong? Or is it a bug in libusb?
take care,
pkot
PS. Please Cc me on replies.
In gnokii project I make use of libusb when connecting via DKU2 cables
to Nokia phones. So far everything looked good. However recently it
turned out that usb_bulk_read() looses data. Code to read the data is:
retval = usb_bulk_read(DEVINSTANCE(state)->interface->dev_data,
DEVINSTANCE(state)->interface->data_endpoint_read,
(char *) bytes, size, USB_FBUS_TIMEOUT);
When size is big enough to store all response it's fine. But when the
buffer is to small, and I need to read twice, 64 bytes is being lost
between two calls.
Here's the example:
When size is set to 1024 I got:
[libusb] 1b 0c 00 14 01 be 01 78 00 13 00 05 01 58 02 12
[libusb] 00 53 00 6b 00 72 00 7a 00 79 00 6e 00 6b 00 61
[libusb] 00 20 00 6f 00 64 00 62 00 69 00 6f 00 72 00 63
[libusb] 00 7a 00 61 00 00 00 00 00 00 00 00 00 00 00 00
[libusb] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[libusb] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[libusb] 00 00 00 00 01 58 03 0f 00 57 00 69 00 61 00 64
[libusb] 00 6f 00 6d 00 2e 00 20 00 77 00 79 00 73 01 42
[libusb] 00 61 00 6e 00 65 00 00 00 00 00 00 00 00 00 00
[libusb] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[libusb] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[libusb] 00 00 00 00 00 00 00 00 00 00 00 00 01 58 04 13
[libusb] 00 5a 00 61 00 70 00 69 00 73 00 2e 00 20 00 77
[libusb] 00 69 00 61 00 64 00 2e 00 20 00 74 00 65 00 6b
[libusb] 00 73 00 74 00 2e 00 00 00 00 00 00 00 00 00 00
[libusb] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[libusb] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[libusb] 00 00 00 00 01 58 05 08 00 53 00 7a 00 61 00 62
[libusb] 00 6c 00 6f 00 6e 00 79 00 00 61 00 64 00 61 00
[libusb] 77 00 63 00 7a 00 61 00 00 00 00 00 00 00 00 00
[libusb] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[libusb] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[libusb] 00 00 00 00 00 00 00 00 00 00 00 00 01 58 1a 10
[libusb] 00 53 00 6b 00 72 00 7a 00 79 00 6e 00 2e 00 20
[libusb] 00 6e 00 61 00 64 00 61 00 77 00 63 00 7a 00 61
[libusb] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[libusb] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[libusb] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[libusb] 00 00 00 00
When size is set to 255 I got:
[libusb] 1b 0c 00 14 01 be 01 78 00 13 00 05 01 58 02 12
[libusb] 00 53 00 6b 00 72 00 7a 00 79 00 6e 00 6b 00 61
[libusb] 00 20 00 6f 00 64 00 62 00 69 00 6f 00 72 00 63
[libusb] 00 7a 00 61 00 00 00 00 00 00 00 00 00 00 00 00
[libusb] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[libusb] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[libusb] 00 00 00 00 01 58 03 0f 00 57 00 69 00 61 00 64
[libusb] 00 6f 00 6d 00 2e 00 20 00 77 00 79 00 73 01 42
[libusb] 00 61 00 6e 00 65 00 00 00 00 00 00 00 00 00 00
[libusb] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[libusb] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[libusb] 00 00 00 00 00 00 00 00 00 00 00 00 01 58 04 13
[libusb] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[libusb] 00 00 00 00 01 58 05 08 00 53 00 7a 00 61 00 62
[libusb] 00 6c 00 6f 00 6e 00 79 00 00 61 00 64 00 61 00
[libusb] 77 00 63 00 7a 00 61 00 00 00 00 00 00 00 00 00
[libusb] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[libusb] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[libusb] 00 00 00 00 00 00 00 00 00 00 00 00 01 58 1a 10
[libusb] 00 53 00 6b 00 72 00 7a 00 79 00 6e 00 2e 00 20
[libusb] 00 6e 00 61 00 64 00 61 00 77 00 63 00 7a 00 61
[libusb] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[libusb] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[libusb] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[libusb] 00 00 00 00
So as you can see 64 bytes are missing in the middle. It's with CVS
version from 0.1 branch and the one shipped by Ubuntu.
What am I doing wrong? Or is it a bug in libusb?
take care,
pkot
PS. Please Cc me on replies.
--
Pawel Kot
Pawel Kot