2016-05-05 20 views
1

Ich arbeite an der Portierung einer vorhandenen, funktionalen C# -Anwendung, die wir verwendet FTDI D2XX C# .NET wrapper unter Windows, über Linux und Mono. Ich habe die Anweisungen zur Installation der Linux D2XX driver eingehalten. Wenn festgestellt wird, dass wir Linux verwenden, suchen und laden wir den Linux-Treiber im C# .NET-Wrapper anstelle des Windows-Treibers.FTDI D2XX C# .NET Wrapper läuft unter Linux/Mono - SetEventNotification ausgelöst scheint Crash-Programm

Nach dieser Arbeit ist ein Großteil unseres Anwendungscodes noch in Ordnung, aber wenn das mit der SetEventNotification-Funktion festgelegte Ereignis bei einem FT_EVENT_RXCHAR-Ereignis ausgelöst wird, stürzt die Anwendung ab.

Der Fluss der C# Anwendung ist:

  1. Kommunikation mit dem FTDI Gerät
  2. SetEventNotification benachrichtigt werden, einrichten, wenn neue Daten vom Gerät FTDI verfügbar sind
  3. Ping das FTDI-Gerät, lassen sie wissen, dass wir bereit und wir würden einige Daten
  4. Wenn neuer Daten informiert wie (von der SetEventNotification verwendet wird), hat einige Dinge mit ihm

Etwas ausführlicher:

  • Read'ing und Write'ing mit der # Wrapper C scheinen gut
      auf Linux/Mono zu arbeiten
    • Das Gerät zuerst pinged wird ein Schreib verwendet wird, dann wird die folgende Reads sind erfolgreich
  • Beispielcode verwenden Sie in der Bedienungsanleitung D2XX Programmer zur Verfügung gestellt, C-Code auf Linux geschrieben nicht abstürzen, wenn SetEventNotification
  • der (scheinbaren) Alternative unter Verwendung des mitgelieferten C# Wrapper die Read auf eine gewünschte Anzahl von Bytes erscheint in geeigneter Weise zu arbeiten auf Linux/Mono

Ein paar Fragen:

  1. gearbeitet hat, das mit dem C# .NET-Wrapper für die D2XX Treiber auf Linux/Mono und hatte dieses Problem?
  2. C# Wrapper SetEventNotification erwartet ein EventWaitHandle, das dann das systemeigene Betriebssystemhandle mithilfe von SafeWaitHandle abruft. Ist es möglich, dass das Problem hier ist?

Jeder Einblick angeboten wird sehr geschätzt.

Edit:

Der Stack-Trace jetzt unten angebracht ist.

Ich habe versucht, zu einem Polling-Ansatz zu wechseln, aber es scheint, dass es möglich ist, einen "Rahmen" von Daten nicht vollständig geschrieben zu haben, wenn wir ein FTDI Read durchführen und wir haben eine Lücke in den Daten.

Ich habe FTDI für einige Hinweise zu diesem Thema kontaktiert. Wird aktualisiert, wenn ich etwas umsetzbares zurück höre.

# mono --debug ./CT4USB.exe 

Native stacktrace: 

    mono() [0x49d5fc] 
    mono() [0x424a0e] 
    /lib/x86_64-linux-gnu/libpthread.so.0(+0x10330) [0x7f3253539330] 
    /lib/x86_64-linux-gnu/libpthread.so.0(pthread_mutex_lock+0x4) [0x7f3253533404] 
    /usr/local/lib/libftd2xx.so(+0x12f52) [0x7f324b9d1f52] 
    /usr/local/lib/libftd2xx.so(+0x134f1) [0x7f324b9d24f1] 
    /usr/local/lib/libftd2xx.so(processor_thread+0x21b) [0x7f324b9d29bd] 
    /lib/x86_64-linux-gnu/libpthread.so.0(+0x8184) [0x7f3253531184] 
    /lib/x86_64-linux-gnu/libc.so.6(clone+0x6d) [0x7f325325e37d] 

Debug info from gdb: 

[New LWP 5654] 
[New LWP 5653] 
[New LWP 5652] 
[New LWP 5645] 
[New LWP 5644] 
[New LWP 5643] 
[New LWP 5642] 
[New LWP 5641] 
[New LWP 5640] 
[New LWP 5639] 
[Thread debugging using libthread_db enabled] 
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". 
0x00007f3253538b9d in nanosleep() at ../sysdeps/unix/syscall-template.S:81 
81 ../sysdeps/unix/syscall-template.S: No such file or directory. 
    Id Target Id   Frame 
    11 Thread 0x7f32523ff700 (LWP 5639) "mono" [email protected]@GLIBC_2.3.2() at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 
    10 Thread 0x7f3252a81700 (LWP 5640) "Finalizer" sem_wait() at ../nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S:85 
    9 Thread 0x7f3253efa700 (LWP 5641) "mono" __clock_nanosleep (clock_id=1, flags=1, req=0x7f3253ef9d80, rem=0x7f325326c974 <__clock_nanosleep+132>) at ../sysdeps/unix/sysv/linux/clock_nanosleep.c:49 
    8 Thread 0x7f324bfff700 (LWP 5642) "Threadpool work" [email protected]@GLIBC_2.3.2() at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S:238 
    7 Thread 0x7f324bdfe700 (LWP 5643) "Threadpool work" [email protected]@GLIBC_2.3.2() at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S:238 
    6 Thread 0x7f324b9be700 (LWP 5644) "Threadpool work" 0x00007f3253250fdd in poll() at ../sysdeps/unix/syscall-template.S:81 
    5 Thread 0x7f324b1bd700 (LWP 5645) "Threadpool work" 0x00007f3253250fdd in poll() at ../sysdeps/unix/syscall-template.S:81 
    4 Thread 0x7f324a7ff700 (LWP 5652) "Threadpool work" [email protected]@GLIBC_2.3.2() at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S:238 
    3 Thread 0x7f3249ffe700 (LWP 5653) "Threadpool work" 0x00007f3253538ed9 in __libc_waitpid (pid=5655, stat_loc=0x7f3249ffce4c, options=0) at ../sysdeps/unix/sysv/linux/waitpid.c:40 
    2 Thread 0x7f32497fd700 (LWP 5654) "Threadpool work" [email protected]@GLIBC_2.3.2() at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 
* 1 Thread 0x7f325405d7c0 (LWP 5638) "mono" 0x00007f3253538b9d in nanosleep() at ../sysdeps/unix/syscall-template.S:81 

Thread 11 (Thread 0x7f32523ff700 (LWP 5639)): 
#0 [email protected]@GLIBC_2.3.2() at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 
#1 0x00000000005f9aec in ??() 
#2 0x00007f3253531184 in start_thread (arg=0x7f32523ff700) at pthread_create.c:312 
#3 0x00007f325325e37d in clone() at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111 

