summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Vogelgesang <matthias.vogelgesang@ipe.fzk.de>2011-02-25 12:24:20 +0100
committerMatthias Vogelgesang <matthias.vogelgesang@ipe.fzk.de>2011-02-25 12:24:20 +0100
commit06890f4bd07aa24f4205a0573c0a57a8c3e9f6b0 (patch)
treeb7083943888ae0b884f23f97ce3137a0299b005b
parentb32564991609717631b2b3926dccd9db21c28f46 (diff)
downloaduca-06890f4bd07aa24f4205a0573c0a57a8c3e9f6b0.tar.gz
uca-06890f4bd07aa24f4205a0573c0a57a8c3e9f6b0.tar.bz2
uca-06890f4bd07aa24f4205a0573c0a57a8c3e9f6b0.tar.xz
uca-06890f4bd07aa24f4205a0573c0a57a8c3e9f6b0.zip
Property re-ordering. Made test program more useful
-rw-r--r--src/cameras/uca_pco.c53
-rw-r--r--src/uca.h37
-rw-r--r--test/test.c32
3 files changed, 78 insertions, 44 deletions
diff --git a/src/cameras/uca_pco.c b/src/cameras/uca_pco.c
index 93d50f6..1c189b7 100644
--- a/src/cameras/uca_pco.c
+++ b/src/cameras/uca_pco.c
@@ -16,6 +16,8 @@ struct pco_cam_t {
#define GET_PCO(uca) (((struct pco_cam_t *)(uca->user))->pco)
#define GET_FG(uca) (((struct pco_cam_t *)(uca->user))->fg)
+#define set_void(p, type, value) { *((type *) p) = value; }
+
static uint32_t uca_pco_set_bitdepth(struct uca_t *uca, uint8_t *bitdepth)
{
@@ -91,6 +93,7 @@ static uint32_t uca_pco_set_property(struct uca_t *uca, int32_t property, void *
return UCA_NO_ERROR;
}
+
static uint32_t uca_pco_get_property(struct uca_t *uca, int32_t property, void *data)
{
struct pco_edge_t *pco = GET_PCO(uca);
@@ -110,11 +113,27 @@ static uint32_t uca_pco_get_property(struct uca_t *uca, int32_t property, void *
return UCA_ERR_PROP_GENERAL;
break;
+ case UCA_PROP_WIDTH_MIN:
+ set_void(data, uint32_t, 1);
+ break;
+
+ case UCA_PROP_WIDTH_MAX:
+ set_void(data, uint32_t, pco->description.wMaxHorzResStdDESC);
+ break;
+
case UCA_PROP_HEIGHT:
if (Fg_getParameter(GET_FG(uca), FG_HEIGHT, (uint32_t *) data, PORT_A) != FG_OK)
return UCA_ERR_PROP_GENERAL;
break;
+ case UCA_PROP_HEIGHT_MIN:
+ set_void(data, uint32_t, 1);
+ break;
+
+ case UCA_PROP_HEIGHT_MAX:
+ set_void(data, uint32_t, pco->description.wMaxVertResStdDESC);
+ break;
+
case UCA_PROP_X_OFFSET:
if (Fg_getParameter(GET_FG(uca), FG_XOFFSET, (uint32_t *) data, PORT_A) != FG_OK)
return UCA_ERR_PROP_GENERAL;
@@ -125,19 +144,21 @@ static uint32_t uca_pco_get_property(struct uca_t *uca, int32_t property, void *
return UCA_ERR_PROP_GENERAL;
break;
- case UCA_PROP_MAX_WIDTH:
- {
- uint32_t w, h;
- pco_get_actual_size(pco, &w, &h);
- *((uint32_t *) data) = w;
- }
+ case UCA_PROP_DELAY_MIN:
+ set_void(data, uint32_t, pco->description.dwMinDelayDESC);
+ break;
- case UCA_PROP_MAX_HEIGHT:
- {
- int w, h;
- pco_get_actual_size(pco, &w, &h);
- *((uint32_t *) data) = h;
- }
+ case UCA_PROP_DELAY_MAX:
+ set_void(data, uint32_t, pco->description.dwMaxDelayDESC);
+ break;
+
+ case UCA_PROP_EXPOSURE_MIN:
+ set_void(data, uint32_t, pco->description.dwMinExposureDESC);
+ break;
+
+ case UCA_PROP_EXPOSURE_MAX:
+ set_void(data, uint32_t, pco->description.dwMaxExposureDESC);
+ break;
default:
return UCA_ERR_PROP_INVALID;
@@ -157,15 +178,19 @@ uint32_t uca_pco_init(struct uca_t *uca)
struct pco_cam_t *pco_cam = uca->user;
struct pco_edge_t *pco = pco_cam->pco = pco_init();
+ if (pco == NULL) {
+ free(uca->user);
+ return UCA_ERR_INIT_NOT_FOUND;
+ }
+
if ((pco->serial_ref == NULL) || !pco_active(pco)) {
+ free(uca->user);
pco_destroy(pco);
return UCA_ERR_INIT_NOT_FOUND;
}
Fg_Struct *fg = pco_cam->fg = Fg_Init("libFullAreaGray8.so", 0);
- pco_scan_and_set_baud_rate(pco);
-
/* Camera found, set function pointers... */
uca->cam_destroy = &uca_pco_destroy;
uca->cam_set_property = &uca_pco_set_property;
diff --git a/src/uca.h b/src/uca.h
index 93dbbff..52cc7b8 100644
--- a/src/uca.h
+++ b/src/uca.h
@@ -91,28 +91,28 @@ const char* uca_get_property_name(int32_t property_id);
#define UCA_PROP_HEIGHT 4
#define UCA_PROP_HEIGHT_MIN 5
#define UCA_PROP_HEIGHT_MAX 6
-#define UCA_PROP_X_OFFSET 3
-#define UCA_PROP_Y_OFFSET 4
-#define UCA_PROP_MAX_WIDTH 5
-#define UCA_PROP_MAX_HEIGHT 6
-#define UCA_PROP_BITDEPTH 7
-#define UCA_PROP_EXPOSURE 8
-#define UCA_PROP_EXPOSURE_MIN 9
-#define UCA_PROP_EXPOSURE_MAX 10
-#define UCA_PROP_DELAY 11
-#define UCA_PROP_DELAY_MIN 12
-#define UCA_PROP_DELAY_MAX 13
-#define UCA_PROP_FRAMERATE 14
-#define UCA_PROP_TRIGGER_MODE 15
+#define UCA_PROP_X_OFFSET 7
+#define UCA_PROP_Y_OFFSET 8
+#define UCA_PROP_MAX_WIDTH 9
+#define UCA_PROP_MAX_HEIGHT 10
+#define UCA_PROP_BITDEPTH 11
+#define UCA_PROP_EXPOSURE 12
+#define UCA_PROP_EXPOSURE_MIN 13
+#define UCA_PROP_EXPOSURE_MAX 14
+#define UCA_PROP_DELAY 15
+#define UCA_PROP_DELAY_MIN 16
+#define UCA_PROP_DELAY_MAX 17
+#define UCA_PROP_FRAMERATE 18
+#define UCA_PROP_TRIGGER_MODE 19
/* pco.edge specific */
-#define UCA_PROP_TIMESTAMP_MODE 16
-#define UCA_PROP_SCAN_MODE 17
+#define UCA_PROP_TIMESTAMP_MODE 20
+#define UCA_PROP_SCAN_MODE 21
/* IPE camera specific */
-#define UCA_PROP_INTERLACE_SAMPLE_RATE 18
-#define UCA_PROP_INTERLACE_PIXEL_THRESH 19
-#define UCA_PROP_INTERLACE_ROW_THRESH 20
+#define UCA_PROP_INTERLACE_SAMPLE_RATE 22
+#define UCA_PROP_INTERLACE_PIXEL_THRESH 23
+#define UCA_PROP_INTERLACE_ROW_THRESH 24
/* Photon Focus specific */
#define UCA_PROP_CORRECTION_MODE 21
@@ -136,6 +136,7 @@ struct uca_t {
uca_cam_set_property cam_set_property;
uca_cam_get_property cam_get_property;
uca_cam_acquire_image cam_acquire_image;
+ uca_cam_alloc cam_alloc;
/* Private */
uca_cam_destroy cam_destroy;
diff --git a/test/test.c b/test/test.c
index 84df874..6537b6b 100644
--- a/test/test.c
+++ b/test/test.c
@@ -4,22 +4,30 @@
int main(int argc, char *argv[])
{
- struct uca_t *uca = uca_init();
- if (uca == NULL) {
- printf("Couldn't find a camera\n");
+ if (argc < 2) {
+ printf("usage: uca <property-name>\n");
return 1;
}
+ else {
+ int property = uca_get_property_id(argv[1]);
+ if (property == UCA_PROP_INVALID) {
+ printf("Property invalid!\n");
+ return 1;
+ }
- uint32_t width = 2560, height = 2160;
+ struct uca_t *uca = uca_init();
+ if (uca == NULL) {
+ printf("Couldn't find a camera\n");
+ return 1;
+ }
- uca->cam_set_property(uca, UCA_PROP_WIDTH, &width);
- uca->cam_set_property(uca, UCA_PROP_HEIGHT, &height);
+ uint32_t value; /* this type should be right, most of the time */
+ if (uca->cam_get_property(uca, property, &value) == UCA_PROP_INVALID)
+ printf("Property not supported on this camera\n");
+ else
+ printf("%s = %u\n", argv[1], value);
- char camera_name[256] = "foobar";
- uca->cam_get_property(uca, UCA_PROP_NAME, camera_name);
-
- printf("Camera name: %s\n", camera_name);
-
- uca_destroy(uca);
+ uca_destroy(uca);
+ }
return 0;
}