From 195ead4d9aa4f1ed244558d49cee348a5ae6e939 Mon Sep 17 00:00:00 2001 From: Matthias Vogelgesang Date: Mon, 21 Mar 2011 12:37:12 +0100 Subject: Fix grabber allocation and callback registration for me4 and pf --- test/grab.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'test') diff --git a/test/grab.c b/test/grab.c index 3e429ed..34b90c8 100644 --- a/test/grab.c +++ b/test/grab.c @@ -4,6 +4,10 @@ #include "uca.h" #include "uca-cam.h" +#define handle_error(errno) {if ((errno) != UCA_NO_ERROR) printf("error at <%s:%i>\n", \ + __FILE__, __LINE__);} + + int main(int argc, char *argv[]) { struct uca *u = uca_init(NULL); @@ -15,24 +19,24 @@ int main(int argc, char *argv[]) /* take first camera */ struct uca_camera *cam = u->cameras; - uint32_t val = 1; - cam->set_property(cam, UCA_PROP_EXPOSURE, &val); + uint32_t val = 2000; + handle_error(cam->set_property(cam, UCA_PROP_EXPOSURE, &val)); val = 0; - cam->set_property(cam, UCA_PROP_DELAY, &val); + handle_error(cam->set_property(cam, UCA_PROP_DELAY, &val)); uint32_t width, height, bits; - cam->get_property(cam, UCA_PROP_WIDTH, &width, 0); - cam->get_property(cam, UCA_PROP_HEIGHT, &height, 0); - cam->get_property(cam, UCA_PROP_BITDEPTH, &bits, 0); + handle_error(cam->get_property(cam, UCA_PROP_WIDTH, &width, 0)); + handle_error(cam->get_property(cam, UCA_PROP_HEIGHT, &height, 0)); + handle_error(cam->get_property(cam, UCA_PROP_BITDEPTH, &bits, 0)); - uca_cam_alloc(cam, 10); + handle_error(uca_cam_alloc(cam, 10)); const int pixel_size = bits == 8 ? 1 : 2; uint16_t *buffer = (uint16_t *) malloc(width * height * pixel_size); - cam->start_recording(cam); - cam->grab(cam, (char *) buffer, NULL); - cam->stop_recording(cam); + handle_error(cam->start_recording(cam)); + handle_error(cam->grab(cam, (char *) buffer, NULL)); + handle_error(cam->stop_recording(cam)); uca_destroy(u); FILE *fp = fopen("out.raw", "wb"); -- cgit v1.2.3