Thread 10 (Thread 0x7f3252a81700 (LWP 5640)): 
#0 sem_wait() at ../nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S:85 
#1 0x000000000061de28 in mono_sem_wait() 
#2 0x00000000005a2076 in ??() 
#3 0x00000000005843d3 in ??() 
#4 0x0000000000624666 in ??() 
#5 0x00007f3253531184 in start_thread (arg=0x7f3252a81700) at pthread_create.c:312 
#6 0x00007f325325e37d in clone() at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111 

Thread 9 (Thread 0x7f3253efa700 (LWP 5641)): 
#0 __clock_nanosleep (clock_id=1, flags=1, req=0x7f3253ef9d80, rem=0x7f325326c974 <__clock_nanosleep+132>) at ../sysdeps/unix/sysv/linux/clock_nanosleep.c:49 
#1 0x00000000006122c8 in ??() 
#2 0x0000000000588244 in ??() 
#3 0x00000000005843d3 in ??() 
#4 0x0000000000624666 in ??() 
#5 0x00007f3253531184 in start_thread (arg=0x7f3253efa700) at pthread_create.c:312 
#6 0x00007f325325e37d in clone() at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111 

Thread 8 (Thread 0x7f324bfff700 (LWP 5642)): 
#0 [email protected]@GLIBC_2.3.2() at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S:238 
#1 0x00000000005fef90 in ??() 
#2 0x00000000006117a2 in ??() 
#3 0x00000000005840fd in ??() 
#4 0x00000000005853e6 in ??() 
#5 0x00000000418b9b0e in ??() 
#6 0x0000000000000000 in ??() 

Thread 7 (Thread 0x7f324bdfe700 (LWP 5643)): 
#0 [email protected]@GLIBC_2.3.2() at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S:238 
#1 0x000000000061b982 in ??() 
#2 0x0000000000586b58 in ??() 
#3 0x00000000005843d3 in ??() 
#4 0x0000000000624666 in ??() 
#5 0x00007f3253531184 in start_thread (arg=0x7f324bdfe700) at pthread_create.c:312 
#6 0x00007f325325e37d in clone() at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111 

Thread 6 (Thread 0x7f324b9be700 (LWP 5644)): 
#0 0x00007f3253250fdd in poll() at ../sysdeps/unix/syscall-template.S:81 
#1 0x00007f324b9f2a52 in linux_netlink_event_thread_main() from /usr/local/lib/libftd2xx.so 
#2 0x00007f3253531184 in start_thread (arg=0x7f324b9be700) at pthread_create.c:312 
#3 0x00007f325325e37d in clone() at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111 

Thread 5 (Thread 0x7f324b1bd700 (LWP 5645)): 
#0 0x00007f3253250fdd in poll() at ../sysdeps/unix/syscall-template.S:81 
#1 0x00007f324b9eb14e in handle_events() from /usr/local/lib/libftd2xx.so 
#2 0x00007f324b9eb569 in libusb_handle_events_timeout_completed() from /usr/local/lib/libftd2xx.so 
#3 0x00007f324b9eb674 in libusb_handle_events_timeout() from /usr/local/lib/libftd2xx.so 
#4 0x00007f324b9c924f in poll_async_libusb() from /usr/local/lib/libftd2xx.so 
#5 0x00007f3253531184 in start_thread (arg=0x7f324b1bd700) at pthread_create.c:312 
#6 0x00007f325325e37d in clone() at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111 

Thread 4 (Thread 0x7f324a7ff700 (LWP 5652)): 
#0 [email protected]@GLIBC_2.3.2() at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S:238 
#1 0x00007f324b9cf9fe in EventWait() from /usr/local/lib/libftd2xx.so 
#2 0x00007f324b9d2651 in reader_thread() from /usr/local/lib/libftd2xx.so 
#3 0x00007f3253531184 in start_thread (arg=0x7f324a7ff700) at pthread_create.c:312 
#4 0x00007f325325e37d in clone() at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111 

Thread 3 (Thread 0x7f3249ffe700 (LWP 5653)): 
#0 0x00007f3253538ed9 in __libc_waitpid (pid=5655, stat_loc=0x7f3249ffce4c, options=0) at ../sysdeps/unix/sysv/linux/waitpid.c:40 
#1 0x000000000049d689 in ??() 
#2 0x0000000000424a0e in ??() 
#3 <signal handler called> 
#4 __GI___pthread_mutex_lock (mutex=0x0) at ../nptl/pthread_mutex_lock.c:66 
#5 0x00007f324b9d1f52 in signalSomeEvents() from /usr/local/lib/libftd2xx.so 
#6 0x00007f324b9d24f1 in ProcessBulkInData() from /usr/local/lib/libftd2xx.so 
#7 0x00007f324b9d29bd in processor_thread() from /usr/local/lib/libftd2xx.so 
#8 0x00007f3253531184 in start_thread (arg=0x7f3249ffe700) at pthread_create.c:312 
#9 0x00007f325325e37d in clone() at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111 

Thread 2 (Thread 0x7f32497fd700 (LWP 5654)): 
#0 [email protected]@GLIBC_2.3.2() at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 
#1 0x00007f324b9cf904 in EventWait() from /usr/local/lib/libftd2xx.so 
#2 0x00007f324b9cbfd1 in write_thread() from /usr/local/lib/libftd2xx.so 
#3 0x00007f3253531184 in start_thread (arg=0x7f32497fd700) at pthread_create.c:312 
#4 0x00007f325325e37d in clone() at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111 

Thread 1 (Thread 0x7f325405d7c0 (LWP 5638)): 
#0 0x00007f3253538b9d in nanosleep() at ../sysdeps/unix/syscall-template.S:81 
#1 0x00000000005fedfa in ??() 
#2 0x000000000061101b in ??() 
#3 0x000000000058415e in ??() 
#4 0x0000000000585309 in ??() 
#5 0x00000000418b3e8d in ??() 
#6 0x00000000015de450 in ??() 
#7 0x00007ffc9ba9b960 in ??() 
#8 0x00007f3253fb8130 in ??() 
#9 0x00007f3252400578 in ??() 
#10 0x00007f3252400528 in ??() 
#11 0x00000000015a41e0 in ??() 
#12 0x00000000418b3e07 in ??() 
#13 0x00007ffc9ba9b4d0 in ??() 
#14 0x00007ffc9ba9b450 in ??() 
/build/buildd/gdb-7.7.1/gdb/dwarf2-frame.c:692: internal-error: Unknown CFI encountered. 
A problem internal to GDB has been detected, 
further debugging may prove unreliable. 
Quit this debugging session? (y or n) [answered Y; input not from terminal] 
/build/buildd/gdb-7.7.1/gdb/dwarf2-frame.c:692: internal-error: Unknown CFI encountered. 
A problem internal to GDB has been detected, 
further debugging may prove unreliable. 
Create a core file of GDB? (y or n) [answered Y; input not from terminal] 

