diff options
author | Suren A. Chilingaryan <csa@dside.dyndns.org> | 2011-07-18 01:07:04 +0200 |
---|---|---|
committer | Suren A. Chilingaryan <csa@dside.dyndns.org> | 2011-07-18 01:07:04 +0200 |
commit | 51b53a89896a63d49e7e622133faf58dc681ce13 (patch) | |
tree | 0af640d5818651d5bf474b1fbc976f821290694b | |
parent | 71c759e3fa6fb725c51e3800947848cd549222bf (diff) | |
download | ipecamera-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.c | 2 | ||||
-rw-r--r-- | event.c | 21 | ||||
-rw-r--r-- | event.h | 2 | ||||
-rw-r--r-- | ipecamera/image.c | 2 | ||||
-rw-r--r-- | ipecamera/image.h | 2 | ||||
-rw-r--r-- | pcilib.h | 13 |
6 files changed, 24 insertions, 18 deletions
@@ -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"); } @@ -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; @@ -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); @@ -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 */ |