summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Vogelgesang <matthias.vogelgesang@kit.edu>2012-03-04 10:29:38 +0100
committerMatthias Vogelgesang <matthias.vogelgesang@kit.edu>2012-03-04 10:29:38 +0100
commitc6435d57e7f3f19ba5d34a77c74e7fce035a842c (patch)
tree3c84d0e25eb6e46bc63cae16da20e7dabeb9f7cd
parenta3e69237f56a7a93f608fbe2dbf1cd8c403a1f25 (diff)
downloaduca-c6435d57e7f3f19ba5d34a77c74e7fce035a842c.tar.gz
uca-c6435d57e7f3f19ba5d34a77c74e7fce035a842c.tar.bz2
uca-c6435d57e7f3f19ba5d34a77c74e7fce035a842c.tar.xz
uca-c6435d57e7f3f19ba5d34a77c74e7fce035a842c.zip
Handle Framegrabber errors more gracefully
-rw-r--r--src/cameras/uca-pco-camera.c30
-rw-r--r--src/cameras/uca-pco-camera.h3
2 files changed, 23 insertions, 10 deletions
diff --git a/src/cameras/uca-pco-camera.c b/src/cameras/uca-pco-camera.c
index 9a5f1f2..6362cab 100644
--- a/src/cameras/uca-pco-camera.c
+++ b/src/cameras/uca-pco-camera.c
@@ -23,6 +23,16 @@
#include "uca-camera.h"
#include "uca-pco-camera.h"
+#define FG_TRY_PARAM(fg, camobj, param, val_addr, port) \
+ { int r = Fg_setParameter(fg, param, val_addr, port); \
+ if (r != FG_OK) { \
+ g_set_error(error, UCA_PCO_CAMERA_ERROR, \
+ UCA_PCO_CAMERA_ERROR_FG_GENERAL, \
+ "%s", Fg_getLastErrorDescription(fg)); \
+ g_object_unref(camobj); \
+ return NULL; \
+ } }
+
#define UCA_PCO_CAMERA_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), UCA_TYPE_PCO_CAMERA, UcaPcoCameraPrivate))
G_DEFINE_TYPE(UcaPcoCamera, uca_pco_camera, UCA_TYPE_CAMERA)
@@ -30,9 +40,10 @@ G_DEFINE_TYPE(UcaPcoCamera, uca_pco_camera, UCA_TYPE_CAMERA)
/**
* UcaPcoCameraError:
* @UCA_PCO_CAMERA_ERROR_LIBPCO_INIT: Initializing libpco failed
+ * @UCA_PCO_CAMERA_ERROR_LIBPCO_GENERAL: General libpco error
* @UCA_PCO_CAMERA_ERROR_UNSUPPORTED: Camera type is not supported
* @UCA_PCO_CAMERA_ERROR_FG_INIT: Framegrabber initialization failed
- * @UCA_PCO_CAMERA_ERROR_FG_ERROR: Framegrabber error
+ * @UCA_PCO_CAMERA_ERROR_FG_GENERAL: General framegrabber error
*/
GQuark uca_pco_camera_error_quark()
{
@@ -169,8 +180,8 @@ UcaPcoCamera *uca_pco_camera_new(GError **error)
priv->fg = Fg_Init(map_entry->so_file, priv->fg_port);
if (priv->fg == NULL) {
- g_set_error(error, UCA_PCO_CAMERA_ERROR, UCA_PCO_CAMERA_ERROR_UNSUPPORTED,
- "Initializing framegrabber failed");
+ g_set_error(error, UCA_PCO_CAMERA_ERROR, UCA_PCO_CAMERA_ERROR_FG_INIT,
+ "%s", Fg_getLastErrorDescription(priv->fg));
g_object_unref(camera);
return NULL;
}
@@ -183,18 +194,19 @@ UcaPcoCamera *uca_pco_camera_new(GError **error)
if (priv->fg_mem == NULL) {
g_set_error(error, UCA_PCO_CAMERA_ERROR, UCA_PCO_CAMERA_ERROR_UNSUPPORTED,
- "Framegrabber could not allocate DMA buffers");
+ "%s", Fg_getLastErrorDescription(priv->fg));
g_object_unref(camera);
return NULL;
}
- Fg_setParameter(priv->fg, FG_CAMERA_LINK_CAMTYP, &map_entry->cl_type, priv->fg_port);
- Fg_setParameter(priv->fg, FG_FORMAT, &map_entry->cl_format, priv->fg_port);
- Fg_setParameter(priv->fg, FG_WIDTH, &fg_width, priv->fg_port);
- Fg_setParameter(priv->fg, FG_HEIGHT, &priv->height, priv->fg_port);
+ FG_TRY_PARAM(priv->fg, camera, FG_CAMERA_LINK_CAMTYP, &map_entry->cl_type, priv->fg_port);
+ FG_TRY_PARAM(priv->fg, camera, FG_CAMERA_LINK_CAMTYP, &map_entry->cl_type, priv->fg_port);
+ FG_TRY_PARAM(priv->fg, camera, FG_FORMAT, &map_entry->cl_format, priv->fg_port);
+ FG_TRY_PARAM(priv->fg, camera, FG_WIDTH, &fg_width, priv->fg_port);
+ FG_TRY_PARAM(priv->fg, camera, FG_HEIGHT, &priv->height, priv->fg_port);
int val = FREE_RUN;
- Fg_setParameter(priv->fg, FG_TRIGGERMODE, &val, priv->fg_port);
+ FG_TRY_PARAM(priv->fg, camera, FG_TRIGGERMODE, &val, priv->fg_port);
fill_binnings(priv);
diff --git a/src/cameras/uca-pco-camera.h b/src/cameras/uca-pco-camera.h
index ba6a105..25009c0 100644
--- a/src/cameras/uca-pco-camera.h
+++ b/src/cameras/uca-pco-camera.h
@@ -31,9 +31,10 @@
#define UCA_PCO_CAMERA_ERROR uca_pco_camera_error_quark()
typedef enum {
UCA_PCO_CAMERA_ERROR_LIBPCO_INIT,
+ UCA_PCO_CAMERA_ERROR_LIBPCO_GENERAL,
UCA_PCO_CAMERA_ERROR_UNSUPPORTED,
UCA_PCO_CAMERA_ERROR_FG_INIT,
- UCA_PCO_CAMERA_ERROR_FG_ERROR
+ UCA_PCO_CAMERA_ERROR_FG_GENERAL
} UcaPcoCameraError;
typedef struct _UcaPcoCamera UcaPcoCamera;