================================================================= 
Got a SIGSEGV while executing native code. This usually indicates 
a fatal error in the mono runtime or one of the native libraries 
used by your application. 
================================================================= 

Aborted (core dumped) 

Bearbeiten Sie die zweite:

Die Darstellungen von Monos SafeWaitHandle und der erwarteten Parameter SetEventNotification sind völlig verschieden. Da die FTDI D2XX-Bibliothek versucht, das SafeWaitHandle als ein EVENT_HANDLE zu behandeln (definiert im Header ftd2xx.h; im Grunde ein pthread_cond_t und pthread_mutex_t), denke ich, dass wir deshalb einen Absturz bekommen.

Ich denke, ich kann mit P/Invoke mit libpthread im FTDI D2XX C# .NET Wrapper, um die notwendigen Konvertierungen zwischen Pthread Bedingungen und Mutexe und Mono SafeWaitHandle durchzuführen. An diesem Punkt muss ich C-Code arbeiten, der für FTDI D2XX auf pthread_cond_wait eine Schleife bildet und blockiert. Ich habe diesen Code noch nicht funktionieren lassen. Es ist unten aufgeführt, wenn jemand Rat hat:

/*/* 

gcc -o SetEventNotification_separate_thread SetEventNotification_separate_thread.c -lpthread -lftd2xx -Wl,-rpath /usr/local/lib 

*/ 

#include <stdlib.h> 
#include <pthread.h> 
#include <stdio.h> 
#include <stdint.h> 
#include "../ftd2xx.h" 

static FT_HANDLE ft_handle; 


// Seems like this sort of stuff should have been provided by FTDI 
static const char *ft_errors[] = 
{ 
    [FT_OK] = "Success", 
    [FT_INVALID_HANDLE] = "Invalid device handle", 
    [FT_DEVICE_NOT_FOUND] = "Device not found", 
    [FT_DEVICE_NOT_OPENED] = "Device not opened", 
    [FT_IO_ERROR] = "Input/output error", 
    [FT_INSUFFICIENT_RESOURCES] = "Insufficient resources", 
    [FT_INVALID_PARAMETER] = "Invalid parameter", 
    [FT_INVALID_BAUD_RATE] = "Invalid baud rate", 
    [FT_DEVICE_NOT_OPENED_FOR_ERASE] = "Device not opened for erase", 
    [FT_DEVICE_NOT_OPENED_FOR_WRITE] = "Device not opened for write", 
    [FT_FAILED_TO_WRITE_DEVICE] = "Failed to write device", 
    [FT_EEPROM_READ_FAILED] = "EEPROM read failed", 
    [FT_EEPROM_WRITE_FAILED] = "EEPROM write failed", 
    [FT_EEPROM_ERASE_FAILED] = "EEPROM erase failed", 
    [FT_EEPROM_NOT_PRESENT] = "EEPROM not present", 
    [FT_EEPROM_NOT_PROGRAMMED] = "EEPROM not programmed", 
    [FT_INVALID_ARGS] = "Invalid argument", 
    [FT_NOT_SUPPORTED] = "Not supported", 
    [FT_OTHER_ERROR] = "Other error" 
}; 

static const int num_ft_errors = sizeof(ft_errors)/sizeof(ft_errors[FT_OK]); 
static const char *ft_strerror(FT_STATUS ft_status) 
{ 
    if (ft_status < 0  // Should be impossible because it is unsigned 
    || ft_status >= num_ft_errors 
    || !ft_errors[ft_status]) 
    { 
    return "Unknown error"; 
    } 
    return ft_errors[ft_status]; 
} 

static void ft_error_exit(const char *str, FT_STATUS ft_status) 
{ 
    if (str && *str) 
    fprintf(stderr, "%s: %sn", str, ft_strerror(ft_status)); 
    else 
    fprintf(stderr, "%sn", ft_strerror(ft_status)); 
    exit(1); 
} 

static void pthread_error_exit(const char *str, int err) 
{ 
    if (str && *str) 
    fprintf(stderr, "%s: %sn", str, strerror(err)); 
    else 
    fprintf(stderr, "%sn", strerror(err)); 
    exit(1); 
} 

static void std_error_exit(const char *str) 
{ 
    perror(str); 
    exit(1); 
} 

// Reader thread function 
static void *reader_func(void *arg) 
{ 
    FT_STATUS ft_status; 
    EVENT_HANDLE eh; 
    DWORD chars_in_q; 
    char buf[8192]; 
    int pterr; 



    if ((pterr = pthread_mutex_init(&eh.eMutex, NULL))) 
    pthread_error_exit("pthread_mutex_init", pterr); 
    if ((pterr = pthread_cond_init(&eh.eCondVar, NULL))) 
    pthread_error_exit("pthread_cond_init", pterr); 

    if ((ft_status = FT_SetEventNotification(ft_handle, FT_EVENT_RXCHAR, 
         (PVOID)&eh)) != FT_OK) 
    ft_error_exit("FT_SetEventNotification", ft_status); 

    for (;;) 
    { 
    printf("at for: chars_in_q: %d\n", chars_in_q); 

    if ((pterr = pthread_mutex_lock(&eh.eMutex))){ 
     pthread_error_exit("pthread_mutex_lock", pterr); 
     printf("pthread_mutex_lock failed...\n"); 
    } 
    printf("pthread_mutex_lock\n"); 
    if ((ft_status = FT_GetQueueStatus(ft_handle, &chars_in_q)) != FT_OK) 
     ft_error_exit("FT_GetQueueStatus", ft_status); 
    printf("before if (chars_in_q == 0): chars_in_q: %d\n", chars_in_q); 
// while (chars_in_q == 0) 
// { 
     printf("<<----------- SetEventNotification pthread_cond_wait --------------->>\n"); 
     if ((pterr = pthread_cond_wait(&eh.eCondVar, &eh.eMutex))) 
     pthread_error_exit("pthread_cond_wait", pterr); 
     printf("pthread_cond_wait\n"); 
     if ((ft_status = FT_GetQueueStatus(ft_handle, 
         &chars_in_q)) != FT_OK) 
     ft_error_exit("FT_GetQueueStatus", ft_status); 
     printf("before if (chars_in_q == 0): chars_in_q: %d\n", chars_in_q); 
// } 
    if ((pterr = pthread_mutex_unlock(&eh.eMutex))) 
     pthread_error_exit("pthread_mutex_unlock", pterr); 

    printf("pthread_mutex_unlock\n"); 

    while (chars_in_q) 
    { 
     printf("at while (chars_in_q): chars_in_q: %d\n", chars_in_q); 

     DWORD len_to_read, len_read; 
     ssize_t len_written; 

     len_to_read = (chars_in_q > sizeof(buf)) ? sizeof(buf) : chars_in_q; 

     if ((ft_status = FT_Read(ft_handle, (LPVOID)buf, 
        len_to_read, &len_read)) != FT_OK) 
     ft_error_exit("FT_Read", ft_status); 
     if (!len_read) 
     { 
     fprintf(stderr, "FT_Read returned no data.n"); 
     exit(1); 
     } 

     len_written = printf("%s\n", buf); 
     printf("len_to_read: %d\n", len_to_read); 
     printf("len_read: %d\n", len_read); 

     chars_in_q -= len_read; 
    } 
    } 
} 

