summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@dside.dyndns.org>2011-07-18 01:07:04 +0200
committerSuren A. Chilingaryan <csa@dside.dyndns.org>2011-07-18 01:07:04 +0200
commit51b53a89896a63d49e7e622133faf58dc681ce13 (patch)
tree0af640d5818651d5bf474b1fbc976f821290694b
parent71c759e3fa6fb725c51e3800947848cd549222bf (diff)
downloadipecamera-51b53a89896a63d49e7e622133faf58dc681ce13.tar.gz
ipecamera-51b53a89896a63d49e7e622133faf58dc681ce13.tar.bz2
ipecamera-51b53a89896a63d49e7e622133faf58dc681ce13.tar.xz
ipecamera-51b53a89896a63d49e7e622133faf58dc681ce13.zip
Change timeout definition in Events API from struct timespec to pcilib_timeout_t
-rw-r--r--cli.c2
-rw-r--r--event.c21
-rw-r--r--event.h2
-rw-r--r--ipecamera/image.c2
-rw-r--r--ipecamera/image.h2
-rw-r--r--pcilib.h13
6 files changed, 24 insertions, 18 deletions
diff --git a/cli.c b/cli.c
index d9b27be..3927fe3 100644
--- a/cli.c
+++ b/cli.c
@@ -884,7 +884,7 @@ int Grab(pcilib_t *handle, const char *event, const char *output) {
// ignoring event for now
- err = pcilib_grab(handle, PCILIB_EVENTS_ALL, &size, &data, NULL);
+ err = pcilib_grab(handle, PCILIB_EVENTS_ALL, &size, &data, PCILIB_TIMEOUT_TRIGGER);
if (err) {
Error("Grabbing event is failed");
}
diff --git a/event.c b/event.c
index 8f00472..cc58c79 100644
--- a/event.c
+++ b/event.c
@@ -12,12 +12,21 @@
#include <arpa/inet.h>
#include <errno.h>
#include <assert.h>
+#include <time.h>
#include "pci.h"
#include "tools.h"
#include "error.h"
+#ifndef __timespec_defined
+struct timespec {
+ time_t tv_sec;
+ long tv_nsec;
+};
+#endif /* __timespec_defined */
+
+
pcilib_event_t pcilib_find_event(pcilib_t *ctx, const char *event) {
int i;
pcilib_register_bank_t res;
@@ -85,7 +94,7 @@ int pcilib_stop(pcilib_t *ctx) {
return 0;
}
-pcilib_event_id_t pcilib_get_next_event(pcilib_t *ctx, pcilib_event_t event_mask, const struct timespec *timeout) {
+pcilib_event_id_t pcilib_get_next_event(pcilib_t *ctx, pcilib_event_t event_mask, pcilib_timeout_t timeout) {
pcilib_event_api_description_t *api;
pcilib_model_description_t *model_info = pcilib_get_model_description(ctx);
@@ -221,15 +230,19 @@ static int pcilib_grab_callback(pcilib_event_t event, pcilib_event_id_t event_id
return 0;
}
-int pcilib_grab(pcilib_t *ctx, pcilib_event_t event_mask, size_t *size, void **data, const struct timespec *timeout) {
+int pcilib_grab(pcilib_t *ctx, pcilib_event_t event_mask, size_t *size, void **data, pcilib_timeout_t timeout) {
int err;
+ struct timespec ts;
pcilib_grab_callback_user_data_t user = {ctx, size, data};
err = pcilib_start(ctx, event_mask, pcilib_grab_callback, &user);
if (!err) {
- if (timeout) nanosleep(timeout, NULL);
- else err = pcilib_trigger(ctx, event_mask, 0, NULL);
+ if (timeout) {
+ ts.tv_sec = timeout / 1000000;
+ ts.tv_nsec = 1000 * (timeout % 1000000);
+ nanosleep(&ts, NULL);
+ } else err = pcilib_trigger(ctx, event_mask, 0, NULL);
}
pcilib_stop(ctx);
return 0;
diff --git a/event.h b/event.h
index c6432be..7c1f1cd 100644
--- a/event.h
+++ b/event.h
@@ -13,7 +13,7 @@ struct pcilib_event_api_description_s {
int (*stop)(pcilib_context_t *ctx);
int (*trigger)(pcilib_context_t *ctx, pcilib_event_t event, size_t trigger_size, void *trigger_data);
- pcilib_event_id_t (*next_event)(pcilib_context_t *ctx, pcilib_event_t event_mask, const struct timespec *timeout);
+ pcilib_event_id_t (*next_event)(pcilib_context_t *ctx, pcilib_event_t event_mask, pcilib_timeout_t timeout);
void* (*get_data)(pcilib_context_t *ctx, pcilib_event_id_t event_id, pcilib_event_data_type_t data_type, size_t arg_size, void *arg, size_t *size);
int (*return_data)(pcilib_context_t *ctx, pcilib_event_id_t event_id);
diff --git a/ipecamera/image.c b/ipecamera/image.c
index 3d1056d..0fe8da8 100644
--- a/ipecamera/image.c
+++ b/ipecamera/image.c
@@ -613,7 +613,7 @@ static int ipecamera_resolve_event_id(ipecamera_t *ctx, pcilib_event_id_t evid)
return buf_ptr;
}
-pcilib_event_id_t ipecamera_next_event(pcilib_context_t *vctx, pcilib_event_t event_mask, const struct timespec *timeout) {
+pcilib_event_id_t ipecamera_next_event(pcilib_context_t *vctx, pcilib_event_t event_mask, pcilib_timeout_t timeout) {
int buf_ptr;
pcilib_event_id_t reported;
ipecamera_t *ctx = (ipecamera_t*)vctx;
diff --git a/ipecamera/image.h b/ipecamera/image.h
index 4bac673..b414f74 100644
--- a/ipecamera/image.h
+++ b/ipecamera/image.h
@@ -13,7 +13,7 @@ int ipecamera_reset(pcilib_context_t *ctx);
int ipecamera_start(pcilib_context_t *ctx, pcilib_event_t event_mask, pcilib_event_callback_t cb, void *user);
int ipecamera_stop(pcilib_context_t *ctx);
int ipecamera_trigger(pcilib_context_t *ctx, pcilib_event_t event, size_t trigger_size, void *trigger_data);
-pcilib_event_id_t ipecamera_next_event(pcilib_context_t *ctx, pcilib_event_t event_mask, const struct timespec *timeout);
+pcilib_event_id_t ipecamera_next_event(pcilib_context_t *ctx, pcilib_event_t event_mask, pcilib_timeout_t timeout);
void* ipecamera_get(pcilib_context_t *ctx, pcilib_event_id_t event_id, pcilib_event_data_type_t data_type, size_t arg_size, void *arg, size_t *size);
int ipecamera_return(pcilib_context_t *ctx, pcilib_event_id_t event_id);
diff --git a/pcilib.h b/pcilib.h
index 01afe9e..07f558a 100644
--- a/pcilib.h
+++ b/pcilib.h
@@ -4,16 +4,8 @@
#define PCILIB_MAX_BANKS 6
#define PCILIB_MAX_DMA_ENGINES 32
-#include <time.h>
#include <stdint.h>
-#ifndef __timespec_defined
-struct timespec {
- time_t tv_sec;
- long tv_nsec;
-};
-#endif /* __timespec_defined */
-
#define pcilib_memcpy pcilib_memcpy32
#define pcilib_datacpy pcilib_datacpy32
@@ -106,6 +98,7 @@ typedef enum {
#define PCILIB_EVENT_ID_INVALID 0
#define PCILIB_TIMEOUT_INFINITE ((pcilib_timeout_t)-1)
#define PCILIB_TIMEOUT_IMMEDIATE 0
+#define PCILIB_TIMEOUT_TRIGGER 0
typedef int (*pcilib_dma_callback_t)(void *ctx, pcilib_dma_flags_t flags, size_t bufsize, void *buf);
typedef int (*pcilib_event_callback_t)(pcilib_event_t event, pcilib_event_id_t event_id, void *user);
@@ -254,7 +247,7 @@ int pcilib_stop(pcilib_t *ctx);
int pcilib_trigger(pcilib_t *ctx, pcilib_event_t event, size_t trigger_size, void *trigger_data);
-pcilib_event_id_t pcilib_get_next_event(pcilib_t *ctx, pcilib_event_t event_mask, const struct timespec *timeout);
+pcilib_event_id_t pcilib_get_next_event(pcilib_t *ctx, pcilib_event_t event_mask, pcilib_timeout_t timeout);
void *pcilib_get_data(pcilib_t *ctx, pcilib_event_id_t event_id, pcilib_event_data_type_t data_type, size_t *size);
void *pcilib_get_data_with_argument(pcilib_t *ctx, pcilib_event_id_t event_id, pcilib_event_data_type_t data_type, size_t arg_size, void *arg, size_t *size);
/*
@@ -268,6 +261,6 @@ int pcilib_return_data(pcilib_t *ctx, pcilib_event_id_t event_id);
* In case of failure the content of data is undefined.
* @param timeout - will be autotriggered if NULL
*/
-int pcilib_grab(pcilib_t *ctx, pcilib_event_t event_mask, size_t *size, void **data, const struct timespec *timeout);
+int pcilib_grab(pcilib_t *ctx, pcilib_event_t event_mask, size_t *size, void **data, pcilib_timeout_t timeout);
#endif /* _PCITOOL_PCILIB_H */