diff options
author | Suren A. Chilingaryan <csa@suren.me> | 2015-08-05 19:27:19 +0200 |
---|---|---|
committer | Suren A. Chilingaryan <csa@suren.me> | 2015-08-05 19:27:19 +0200 |
commit | 5edb8d14272ea2ecd9784a26e150a45954d67e2e (patch) | |
tree | f769aca2c7fc78ccb3a291623ca5c60c124413bb | |
parent | f290bdc333b01dbc5f695236e0b72db1ac2a67d5 (diff) | |
download | ipecamera-5edb8d14272ea2ecd9784a26e150a45954d67e2e.tar.gz ipecamera-5edb8d14272ea2ecd9784a26e150a45954d67e2e.tar.bz2 ipecamera-5edb8d14272ea2ecd9784a26e150a45954d67e2e.tar.xz ipecamera-5edb8d14272ea2ecd9784a26e150a45954d67e2e.zip |
Introduce API debugging
-rw-r--r-- | base.c | 8 | ||||
-rw-r--r-- | data.c | 4 | ||||
-rw-r--r-- | env.h | 1 | ||||
-rw-r--r-- | events.c | 14 | ||||
-rw-r--r-- | private.h | 9 |
5 files changed, 34 insertions, 2 deletions
@@ -288,6 +288,8 @@ int ipecamera_start(pcilib_context_t *vctx, pcilib_event_t event_mask, pcilib_ev return PCILIB_ERROR_INVALID_REQUEST; } + ipecamera_debug(API, "ipecamera: starting"); + ctx->event_id = 0; ctx->preproc_id = 0; ctx->reported_id = 0; @@ -503,6 +505,8 @@ int ipecamera_start(pcilib_context_t *vctx, pcilib_event_t event_mask, pcilib_ev pthread_attr_destroy(&attr); + ipecamera_debug(API, "ipecamera: started"); + return err; } @@ -523,6 +527,8 @@ int ipecamera_stop(pcilib_context_t *vctx, pcilib_event_flags_t flags) { return 0; } + ipecamera_debug(API, "ipecamera: stopping"); + if (ctx->started) { ctx->run_reader = 0; err = pthread_join(ctx->rthread, &retcode); @@ -597,6 +603,8 @@ int ipecamera_stop(pcilib_context_t *vctx, pcilib_event_flags_t flags) { ctx->buffer_pos = 0; ctx->started = 0; + ipecamera_debug(API, "ipecamera: stopped"); + return 0; } @@ -189,6 +189,8 @@ int ipecamera_get(pcilib_context_t *vctx, pcilib_event_id_t event_id, pcilib_eve return PCILIB_ERROR_NOTINITIALIZED; } + ipecamera_debug(API, "ipecamera: get (data)"); + buf_ptr = ipecamera_resolve_event_id(ctx, event_id); if (buf_ptr < 0) return PCILIB_ERROR_OVERWRITTEN; @@ -272,5 +274,7 @@ int ipecamera_return(pcilib_context_t *vctx, pcilib_event_id_t event_id, pcilib_ pthread_rwlock_unlock(&ctx->frame[buf_ptr].mutex); } + ipecamera_debug(API, "ipecamera: return (data)"); + return 0; } @@ -7,6 +7,7 @@ typedef enum { IPECAMERA_DEBUG_RAW_PACKETS_ENV, IPECAMERA_DEBUG_HARDWARE_ENV, IPECAMERA_DEBUG_FRAME_HEADERS_ENV, + IPECAMERA_DEBUG_API_ENV, IPECAMERA_MAX_ENV } ipecamera_env_t; @@ -32,6 +32,8 @@ int ipecamera_stream(pcilib_context_t *vctx, pcilib_event_callback_t callback, v return PCILIB_ERROR_NOTINITIALIZED; } + ipecamera_debug(API, "ipecamera: start streaming"); + ctx->streaming = 1; ctx->run_streamer = 1; @@ -77,10 +79,11 @@ int ipecamera_stream(pcilib_context_t *vctx, pcilib_event_callback_t callback, v ctx->streaming = 0; + ipecamera_debug(API, "ipecamera: streaming finished"); + if (do_stop) { ipecamera_stop(vctx, PCILIB_EVENT_FLAGS_DEFAULT); } - return err; } @@ -104,6 +107,8 @@ int ipecamera_next_event(pcilib_context_t *vctx, pcilib_timeout_t timeout, pcili return PCILIB_ERROR_INVALID_REQUEST; } + ipecamera_debug(API, "ipecamera: next_event"); + #ifdef IPECAMERA_ANNOUNCE_READY if (((!ctx->preproc)&&(ctx->reported_id == ctx->event_id))||((ctx->preproc)&&(ctx->reported_id == ctx->preproc_id))) { #else /* IPECAMERA_ANNOUNCE_READY */ @@ -133,6 +138,7 @@ int ipecamera_next_event(pcilib_context_t *vctx, pcilib_timeout_t timeout, pcili } if (ctx->reported_id == ctx->event_id) { + ipecamera_debug(API, "ipecamera: next_event timed out"); return PCILIB_ERROR_TIMEOUT; } @@ -149,12 +155,16 @@ retry: memcpy(info, ctx->frame + ((ctx->reported_id-1)%ctx->buffer_size), sizeof(ipecamera_event_info_t)); else if (info_size >= sizeof(pcilib_event_info_t)) memcpy(info, ctx->frame + ((ctx->reported_id-1)%ctx->buffer_size), sizeof(pcilib_event_info_t)); - else + else { + ipecamera_debug(API, "ipecamera: next_event returned a error"); return PCILIB_ERROR_INVALID_ARGUMENT; + } } if ((ctx->event_id - ctx->reported_id) >= ctx->buffer_size) goto retry; + ipecamera_debug(API, "ipecamera: next_event returned"); + return 0; } @@ -14,6 +14,7 @@ # define IPECAMERA_DEBUG_RAW_PACKETS //**< Store all raw packets read from DMA grouped in frames */ # define IPECAMERA_DEBUG_HARDWARE //**< Produce various debugging information about ipecamera operation */ # define IPECAMERA_DEBUG_FRAME_HEADERS //**< Print frame headers & footers */ +# define IPECAMERA_DEBUG_API //**< Debug IPECamera API calls */ #endif /* IPECAMERA_DEBUG */ #define IPECAMERA_BUG_MISSING_PAYLOAD //**< CMOSIS fails to provide a first payload for each frame, therefore the frame is 32 bit shorter */ @@ -108,6 +109,14 @@ # define IPECAMERA_DEBUG_FRAME_HEADERS_BUFFER(function, ...) #endif /* IPECAMERA_DEBUG_RAW_FRAMES */ +#ifdef IPECAMERA_DEBUG_API +# define IPECAMERA_DEBUG_API_MESSAGE(function, ...) if (ipecamera_getenv(function##_ENV, #function)) { pcilib_debug_message (#function, __FILE__, __LINE__, __VA_ARGS__); } +# define IPECAMERA_DEBUG_API_BUFFER(function, ...) if (ipecamera_getenv(function##_ENV, #function)) { pcilib_debug_data_buffer (#function, __VA_ARGS__); } +#else /* IPECAMERA_DEBUG_API */ +# define IPECAMERA_DEBUG_API_MESSAGE(function, ...) +# define IPECAMERA_DEBUG_API_BUFFER(function, ...) +#endif /* IPECAMERA_DEBUG_API */ + #define ipecamera_debug(function, ...) \ IPECAMERA_DEBUG_##function##_MESSAGE(IPECAMERA_DEBUG_##function, PCILIB_LOG_DEFAULT, __VA_ARGS__) |