int main(int argc, char *argv[]) 
{ 
    FT_STATUS ft_status; 
    DWORD devCount; 
    DWORD devIndex = 0; // first device 
    DWORD numDevices = 1; 
    char serialNumber[64]; // more than enough room! 

    const unsigned int baudrate = 8000000; 

    FT_DEVICE_LIST_INFO_NODE * devInfo; 
    devInfo = malloc(sizeof(FT_DEVICE_LIST_INFO_NODE)*numDevices); 

    ft_status = FT_CreateDeviceInfoList(&devCount); 

    if( ft_status != FT_OK) 
    { 
    printf("No devices connected!\n"); 
    exit(-1); 
    } 

    printf("Devices found: %d\n", devCount); 

    ft_status = FT_ListDevices((PVOID)devIndex, serialNumber, FT_LIST_BY_INDEX|FT_OPEN_BY_SERIAL_NUMBER); 
    if ( ft_status == FT_OK) 
    { 
    // FT_ListDevices OK, serial number is in serialNumber 
    printf("Device Serial Number: %s\n", serialNumber); 
    } 
    else 
    { 
    // FT_ListDevices failed 
    } 

    ft_status = FT_OpenEx(serialNumber, FT_OPEN_BY_SERIAL_NUMBER, &ft_handle); 

    printf("after calling FT_OpenEx\n"); 

    if ( ft_status == FT_OK) 
    { 
    // FT_OpenEx OK, ft_handle not null 
    printf("FT_OpenEx succeeded\n"); 
    } 
    else 
    { 
    printf("FT_OpenEx failed\n"); 
    } 

    ft_status = FT_SetBaudRate(ft_handle, baudrate); 

    if ( ft_status == FT_OK) 
    { 
    // FT_SetBaudRate OK 
    printf("FT_SetBaudRate succeeded\n"); 
    } 
    else 
    { 
    printf("FT_SetBaudRate failed\n"); 
    } 

    ft_status = FT_SetFlowControl(ft_handle, FT_FLOW_RTS_CTS, 0, 0); 

    if ( ft_status == FT_OK) 
    { 
    // FT_SetFlowControl OK 
    printf("FT_SetFlowControl succeeded\n"); 
    } 
    else 
    { 
    printf("FT_SetFlowControl failed\n"); 
    } 

    // Flush the FTDI's buffers 
    if ((ft_status = FT_Purge(ft_handle, FT_PURGE_RX | FT_PURGE_TX)) != FT_OK) 
    ft_error_exit("FT_Purge", ft_status); 

    // Create reader and writer threads. 
    int pterr; 
    sigset_t sig_set; 
    (void)sigfillset(&sig_set); 
    pthread_attr_t ptattr; 
    if ((pterr = pthread_attr_init(&ptattr))) 
    pthread_error_exit("pthread_attr_init", pterr); 
    if ((pterr = pthread_attr_setdetachstate(&ptattr, 
         PTHREAD_CREATE_DETACHED))) 
    pthread_error_exit("pthread_attr_setdetachstate", pterr); 
    pthread_t reader_id, writer_id; 
    if ((pterr = pthread_create(&reader_id, &ptattr, reader_func, NULL))) 
    pthread_error_exit("pthread_create reader", pterr); 

    // Now wait for a signal to terminate us 
    int caught_sig; 
    if (sigwait(&sig_set, &caught_sig)) 
    std_error_exit("sigwait"); 

    exit(0); 
} 

gcc -o SetEventNotification_separate_thread SetEventNotification_separate_thread.c -lpthread -lftd2xx -Wl,-rpath /usr/local/lib 

*/ 

#include <stdlib.h> 
#include <pthread.h> 
#include <stdio.h> 
#include <stdint.h> 
#include "../ftd2xx.h" 

static FT_HANDLE ft_handle; 


// Seems like this sort of stuff should have been provided by FTDI 
static const char *ft_errors[] = 
{ 
    [FT_OK] = "Success", 
    [FT_INVALID_HANDLE] = "Invalid device handle", 
    [FT_DEVICE_NOT_FOUND] = "Device not found", 
    [FT_DEVICE_NOT_OPENED] = "Device not opened", 
    [FT_IO_ERROR] = "Input/output error", 
    [FT_INSUFFICIENT_RESOURCES] = "Insufficient resources", 
    [FT_INVALID_PARAMETER] = "Invalid parameter", 
    [FT_INVALID_BAUD_RATE] = "Invalid baud rate", 
    [FT_DEVICE_NOT_OPENED_FOR_ERASE] = "Device not opened for erase", 
    [FT_DEVICE_NOT_OPENED_FOR_WRITE] = "Device not opened for write", 
    [FT_FAILED_TO_WRITE_DEVICE] = "Failed to write device", 
    [FT_EEPROM_READ_FAILED] = "EEPROM read failed", 
    [FT_EEPROM_WRITE_FAILED] = "EEPROM write failed", 
    [FT_EEPROM_ERASE_FAILED] = "EEPROM erase failed", 
    [FT_EEPROM_NOT_PRESENT] = "EEPROM not present", 
    [FT_EEPROM_NOT_PROGRAMMED] = "EEPROM not programmed", 
    [FT_INVALID_ARGS] = "Invalid argument", 
    [FT_NOT_SUPPORTED] = "Not supported", 
    [FT_OTHER_ERROR] = "Other error" 
}; 

static const int num_ft_errors = sizeof(ft_errors)/sizeof(ft_errors[FT_OK]); 
static const char *ft_strerror(FT_STATUS ft_status) 
{ 
    if (ft_status < 0  // Should be impossible because it is unsigned 
    || ft_status >= num_ft_errors 
    || !ft_errors[ft_status]) 
    { 
    return "Unknown error"; 
    } 
    return ft_errors[ft_status]; 
} 

static void ft_error_exit(const char *str, FT_STATUS ft_status) 
{ 
    if (str && *str) 
    fprintf(stderr, "%s: %sn", str, ft_strerror(ft_status)); 
    else 
    fprintf(stderr, "%sn", ft_strerror(ft_status)); 
    exit(1); 
} 

static void pthread_error_exit(const char *str, int err) 
{ 
    if (str && *str) 
    fprintf(stderr, "%s: %sn", str, strerror(err)); 
    else 
    fprintf(stderr, "%sn", strerror(err)); 
    exit(1); 
} 

