summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cli.c55
-rw-r--r--ipecamera/image.c4
-rw-r--r--ipecamera/ipecamera.h4
-rw-r--r--pcilib.h4
-rw-r--r--pcitool/sysinfo.c1
5 files changed, 57 insertions, 11 deletions
diff --git a/cli.c b/cli.c
index e2c8615..5398d8f 100644
--- a/cli.c
+++ b/cli.c
@@ -97,7 +97,8 @@ typedef enum {
typedef enum {
PARTITION_UNKNOWN,
PARTITION_RAW,
- PARTITION_EXT4
+ PARTITION_EXT4,
+ PARTITION_NULL
} PARTITION;
typedef enum {
@@ -1116,6 +1117,17 @@ int GrabCallback(pcilib_event_id_t event_id, pcilib_event_info_t *info, void *us
ctx->event_count++;
if (info->flags&PCILIB_EVENT_INFO_FLAG_BROKEN) ctx->broken_count++;
+
+ data = pcilib_get_data(handle, ctx->event, ctx->data, &size);
+ if (!data) Error("Internal Error: No data is provided to event callback");
+
+ written = fwrite(data, 1, size, ctx->output);
+ if (written != size) {
+ if (written > 0) Error("Write failed, only %z bytes out of %z are stored", written, size);
+ else Error("Write failed");
+ }
+
+ pcilib_return_data(handle, ctx->event, data);
// printf("%lu %lu\n", info->seqnum, info->offset);
@@ -1161,7 +1173,7 @@ void *Trigger(void *user) {
gettimeofday(&start, NULL);
do {
- pcilib_trigger(ctx->handle, PCILIB_EVENT0, 0, NULL);
+ pcilib_trigger(ctx->handle, ctx->event, 0, NULL);
if ((++ctx->trigger_count == max_triggers)&&(max_triggers)) break;
if (trigger_time) {
@@ -1240,11 +1252,15 @@ void *Monitor(void *user) {
return NULL;
}
-int TriggerAndGrab(pcilib_t *handle, GRAB_MODE grab_mode, const char *event, const char *data_type, size_t num, size_t run_time, size_t trigger_time, pcilib_timeout_t timeout, PARTITION partition, FORMAT format, size_t buffer_size, FILE *ofile) {
+int TriggerAndGrab(pcilib_t *handle, GRAB_MODE grab_mode, const char *evname, const char *data_type, size_t num, size_t run_time, size_t trigger_time, pcilib_timeout_t timeout, PARTITION partition, FORMAT format, size_t buffer_size, FILE *ofile) {
int err;
GRABContext ctx;
- void *data = NULL;
- size_t size, written;
+// void *data = NULL;
+// size_t size, written;
+
+ pcilib_event_t event;
+ pcilib_event_t listen_events;
+ pcilib_event_data_type_t data;
pthread_t monitor_thread;
pthread_t trigger_thread;
@@ -1254,9 +1270,29 @@ int TriggerAndGrab(pcilib_t *handle, GRAB_MODE grab_mode, const char *event, con
struct timeval end_time;
pcilib_event_flags_t flags;
+ if (evname) {
+ event = pcilib_find_event(handle, evname);
+ if (event == PCILIB_EVENT_INVALID)
+ Error("Can't find event (%s)", evname);
+
+ listen_events = event;
+ } else {
+ listen_events = PCILIB_EVENTS_ALL;
+ event = PCILIB_EVENT0;
+ }
+
+ if (data_type) {
+ data = pcilib_find_event_data_type(handle, event, data_type);
+ if (data == PCILIB_EVENT_DATA_TYPE_INVALID)
+ Error("Can't find data type (%s)", data_type);
+ } else {
+ data = PCILIB_EVENT_DATA;
+ }
+
ctx.handle = handle;
ctx.output = ofile;
- ctx.event = PCILIB_EVENT0;
+ ctx.event = event;
+ ctx.data = data;
ctx.run_time = run_time;
ctx.timeout = timeout;
@@ -1268,6 +1304,8 @@ int TriggerAndGrab(pcilib_t *handle, GRAB_MODE grab_mode, const char *event, con
ctx.run_flag = 1;
memset(&ctx.stop_time, 0, sizeof(struct timeval));
+
+
// printf("Limits: %lu %lu %lu\n", num, run_time, timeout);
pcilib_configure_autostop(handle, num, run_time);//PCILIB_TIMEOUT_TRIGGER);
@@ -1303,7 +1341,7 @@ int TriggerAndGrab(pcilib_t *handle, GRAB_MODE grab_mode, const char *event, con
gettimeofday(&ctx.start_time, NULL);
if (grab_mode&GRAB_MODE_GRAB) {
- err = pcilib_start(handle, PCILIB_EVENTS_ALL, PCILIB_EVENT_FLAGS_DEFAULT);
+ err = pcilib_start(handle, listen_events, flags);
if (err) Error("Failed to start event engine, error %i", err);
}
@@ -2307,6 +2345,9 @@ int main(int argc, char **argv) {
if (!strcmp(fsname, "ext4")) partition = PARTITION_EXT4;
else if (!strcmp(fsname, "raw")) partition = PARTITION_RAW;
}
+ } else {
+ output = "/dev/null";
+ partition = PARTITION_NULL;
}
if (!timeout_set) {
diff --git a/ipecamera/image.c b/ipecamera/image.c
index 89e02a7..4653dc4 100644
--- a/ipecamera/image.c
+++ b/ipecamera/image.c
@@ -418,6 +418,7 @@ static int ipecamera_data_callback(void *user, pcilib_dma_flags_t flags, size_t
if ((bufsize >= 8)&&(!memcmp(buf, frame_magic, sizeof(frame_magic)))) {
//if (ctx->cur_size) ipecamera_new_frame(ctx);
+// printf("%lx\n", ((uint32_t*)buf)[7] & 0xF0000000);
ctx->frame_info[ctx->buffer_pos].info.seqnum = ((uint32_t*)buf)[6] & 0xF0000000;
ctx->frame_info[ctx->buffer_pos].info.offset = ((uint32_t*)buf)[7] & 0xF0000000;
gettimeofday(&ctx->frame_info[ctx->buffer_pos].info.timestamp, NULL);
@@ -865,6 +866,9 @@ void* ipecamera_get(pcilib_context_t *vctx, pcilib_event_id_t event_id, pcilib_e
if (buf_ptr < 0) return NULL;
switch ((ipecamera_data_type_t)data_type) {
+ case IPECAMERA_RAW_DATA:
+ if (size) *size = ctx->frame_info[buf_ptr].raw_size;
+ return ctx->buffer + buf_ptr * ctx->padded_size;
case IPECAMERA_IMAGE_DATA:
if (size) *size = ctx->dim.width * ctx->dim.height * sizeof(ipecamera_pixel_t);
return ctx->buffer + buf_ptr * ctx->dim.width * ctx->dim.height;
diff --git a/ipecamera/ipecamera.h b/ipecamera/ipecamera.h
index c89c6c9..b923b1f 100644
--- a/ipecamera/ipecamera.h
+++ b/ipecamera/ipecamera.h
@@ -10,8 +10,8 @@ typedef struct {
} ipecamera_image_dimensions_t;
typedef enum {
- IPECAMERA_RAW_DATA = 0,
- IPECAMERA_IMAGE_DATA = 1,
+ IPECAMERA_IMAGE_DATA = 0,
+ IPECAMERA_RAW_DATA = 1,
IPECAMERA_DIMENSIONS = 0x8000,
IPECAMERA_IMAGE_REGION = 0x8010,
IPECAMERA_PACKED_IMAGE = 0x8020,
diff --git a/pcilib.h b/pcilib.h
index 18806f9..2eaf63c 100644
--- a/pcilib.h
+++ b/pcilib.h
@@ -60,7 +60,8 @@ typedef enum {
} pcilib_register_protocol_t;
typedef enum {
- PCILIB_EVENT_DATA
+ PCILIB_EVENT_DATA = 0, /**< default data format */
+ PCILIB_EVENT_RAW_DATA = 1 /**< raw data */
} pcilib_event_data_type_t;
typedef enum {
@@ -123,6 +124,7 @@ typedef enum {
#define PCILIB_EVENT3 8
#define PCILIB_EVENTS_ALL ((pcilib_event_t)-1)
#define PCILIB_EVENT_INVALID ((pcilib_event_t)-1)
+#define PCILIB_EVENT_DATA_TYPE_INVALID ((pcilib_event_data_type_t)-1)
#define PCILIB_TIMEOUT_INFINITE ((pcilib_timeout_t)-1)
#define PCILIB_TIMEOUT_IMMEDIATE 0
#define PCILIB_IRQ_SOURCE_DEFAULT 0
diff --git a/pcitool/sysinfo.c b/pcitool/sysinfo.c
index 51e7566..7b25972 100644
--- a/pcitool/sysinfo.c
+++ b/pcitool/sysinfo.c
@@ -168,6 +168,5 @@ nextline:
clean:
if (fn != fname) free(fn);
-puts(fs);
return err;
}