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);
    
    libusb_set_interface_alt_setting(stk1160_usb_device_handle, 0, 5);
    ret = libusb_submit_transfer(transfer);
    printf("init_iso_transfer: ret2 == %d \"%s\"\n", ret, 
libusb_error_name(ret));  
}

The event handling is done by this thread:

void* libusb_event_handling_thread(void* aPointer)
{
    struct timespec sleeptime = { 0, 1000*1000*10 };
    puts("hey ho!");
    nanosleep(&sleeptime, NULL);
    
    while (1)
    {
        printf("libusb_event_handling_thread ...\n");
        nanosleep(&sleeptime, NULL);
        struct timeval t = {0, 0};
        libusb_handle_events_timeout_completed(stk1160_ctx, &t, NULL);
        libusb_handle_events(stk1160_ctx);
    }
}

We would appreciate any help regarding this matter.

Philipp Rosenkranz
Maximilian Mueller
libusb_event_handling_thread ...
[ 0.035532] [000031a6] libusbx: debug [libusb_handle_events_timeout_completed] 
doing our own event handling
[ 0.035620] [000031a6] libusbx: debug [handle_events] poll() 4 fds with timeout 
in 0ms
[ 0.035638] [000031a6] libusbx: debug [handle_events] poll() returned 1
op_handle_events: (handle, hpriv) == (0x804c238, 0x804c264)
reap_for_handle: hpriv->fd == 13
reap_for_handle: usr->usercontext == 0x9800a80
reap_for_handle: transfer == 0x9800ab4
[ 0.035714] [000031a6] libusbx: debug [reap_for_handle] urb type=128 status=0 
transferred=21504

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xf75cbb40 (LWP 12710)]
0xf7faf560 in reap_for_handle (handle=0x804c238) at os/linux_usbfs.c:2450
2450            switch (transfer->type) {
(gdb) bt
#0  0xf7faf560 in reap_for_handle (handle=0x804c238) at os/linux_usbfs.c:2450
#1  0xf7faf706 in op_handle_events (ctx=0x804c008, fds=0xf6c00468, nfds=4, 
num_ready=0) at os/linux_usbfs.c:2495
#2  0xf7fa870a in handle_events (ctx=0x804c008, tv=0xf75cb324) at io.c:1986
#3  0xf7fa88af in libusb_handle_events_timeout_completed (ctx=0x804c008, 
tv=0xf75cb350, completed=0x0) at io.c:2066
#4  0x080490a2 in libusb_event_handling_thread (aPointer=0x80496c8) at 
main.c:204
#5  0xf7f8ae52 in start_thread () from /lib/libpthread.so.0
#6  0xf7ec1e7e in clone () from /lib/libc.so.6
------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
libusbx-devel mailing list
libusbx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusbx-devel

Reply via email to