static void std_error_exit(const char *str) 
{ 
    perror(str); 
    exit(1); 
} 

// Reader thread function 
static void *reader_func(void *arg) 
{ 
    FT_STATUS ft_status; 
    EVENT_HANDLE eh; 
    DWORD chars_in_q; 
    char buf[8192]; 
    int pterr; 



    if ((pterr = pthread_mutex_init(&eh.eMutex, NULL))) 
    pthread_error_exit("pthread_mutex_init", pterr); 
    if ((pterr = pthread_cond_init(&eh.eCondVar, NULL))) 
    pthread_error_exit("pthread_cond_init", pterr); 

    if ((ft_status = FT_SetEventNotification(ft_handle, FT_EVENT_RXCHAR, 
         (PVOID)&eh)) != FT_OK) 
    ft_error_exit("FT_SetEventNotification", ft_status); 

    for (;;) 
    { 
    printf("at for: chars_in_q: %d\n", chars_in_q); 

    if ((pterr = pthread_mutex_lock(&eh.eMutex))){ 
     pthread_error_exit("pthread_mutex_lock", pterr); 
     printf("pthread_mutex_lock failed...\n"); 
    } 
    printf("pthread_mutex_lock\n"); 
    if ((ft_status = FT_GetQueueStatus(ft_handle, &chars_in_q)) != FT_OK) 
     ft_error_exit("FT_GetQueueStatus", ft_status); 
    printf("before if (chars_in_q == 0): chars_in_q: %d\n", chars_in_q); 
// while (chars_in_q == 0) 
// { 
     printf("<<----------- SetEventNotification pthread_cond_wait --------------->>\n"); 
     if ((pterr = pthread_cond_wait(&eh.eCondVar, &eh.eMutex))) 
     pthread_error_exit("pthread_cond_wait", pterr); 
     printf("pthread_cond_wait\n"); 
     if ((ft_status = FT_GetQueueStatus(ft_handle, 
         &chars_in_q)) != FT_OK) 
     ft_error_exit("FT_GetQueueStatus", ft_status); 
     printf("before if (chars_in_q == 0): chars_in_q: %d\n", chars_in_q); 
// } 
    if ((pterr = pthread_mutex_unlock(&eh.eMutex))) 
     pthread_error_exit("pthread_mutex_unlock", pterr); 

    printf("pthread_mutex_unlock\n"); 

    while (chars_in_q) 
    { 
     printf("at while (chars_in_q): chars_in_q: %d\n", chars_in_q); 

     DWORD len_to_read, len_read; 
     ssize_t len_written; 

     len_to_read = (chars_in_q > sizeof(buf)) ? sizeof(buf) : chars_in_q; 

     if ((ft_status = FT_Read(ft_handle, (LPVOID)buf, 
        len_to_read, &len_read)) != FT_OK) 
     ft_error_exit("FT_Read", ft_status); 
     if (!len_read) 
     { 
     fprintf(stderr, "FT_Read returned no data.n"); 
     exit(1); 
     } 

     len_written = printf("%s\n", buf); 
     printf("len_to_read: %d\n", len_to_read); 
     printf("len_read: %d\n", len_read); 

     chars_in_q -= len_read; 
    } 
    } 
} 

int main(int argc, char *argv[]) 
{ 
    FT_STATUS ft_status; 
    DWORD devCount; 
    DWORD devIndex = 0; // first device 
    DWORD numDevices = 1; 
    char serialNumber[64]; // more than enough room! 

    const unsigned int baudrate = 8000000; 

    FT_DEVICE_LIST_INFO_NODE * devInfo; 
    devInfo = malloc(sizeof(FT_DEVICE_LIST_INFO_NODE)*numDevices); 

    ft_status = FT_CreateDeviceInfoList(&devCount); 

    if( ft_status != FT_OK) 
    { 
    printf("No devices connected!\n"); 
    exit(-1); 
    } 

    printf("Devices found: %d\n", devCount); 

    ft_status = FT_ListDevices((PVOID)devIndex, serialNumber, FT_LIST_BY_INDEX|FT_OPEN_BY_SERIAL_NUMBER); 
    if ( ft_status == FT_OK) 
    { 
    // FT_ListDevices OK, serial number is in serialNumber 
    printf("Device Serial Number: %s\n", serialNumber); 
    } 
    else 
    { 
    // FT_ListDevices failed 
    } 

    ft_status = FT_OpenEx(serialNumber, FT_OPEN_BY_SERIAL_NUMBER, &ft_handle); 

    printf("after calling FT_OpenEx\n"); 

    if ( ft_status == FT_OK) 
    { 
    // FT_OpenEx OK, ft_handle not null 
    printf("FT_OpenEx succeeded\n"); 
    } 
    else 
    { 
    printf("FT_OpenEx failed\n"); 
    } 

    ft_status = FT_SetBaudRate(ft_handle, baudrate); 

    if ( ft_status == FT_OK) 
    { 
    // FT_SetBaudRate OK 
    printf("FT_SetBaudRate succeeded\n"); 
    } 
    else 
    { 
    printf("FT_SetBaudRate failed\n"); 
    } 

    ft_status = FT_SetFlowControl(ft_handle, FT_FLOW_RTS_CTS, 0, 0); 

    if ( ft_status == FT_OK) 
    { 
    // FT_SetFlowControl OK 
    printf("FT_SetFlowControl succeeded\n"); 
    } 
    else 
    { 
    printf("FT_SetFlowControl failed\n"); 
    } 

    // Flush the FTDI's buffers 
    if ((ft_status = FT_Purge(ft_handle, FT_PURGE_RX | FT_PURGE_TX)) != FT_OK) 
    ft_error_exit("FT_Purge", ft_status); 

    // Create reader and writer threads. 
    int pterr; 
    sigset_t sig_set; 
    (void)sigfillset(&sig_set); 
    pthread_attr_t ptattr; 
    if ((pterr = pthread_attr_init(&ptattr))) 
    pthread_error_exit("pthread_attr_init", pterr); 
    if ((pterr = pthread_attr_setdetachstate(&ptattr, 
         PTHREAD_CREATE_DETACHED))) 
    pthread_error_exit("pthread_attr_setdetachstate", pterr); 
    pthread_t reader_id, writer_id; 
    if ((pterr = pthread_create(&reader_id, &ptattr, reader_func, NULL))) 
    pthread_error_exit("pthread_create reader", pterr); 

    // Now wait for a signal to terminate us 
    int caught_sig; 
    if (sigwait(&sig_set, &caught_sig)) 
    std_error_exit("sigwait"); 

    exit(0); 
} 

Es bleibt immer auf der pthread_cond_wait stecken. Irgendwelche Gedanken würden geschätzt werden.

