Hi,
On 07/05/2013 12:29 PM, Maximilian Ferdinand Müller wrote:
> Hello!
>
> We're currently developing a device driver for an usb video grabber based on
> libusbx. We already managed to communicate with the device by using control
> messages (synchronous transfer).
>
> But we're currently experiencing some problems regarding the isochronous data
> transfer which we need in order to gather video data. Every time we try to
> process returning packets we get a segfault in libusbx's reap_for_handle.
> We're not sure whether this is a bug in libusbx (or libusb, we tried both) or
> we're doing something wrong.
>
> You can find the gdb-backtrace attached to this mail.
>
> This is how we set up isoc. transfer:
>
> int init_iso_transfer(int num_iso_packets, int buffer_size,
> stk1160_process_data_cb_handler handler)
> {
> pthread_create(&thread, NULL, libusb_event_handling_thread,
> "libusb_event_handling_thread");
>
> // TODO: cb_handler in libusb_transfer->user_data reinstopfen
> cb_handler = handler;
> uint8_t *buffer;
>
> struct libusb_transfer *transfer;
> transfer = libusb_alloc_transfer(num_iso_packets);
> printf("init_iso_transfer: transfer == %p\n", transfer);
>
> buffer = malloc(buffer_size);
> int ret;
> libusb_fill_iso_transfer(transfer, stk1160_usb_device_handle,
> USB_ENDPOINT_IN | 0x2, buffer, buffer_size, num_iso_packets, iso_handler,
> NULL,
> 100);
>
> libusb_set_iso_packet_lengths(transfer, buffer_size);
This is wrong, either you need to alloc a buffer of buffer_size *
num_iso_packets
size, or you need to make this:
libusb_set_iso_packet_lengths(transfer, buffer_size / num_iso_packets);
Now you're telling libusb / the kernel to receive (num_iso_packets *
buffer_size)
bytes of data, but are only giving it buffer_size bytes to store it in, hence
the
segfault.
Regards,
Hans
------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:
Build for Windows Store.
http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
libusbx-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libusbx-devel