summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/cameras/uca-pco-camera.c15
-rw-r--r--test/grab.c12
2 files changed, 19 insertions, 8 deletions
diff --git a/src/cameras/uca-pco-camera.c b/src/cameras/uca-pco-camera.c
index 945155a..11328e9 100644
--- a/src/cameras/uca-pco-camera.c
+++ b/src/cameras/uca-pco-camera.c
@@ -140,6 +140,7 @@ struct _UcaPcoCameraPrivate {
GValueArray *horizontal_binnings;
GValueArray *vertical_binnings;
+ frameindex_t last_frame;
guint16 active_segment;
guint num_recorded_images;
guint current_image;
@@ -319,6 +320,8 @@ static void uca_pco_camera_start_recording(UcaCamera *camera, GError **error)
(priv->camera_description->camera_type == CAMERATYPE_PCO4000))
pco_clear_active_segment(priv->pco);
+ priv->last_frame = 0;
+
err = pco_arm_camera(priv->pco);
HANDLE_PCO_ERROR(err);
@@ -339,6 +342,10 @@ static void uca_pco_camera_stop_recording(UcaCamera *camera, GError **error)
err = Fg_stopAcquireEx(priv->fg, priv->fg_port, priv->fg_mem, STOP_SYNC);
FG_SET_ERROR(err, priv->fg, UCA_PCO_CAMERA_ERROR_FG_ACQUISITION);
+
+ err = Fg_setStatusEx(priv->fg, FG_UNBLOCK_ALL, 0, priv->fg_port, priv->fg_mem);
+ if (err == FG_INVALID_PARAMETER)
+ g_print(" Unable to unblock all\n");
}
static void uca_pco_camera_start_readout(UcaCamera *camera, GError **error)
@@ -363,7 +370,6 @@ static void uca_pco_camera_start_readout(UcaCamera *camera, GError **error)
static void uca_pco_camera_grab(UcaCamera *camera, gpointer *data, GError **error)
{
g_return_if_fail(UCA_IS_PCO_CAMERA(camera));
- static frameindex_t last_frame = 0;
UcaPcoCameraPrivate *priv = UCA_PCO_CAMERA_GET_PRIVATE(camera);
gboolean is_readout = FALSE;
@@ -385,14 +391,14 @@ static void uca_pco_camera_grab(UcaCamera *camera, gpointer *data, GError **erro
}
pco_request_image(priv->pco);
- last_frame = Fg_getLastPicNumberBlockingEx(priv->fg, last_frame+1, priv->fg_port, 5, priv->fg_mem);
+ priv->last_frame = Fg_getLastPicNumberBlockingEx(priv->fg, priv->last_frame+1, priv->fg_port, 5, priv->fg_mem);
- if (last_frame <= 0) {
+ if (priv->last_frame <= 0) {
guint err = FG_OK + 1;
FG_SET_ERROR(err, priv->fg, UCA_PCO_CAMERA_ERROR_FG_GENERAL);
}
- guint16 *frame = Fg_getImagePtrEx(priv->fg, last_frame, priv->fg_port, priv->fg_mem);
+ guint16 *frame = Fg_getImagePtrEx(priv->fg, priv->last_frame, priv->fg_port, priv->fg_mem);
if (*data == NULL)
*data = g_malloc0(priv->frame_width * priv->frame_height * priv->num_bytes);
@@ -601,4 +607,5 @@ static void uca_pco_camera_init(UcaPcoCamera *self)
self->priv->horizontal_binnings = NULL;
self->priv->vertical_binnings = NULL;
self->priv->camera_description = NULL;
+ self->priv->last_frame = 0;
}
diff --git a/test/grab.c b/test/grab.c
index 7b5062f..bcabd1a 100644
--- a/test/grab.c
+++ b/test/grab.c
@@ -65,11 +65,13 @@ int main(int argc, char *argv[])
uca_camera_start_recording(camera, &error);
g_assert_no_error(error);
- while (counter < 4) {
+ while (counter < 2) {
g_print(" grab frame ... ");
uca_camera_grab(camera, &buffer, &error);
- if (error != NULL)
- break;
+ if (error != NULL) {
+ g_print("\nError: %s\n", error->message);
+ goto cleanup;
+ }
g_print("done\n");
snprintf(filename, FILENAME_MAX, "frame-%08i.raw", counter++);
@@ -78,11 +80,13 @@ int main(int argc, char *argv[])
fclose(fp);
}
- g_print("Start recording\n");
+ g_print("Stop recording\n");
uca_camera_stop_recording(camera, &error);
g_assert_no_error(error);
}
+cleanup:
+ uca_camera_stop_recording(camera, NULL);
g_object_unref(camera);
g_free(buffer);