+0

verwandt ist und der Fehler/Ausnahme ist? – leppie

Antwort

0

Ich habe keine Antwort, ich habe das gleiche Problem. Der Fehler ist

Native stacktrace: 

    /usr/bin/cli() [0x49ff2f] 
    /usr/bin/cli() [0x426c8c] 
    /lib/x86_64-linux-gnu/libpthread.so.0(+0x113d0) [0x7f5bbe6103d0] 
    /lib/x86_64-linux-gnu/libpthread.so.0(pthread_mutex_lock+0x4) [0x7f5bbe608d84] 
    /usr/local/lib/libftd2xx.so(+0x12f52) [0x7f5bad952f52] 
    /usr/local/lib/libftd2xx.so(+0x134f1) [0x7f5bad9534f1] 
    /usr/local/lib/libftd2xx.so(processor_thread+0x21b) [0x7f5bad9539bd] 
    /lib/x86_64-linux-gnu/libpthread.so.0(+0x76fa) [0x7f5bbe6066fa] 
    /lib/x86_64-linux-gnu/libc.so.6(clone+0x6d) [0x7f5bbe33cb5d] 

Debug info from gdb: 

[New LWP 56271] 
[New LWP 56270] 
[New LWP 56269] 
[New LWP 56262] 
[New LWP 56261] 
[New LWP 56259] 
[New LWP 56258] 
[Thread debugging using libthread_db enabled] 
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". 
[email protected]@GLIBC_2.3.2() at ../sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S:225 
225 ../sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S: No such file or directory. 
    Id Target Id   Frame 
* 1 Thread 0x7f5bbf13a780 (LWP 56256) "cli" [email protected]@GLIBC_2.3.2() at ../sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S:225 
    2 Thread 0x7f5ba77fe700 (LWP 56271) "cli" [email protected]@GLIBC_2.3.2() at ../sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 
    3 Thread 0x7f5ba7fff700 (LWP 56270) "cli" 0x00007f5bbe60ffbb in __waitpid (pid=56272, stat_loc=0x7f5ba7ffde7c, options=0) at ../sysdeps/unix/sysv/linux/waitpid.c:29 
    4 Thread 0x7f5bac93d700 (LWP 56269) "cli" [email protected]@GLIBC_2.3.2() at ../sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S:225 
    5 Thread 0x7f5bad13e700 (LWP 56262) "cli" 0x00007f5bbe330e8d in poll() at ../sysdeps/unix/syscall-template.S:84 
    6 Thread 0x7f5bad93f700 (LWP 56261) "cli" 0x00007f5bbe330e8d in poll() at ../sysdeps/unix/syscall-template.S:84 
    7 Thread 0x7f5bbb315700 (LWP 56259) "Finalizer" 0x00007f5bbe60e867 in futex_abstimed_wait_cancelable (private=0, abstime=0x0, expected=0, futex_word=0x956820) at ../sysdeps/unix/sysv/linux/futex-internal.h:205 
    8 Thread 0x7f5bbd3ff700 (LWP 56258) "cli" [email protected]@GLIBC_2.3.2() at ../sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 

Thread 8 (Thread 0x7f5bbd3ff700 (LWP 56258)): 
#0 [email protected]@GLIBC_2.3.2() at ../sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 
#1 0x00000000005fdcdb in ??() 
#2 0x00007f5bbe6066fa in start_thread (arg=0x7f5bbd3ff700) at pthread_create.c:333 
#3 0x00007f5bbe33cb5d in clone() at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109 

Thread 7 (Thread 0x7f5bbb315700 (LWP 56259)): 
#0 0x00007f5bbe60e867 in futex_abstimed_wait_cancelable (private=0, abstime=0x0, expected=0, futex_word=0x956820) at ../sysdeps/unix/sysv/linux/futex-internal.h:205 
#1 do_futex_wait ([email protected]=0x956820, abstime=0x0) at sem_waitcommon.c:111 
#2 0x00007f5bbe60e914 in __new_sem_wait_slow (sem=0x956820, abstime=0x0) at sem_waitcommon.c:181 
#3 0x00007f5bbe60e9ba in __new_sem_wait (sem=<optimized out>) at sem_wait.c:29 
#4 0x0000000000622e06 in mono_sem_wait() 
#5 0x00000000005a5742 in ??() 
#6 0x0000000000587b2b in ??() 
#7 0x0000000000629a8c in ??() 
#8 0x00007f5bbe6066fa in start_thread (arg=0x7f5bbb315700) at pthread_create.c:333 
#9 0x00007f5bbe33cb5d in clone() at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109 

Thread 6 (Thread 0x7f5bad93f700 (LWP 56261)): 
#0 0x00007f5bbe330e8d in poll() at ../sysdeps/unix/syscall-template.S:84 
#1 0x00007f5bad973a52 in linux_netlink_event_thread_main() from /usr/local/lib/libftd2xx.so 
#2 0x00007f5bbe6066fa in start_thread (arg=0x7f5bad93f700) at pthread_create.c:333 
#3 0x00007f5bbe33cb5d in clone() at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109 

Thread 5 (Thread 0x7f5bad13e700 (LWP 56262)): 
#0 0x00007f5bbe330e8d in poll() at ../sysdeps/unix/syscall-template.S:84 
#1 0x00007f5bad96c14e in handle_events() from /usr/local/lib/libftd2xx.so 
#2 0x00007f5bad96c569 in libusb_handle_events_timeout_completed() from /usr/local/lib/libftd2xx.so 
#3 0x00007f5bad96c674 in libusb_handle_events_timeout() from /usr/local/lib/libftd2xx.so 
#4 0x00007f5bad94a24f in poll_async_libusb() from /usr/local/lib/libftd2xx.so 
#5 0x00007f5bbe6066fa in start_thread (arg=0x7f5bad13e700) at pthread_create.c:333 
#6 0x00007f5bbe33cb5d in clone() at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109 

Thread 4 (Thread 0x7f5bac93d700 (LWP 56269)): 
#0 [email protected]@GLIBC_2.3.2() at ../sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S:225 
#1 0x00007f5bad9509fe in EventWait() from /usr/local/lib/libftd2xx.so 
#2 0x00007f5bad953651 in reader_thread() from /usr/local/lib/libftd2xx.so 
#3 0x00007f5bbe6066fa in start_thread (arg=0x7f5bac93d700) at pthread_create.c:333 
#4 0x00007f5bbe33cb5d in clone() at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109 

