#include #include #include #include "libvxi11client.h" static GAsyncQueue* interruptqueue; typedef struct { GTimeVal when; char* handle; } Event; static void interruptcallback(char* handle) { Event* event = g_malloc(sizeof(Event)); g_get_current_time(&event->when); g_async_queue_push(interruptqueue, event); } VXI11Context* glue_open(char* address, char* device) { VXI11Context* context = malloc(sizeof(VXI11Context)); if (context == NULL) return NULL; int err = vxi11_open(context, address, device); return context; } int glue_start_interrupt_server() { interruptqueue = g_async_queue_new(); return vxi11_start_interrupt_server(interruptcallback); } int glue_stop_interrupt_server() { int ret = vxi11_stop_interrupt_server(); g_free(interruptqueue); return ret; } int glue_wait_for_interrupt() { GTimeVal timeout; g_get_current_time(&timeout); g_time_val_add(&timeout, 2500); gpointer event = g_async_queue_timed_pop(interruptqueue, &timeout); if (event != NULL) { g_free(event); return 1; } else return 0; }