Thread 3 (Thread 0x7f5ba7fff700 (LWP 56270)): 
#0 0x00007f5bbe60ffbb in __waitpid (pid=56272, stat_loc=0x7f5ba7ffde7c, options=0) at ../sysdeps/unix/sysv/linux/waitpid.c:29 
#1 0x00000000004a0006 in ??() 
#2 0x0000000000426c8c in ??() 
#3 <signal handler called> 
#4 __GI___pthread_mutex_lock (mutex=0x438) at ../nptl/pthread_mutex_lock.c:67 
#5 0x00007f5bad952f52 in signalSomeEvents() from /usr/local/lib/libftd2xx.so 
#6 0x00007f5bad9534f1 in ProcessBulkInData() from /usr/local/lib/libftd2xx.so 
#7 0x00007f5bad9539bd in processor_thread() from /usr/local/lib/libftd2xx.so 
#8 0x00007f5bbe6066fa in start_thread (arg=0x7f5ba7fff700) at pthread_create.c:333 
#9 0x00007f5bbe33cb5d in clone() at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109 

Thread 2 (Thread 0x7f5ba77fe700 (LWP 56271)): 
#0 [email protected]@GLIBC_2.3.2() at ../sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 
#1 0x00007f5bad950904 in EventWait() from /usr/local/lib/libftd2xx.so 
#2 0x00007f5bad94cfd1 in write_thread() from /usr/local/lib/libftd2xx.so 
#3 0x00007f5bbe6066fa in start_thread (arg=0x7f5ba77fe700) at pthread_create.c:333 
#4 0x00007f5bbe33cb5d in clone() at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109 

Thread 1 (Thread 0x7f5bbf13a780 (LWP 56256)): 
#0 [email protected]@GLIBC_2.3.2() at ../sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S:225 
#1 0x000000000060306e in ??() 
#2 0x0000000000615b72 in ??() 
#3 0x00000000005875af in ??() 
#4 0x000000000058763d in ??() 
#5 0x00000000412c35dd in ??() 
#6 0x0000000000000001 in ??() 
#7 0x00007f5bbd6c69c0 in ??() 
#8 0x00007f5bbd6c69c0 in ??() 
#9 0x00007f5bbd6c6d10 in ??() 
#10 0x0000000000001388 in ??() 
#11 0x0000000001644140 in ??() 
#12 0x00000000412c3560 in ??() 
#13 0x00007fff13c419e0 in ??() 
#14 0x00007fff13c41950 in ??() 
/build/gdb-sqtpXm/gdb-7.11/gdb/dwarf2-frame.c:690: internal-error: Unknown CFI encountered. 
A problem internal to GDB has been detected, 
further debugging may prove unreliable. 
Quit this debugging session? (y or n) [answered Y; input not from terminal] 

This is a bug, please report it. For instructions, see: 
<http://www.gnu.org/software/gdb/bugs/>. 

/build/gdb-sqtpXm/gdb-7.11/gdb/dwarf2-frame.c:690: internal-error: Unknown CFI encountered. 
A problem internal to GDB has been detected, 
further debugging may prove unreliable. 
Create a core file of GDB? (y or n) [answered Y; input not from terminal] 

================================================================= 
Got a SIGSEGV while executing native code. This usually indicates 
a fatal error in the mono runtime or one of the native libraries 
used by your application. 
================================================================= 

Aborted (core dumped) 
[email protected]:/home/hglenni/FTDI/MonoTestApp# chmod +x MonoTestApp.exe 
[email protected]:/home/hglenni/FTDI/MonoTestApp# sudo ./MonoTestApp.exe 

Native stacktrace: 

    /usr/bin/cli() [0x49ff2f] 
    /usr/bin/cli() [0x426c8c] 
    /lib/x86_64-linux-gnu/libpthread.so.0(+0x113d0) [0x7f6f1a2e53d0] 
    /lib/x86_64-linux-gnu/libpthread.so.0(pthread_mutex_lock+0x4) [0x7f6f1a2ddd84] 
    /usr/local/lib/libftd2xx.so(+0x12f52) [0x7f6f09695f52] 
    /usr/local/lib/libftd2xx.so(+0x134f1) [0x7f6f096964f1] 
    /usr/local/lib/libftd2xx.so(processor_thread+0x21b) [0x7f6f096969bd] 
    /lib/x86_64-linux-gnu/libpthread.so.0(+0x76fa) [0x7f6f1a2db6fa] 
    /lib/x86_64-linux-gnu/libc.so.6(clone+0x6d) [0x7f6f1a011b5d] 

Debug info from gdb: 

[New LWP 56334] 
[New LWP 56333] 
[New LWP 56332] 
[New LWP 56325] 
[New LWP 56324] 
[New LWP 56319] 
[New LWP 56318] 
[Thread debugging using libthread_db enabled] 
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". 
[email protected]@GLIBC_2.3.2() at ../sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S:225 
225 ../sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S: No such file or directory. 
    Id Target Id   Frame 
* 1 Thread 0x7f6f1ae0f780 (LWP 56316) "cli" [email protected]@GLIBC_2.3.2() at ../sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S:225 
    2 Thread 0x7f6f02ffd700 (LWP 56334) "cli" [email protected]@GLIBC_2.3.2() at ../sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 
    3 Thread 0x7f6f037fe700 (LWP 56333) "cli" 0x00007f6f1a2e4fbb in __waitpid (pid=56335, stat_loc=0x7f6f037fce7c, options=0) at ../sysdeps/unix/sysv/linux/waitpid.c:29 
    4 Thread 0x7f6f03fff700 (LWP 56332) "cli" [email protected]@GLIBC_2.3.2() at ../sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S:225 
    5 Thread 0x7f6f08e81700 (LWP 56325) "cli" 0x00007f6f1a005e8d in poll() at ../sysdeps/unix/syscall-template.S:84 
    6 Thread 0x7f6f09682700 (LWP 56324) "cli" 0x00007f6f1a005e8d in poll() at ../sysdeps/unix/syscall-template.S:84 
    7 Thread 0x7f6f16f15700 (LWP 56319) "Finalizer" 0x00007f6f1a2e3867 in futex_abstimed_wait_cancelable (private=0, abstime=0x0, expected=0, futex_word=0x956820) at ../sysdeps/unix/sysv/linux/futex-internal.h:205 
    8 Thread 0x7f6f18fff700 (LWP 56318) "cli" [email protected]@GLIBC_2.3.2() at ../sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 

Thread 8 (Thread 0x7f6f18fff700 (LWP 56318)): 
#0 [email protected]@GLIBC_2.3.2() at ../sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 
#1 0x00000000005fdcdb in ??() 
#2 0x00007f6f1a2db6fa in start_thread (arg=0x7f6f18fff700) at pthread_create.c:333 
#3 0x00007f6f1a011b5d in clone() at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109 

Thread 7 (Thread 0x7f6f16f15700 (LWP 56319)): 
#0 0x00007f6f1a2e3867 in futex_abstimed_wait_cancelable (private=0, abstime=0x0, expected=0, futex_word=0x956820) at ../sysdeps/unix/sysv/linux/futex-internal.h:205 
#1 do_futex_wait ([email protected]=0x956820, abstime=0x0) at sem_waitcommon.c:111 
#2 0x00007f6f1a2e3914 in __new_sem_wait_slow (sem=0x956820, abstime=0x0) at sem_waitcommon.c:181 
#3 0x00007f6f1a2e39ba in __new_sem_wait (sem=<optimized out>) at sem_wait.c:29 
#4 0x0000000000622e06 in mono_sem_wait() 
#5 0x00000000005a5742 in ??() 
#6 0x0000000000587b2b in ??() 
#7 0x0000000000629a8c in ??() 
#8 0x00007f6f1a2db6fa in start_thread (arg=0x7f6f16f15700) at pthread_create.c:333 
#9 0x00007f6f1a011b5d in clone() at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109 

Thread 6 (Thread 0x7f6f09682700 (LWP 56324)): 
#0 0x00007f6f1a005e8d in poll() at ../sysdeps/unix/syscall-template.S:84 
#1 0x00007f6f096b6a52 in linux_netlink_event_thread_main() from /usr/local/lib/libftd2xx.so 
#2 0x00007f6f1a2db6fa in start_thread (arg=0x7f6f09682700) at pthread_create.c:333 
#3 0x00007f6f1a011b5d in clone() at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109 

Thread 5 (Thread 0x7f6f08e81700 (LWP 56325)): 
#0 0x00007f6f1a005e8d in poll() at ../sysdeps/unix/syscall-template.S:84 
#1 0x00007f6f096af14e in handle_events() from /usr/local/lib/libftd2xx.so 
#2 0x00007f6f096af569 in libusb_handle_events_timeout_completed() from /usr/local/lib/libftd2xx.so 
#3 0x00007f6f096af674 in libusb_handle_events_timeout() from /usr/local/lib/libftd2xx.so 
#4 0x00007f6f0968d24f in poll_async_libusb() from /usr/local/lib/libftd2xx.so 
#5 0x00007f6f1a2db6fa in start_thread (arg=0x7f6f08e81700) at pthread_create.c:333 
#6 0x00007f6f1a011b5d in clone() at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109 

Thread 4 (Thread 0x7f6f03fff700 (LWP 56332)): 
#0 [email protected]@GLIBC_2.3.2() at ../sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S:225 
#1 0x00007f6f096939fe in EventWait() from /usr/local/lib/libftd2xx.so 
#2 0x00007f6f09696651 in reader_thread() from /usr/local/lib/libftd2xx.so 
#3 0x00007f6f1a2db6fa in start_thread (arg=0x7f6f03fff700) at pthread_create.c:333 
#4 0x00007f6f1a011b5d in clone() at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109 

Thread 3 (Thread 0x7f6f037fe700 (LWP 56333)): 
#0 0x00007f6f1a2e4fbb in __waitpid (pid=56335, stat_loc=0x7f6f037fce7c, options=0) at ../sysdeps/unix/sysv/linux/waitpid.c:29 
#1 0x00000000004a0006 in ??() 
#2 0x0000000000426c8c in ??() 
#3 <signal handler called> 
#4 __GI___pthread_mutex_lock (mutex=0x438) at ../nptl/pthread_mutex_lock.c:67 
#5 0x00007f6f09695f52 in signalSomeEvents() from /usr/local/lib/libftd2xx.so 
#6 0x00007f6f096964f1 in ProcessBulkInData() from /usr/local/lib/libftd2xx.so 
#7 0x00007f6f096969bd in processor_thread() from /usr/local/lib/libftd2xx.so 
#8 0x00007f6f1a2db6fa in start_thread (arg=0x7f6f037fe700) at pthread_create.c:333 
#9 0x00007f6f1a011b5d in clone() at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109 

Thread 2 (Thread 0x7f6f02ffd700 (LWP 56334)): 
#0 [email protected]@GLIBC_2.3.2() at ../sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 
#1 0x00007f6f09693904 in EventWait() from /usr/local/lib/libftd2xx.so 
#2 0x00007f6f0968ffd1 in write_thread() from /usr/local/lib/libftd2xx.so 
#3 0x00007f6f1a2db6fa in start_thread (arg=0x7f6f02ffd700) at pthread_create.c:333 
#4 0x00007f6f1a011b5d in clone() at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109 

Thread 1 (Thread 0x7f6f1ae0f780 (LWP 56316)): 
#0 [email protected]@GLIBC_2.3.2() at ../sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S:225 
#1 0x000000000060306e in ??() 
#2 0x0000000000615b72 in ??() 
#3 0x00000000005875af in ??() 
#4 0x000000000058763d in ??() 
#5 0x0000000040b7d5dd in ??() 
#6 0x0000000000000001 in ??() 
#7 0x00007f6f192c5f20 in ??() 
#8 0x00007f6f192c5f20 in ??() 
#9 0x00007f6f192c6270 in ??() 
#10 0x0000000000001388 in ??() 
#11 0x00000000020db150 in ??() 
#12 0x0000000040b7d560 in ??() 
#13 0x00007fff1691a470 in ??() 
#14 0x00007fff1691a3e0 in ??() 
/build/gdb-sqtpXm/gdb-7.11/gdb/dwarf2-frame.c:690: internal-error: Unknown CFI encountered. 
A problem internal to GDB has been detected, 
further debugging may prove unreliable. 
Quit this debugging session? (y or n) [answered Y; input not from terminal] 

This is a bug, please report it. For instructions, see: 
<http://www.gnu.org/software/gdb/bugs/>. 

/build/gdb-sqtpXm/gdb-7.11/gdb/dwarf2-frame.c:690: internal-error: Unknown CFI encountered. 
A problem internal to GDB has been detected, 
further debugging may prove unreliable. 
Create a core file of GDB? (y or n) [answered Y; input not from terminal] 
n 
+0

Siehe bearbeiten zu OP. Der Stacktrace sieht sehr ähnlich aus. Ich habe FTDI um Rat gefragt, wie es weitergehen soll. – Peter

0

Wieder keine Antwort, aber ich weiß nicht, wie Mono EventWaitHandle.SafeWaitHandle definiert.

Im Beispiel von FTDI für Linux (c) sofern dies ist die Definition

FT_HANDLE ftHandle; 
FT_STATUS ftStatus; 
EVENT_HANDLE eh; 
DWORD EventMask; 

ftStatus = FT_Open(0, &ftHandle); 
if(ftStatus != FT_OK) { 
    // FT_Open failed 
    return; 
} 

pthread_mutex_init(&eh.eMutex, NULL); 
pthread_cond_init(&eh.eCondVar, NULL); 

EventMask = FT_EVENT_RXCHAR | FT_EVENT_MODEM_STATUS; 
ftStatus = FT_SetEventNotification(ftHandle, EventMask, (PVOID)&eh); 

so frage ich mich, ob dies auf die Definition von SafeWaitHandle