From e6f5f67068c575a51a05845353c673c77be6530a Mon Sep 17 00:00:00 2001 From: Matthias Vogelgesang Date: Wed, 16 Mar 2016 10:28:34 +0100 Subject: Use current exported symbol name See https://github.com/ufo-kit/libuca/commit/6c2c19d1101a043cc0b05065447cc9321ed32ac0 --- uca-ufo-camera.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'uca-ufo-camera.c') diff --git a/uca-ufo-camera.c b/uca-ufo-camera.c index 7455824..e3c16e5 100644 --- a/uca-ufo-camera.c +++ b/uca-ufo-camera.c @@ -762,7 +762,7 @@ uca_ufo_camera_init(UcaUfoCamera *self) } G_MODULE_EXPORT GType -uca_camera_get_type (void) +camera_plugin_get_type (void) { return UCA_TYPE_UFO_CAMERA; } -- cgit v1.2.3 From 715038226f9209fde8192e1b04c3f2671a669eca Mon Sep 17 00:00:00 2001 From: Matthias Vogelgesang Date: Fri, 3 Jun 2016 15:08:28 +0200 Subject: Fix software trigger ... again --- uca-ufo-camera.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'uca-ufo-camera.c') diff --git a/uca-ufo-camera.c b/uca-ufo-camera.c index e3c16e5..eee1145 100644 --- a/uca-ufo-camera.c +++ b/uca-ufo-camera.c @@ -328,7 +328,6 @@ uca_ufo_camera_start_recording (UcaCamera *camera, GError **error) "trigger-type", &trigger_type, NULL); - set_control_bit (priv, 3, trigger_source == UCA_CAMERA_TRIGGER_SOURCE_SOFTWARE); set_control_bit (priv, 11, trigger_source == UCA_CAMERA_TRIGGER_SOURCE_AUTO); set_control_bit (priv, 14, trigger_source == UCA_CAMERA_TRIGGER_SOURCE_EXTERNAL); set_control_bit (priv, 15, trigger_type == UCA_CAMERA_TRIGGER_TYPE_EDGE && @@ -443,6 +442,9 @@ uca_ufo_camera_trigger (UcaCamera *camera, GError **error) priv = UCA_UFO_CAMERA_GET_PRIVATE(camera); + set_control_bit (priv, 3, TRUE); + set_control_bit (priv, 3, FALSE); + /* XXX: What is PCILIB_EVENT0? */ err = pcilib_trigger (priv->handle, PCILIB_EVENT0, 0, NULL); PCILIB_SET_ERROR (err, UCA_UFO_CAMERA_ERROR_TRIGGER); -- cgit v1.2.3 From 5553af504a38a7671fbba8ea2389de8852f82121 Mon Sep 17 00:00:00 2001 From: Matthias Vogelgesang Date: Wed, 22 Jun 2016 10:28:31 +0200 Subject: Do not stop/close pcilib if we never had a handle --- uca-ufo-camera.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'uca-ufo-camera.c') diff --git a/uca-ufo-camera.c b/uca-ufo-camera.c index eee1145..a5d5235 100644 --- a/uca-ufo-camera.c +++ b/uca-ufo-camera.c @@ -659,12 +659,14 @@ uca_ufo_camera_finalize(GObject *object) priv = UCA_UFO_CAMERA_GET_PRIVATE (object); - int err = pcilib_stop (priv->handle, PCILIB_EVENT_FLAGS_DEFAULT); - PCILIB_WARN_ON_ERROR (err); + if (priv->handle != NULL) { + int err = pcilib_stop (priv->handle, PCILIB_EVENT_FLAGS_DEFAULT); + PCILIB_WARN_ON_ERROR (err); - pcilib_close (priv->handle); - g_clear_error (&priv->construct_error); + pcilib_close (priv->handle); + } + g_clear_error (&priv->construct_error); G_OBJECT_CLASS (uca_ufo_camera_parent_class)->finalize (object); } -- cgit v1.2.3 From cdb0c46e6e41c196b83773efbed8c53b51c30576 Mon Sep 17 00:00:00 2001 From: Matthias Vogelgesang Date: Mon, 4 Jul 2016 15:29:01 +0200 Subject: Track current pcilib --- uca-ufo-camera.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'uca-ufo-camera.c') diff --git a/uca-ufo-camera.c b/uca-ufo-camera.c index a5d5235..6957342 100644 --- a/uca-ufo-camera.c +++ b/uca-ufo-camera.c @@ -155,7 +155,7 @@ write_register_value (pcilib_t *handle, const gchar *name, pcilib_register_value } static int -event_callback(pcilib_event_id_t event_id, pcilib_event_info_t *info, void *user) +event_callback(pcilib_event_id_t event_id, const pcilib_event_info_t *info, void *user) { UcaCamera *camera = UCA_CAMERA(user); UcaUfoCameraPrivate *priv = UCA_UFO_CAMERA_GET_PRIVATE(camera); @@ -204,6 +204,9 @@ update_properties (UcaUfoCameraPrivate *priv) case PCILIB_REGISTER_RW1I: flags = G_PARAM_READWRITE; break; + case PCILIB_REGISTER_INCONSISTENT: + g_warning ("%s is an inconsistent register, don't know how to handle that", reg->name); + break; } value = read_register_value (priv->handle, reg->name); -- cgit v1.2.3 From ae0269155e1e2d0d602a0892b4bcdd2df708d53c Mon Sep 17 00:00:00 2001 From: Matthias Vogelgesang Date: Mon, 4 Jul 2016 15:55:54 +0200 Subject: Add adjustable "timeout" property --- uca-ufo-camera.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'uca-ufo-camera.c') diff --git a/uca-ufo-camera.c b/uca-ufo-camera.c index 6957342..041efe7 100644 --- a/uca-ufo-camera.c +++ b/uca-ufo-camera.c @@ -81,6 +81,7 @@ GQuark uca_ufo_camera_error_quark() enum { PROP_SENSOR_TEMPERATURE = N_BASE_PROPERTIES, PROP_FPGA_TEMPERATURE, + PROP_TIMEOUT, PROP_UFO_START, N_MAX_PROPERTIES = 512 }; @@ -115,6 +116,7 @@ struct _UcaUfoCameraPrivate { GHashTable *property_table; /* maps from prop_id to RegisterInfo* */ GThread *async_thread; pcilib_t *handle; + pcilib_timeout_t timeout; guint n_bits; guint roi_height; guint roi_start; @@ -407,7 +409,7 @@ uca_ufo_camera_grab(UcaCamera *camera, gpointer data, GError **error) const gsize size = CMOSIS_SENSOR_WIDTH * priv->roi_height * sizeof(guint16); - err = pcilib_get_next_event (priv->handle, PCILIB_TIMEOUT_INFINITE, &event_id, sizeof(pcilib_event_info_t), &event_info); + err = pcilib_get_next_event (priv->handle, priv->timeout, &event_id, sizeof(pcilib_event_info_t), &event_info); PCILIB_SET_ERROR_RETURN_FALSE (err, UCA_UFO_CAMERA_ERROR_NEXT_EVENT); gpointer src = pcilib_get_data (priv->handle, event_id, PCILIB_EVENT_DATA, (size_t *) &err); @@ -544,6 +546,9 @@ uca_ufo_camera_set_property(GObject *object, guint property_id, const GValue *va } } break; + case PROP_TIMEOUT: + priv->timeout = g_value_get_uint64 (value); + break; default: { RegisterInfo *reg_info; @@ -642,6 +647,9 @@ uca_ufo_camera_get_property(GObject *object, guint property_id, GValue *value, G case PROP_NAME: g_value_set_string (value, "Ufo Camera w/ CMOSIS CMV2000"); break; + case PROP_TIMEOUT: + g_value_set_uint64 (value, priv->timeout); + break; default: { RegisterInfo *reg_info = g_hash_table_lookup (priv->property_table, GINT_TO_POINTER (property_id)); @@ -741,6 +749,13 @@ uca_ufo_camera_class_init(UcaUfoCameraClass *klass) -G_MAXDOUBLE, G_MAXDOUBLE, 0.0, G_PARAM_READABLE); + ufo_properties[PROP_TIMEOUT] = + g_param_spec_uint64("timeout", + "Timeout in milliseconds", + "Timeout in milliseconds", + 0, G_MAXUINT64, 5000, + G_PARAM_READWRITE); + g_type_class_add_private(klass, sizeof(UcaUfoCameraPrivate)); } @@ -754,6 +769,7 @@ uca_ufo_camera_init(UcaUfoCamera *self) self->priv = priv = UCA_UFO_CAMERA_GET_PRIVATE(self); priv->construct_error = NULL; priv->async_thread = NULL; + priv->timeout = 5000; if (!setup_pcilib (priv)) return; -- cgit v1.2.3 From d50e109380ef3a91e286ccd858b87e732eba0f1f Mon Sep 17 00:00:00 2001 From: Matthias Vogelgesang Date: Thu, 7 Jul 2016 10:09:49 +0200 Subject: Fix #2: reset frame request and flush at the end This is an intermediate fix proposed by Michele but not really solving the underlying issue of the FPGA getting stuck. The fix consists of two separate solutions: 1. In case we encounter an error while grabbing we reset the command queue on the FPGA (i.e. flipping third bit on the control register). 2. We read all stale data from the FPGA with a timeout now. Before it was still possible to have stale data in the DDR thus corrupting subsequent data reads. --- uca-ufo-camera.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'uca-ufo-camera.c') diff --git a/uca-ufo-camera.c b/uca-ufo-camera.c index 041efe7..be06040 100644 --- a/uca-ufo-camera.c +++ b/uca-ufo-camera.c @@ -357,7 +357,6 @@ static void uca_ufo_camera_stop_recording (UcaCamera *camera, GError **error) { UcaUfoCameraPrivate *priv; - UcaCameraTriggerSource trigger_source; pcilib_event_id_t event_id; pcilib_event_info_t event_info; int err; @@ -369,8 +368,6 @@ uca_ufo_camera_stop_recording (UcaCamera *camera, GError **error) set_control_bit (priv, 14, FALSE); /* disable external trigger */ set_control_bit (priv, 11, FALSE); /* disable streaming */ - g_object_get (G_OBJECT (camera), "trigger-source", &trigger_source, NULL); - if (priv->async_thread) { err = pcilib_stop(priv->handle, PCILIB_EVENT_FLAG_STOP_ONLY); PCILIB_SET_ERROR(err, UCA_UFO_CAMERA_ERROR_STOP_RECORDING); @@ -379,7 +376,7 @@ uca_ufo_camera_stop_recording (UcaCamera *camera, GError **error) } /* read stale frames ... */ - while (!pcilib_get_next_event (priv->handle, 0, &event_id, sizeof (pcilib_event_info_t), &event_info)) + while (!pcilib_get_next_event (priv->handle, priv->timeout, &event_id, sizeof (pcilib_event_info_t), &event_info)) ; err = pcilib_stop (priv->handle, PCILIB_EVENT_FLAGS_DEFAULT); @@ -410,6 +407,17 @@ uca_ufo_camera_grab(UcaCamera *camera, gpointer data, GError **error) const gsize size = CMOSIS_SENSOR_WIDTH * priv->roi_height * sizeof(guint16); err = pcilib_get_next_event (priv->handle, priv->timeout, &event_id, sizeof(pcilib_event_info_t), &event_info); + + /* + * Try to recover from errors by flushing pending requests. This is curing + * symptoms but not the actual problem. + */ + if (err != 0) { + set_control_bit (priv, 2, TRUE); + g_usleep (10); + set_control_bit (priv, 2, FALSE); + } + PCILIB_SET_ERROR_RETURN_FALSE (err, UCA_UFO_CAMERA_ERROR_NEXT_EVENT); gpointer src = pcilib_get_data (priv->handle, event_id, PCILIB_EVENT_DATA, (size_t *) &err); @@ -769,7 +777,7 @@ uca_ufo_camera_init(UcaUfoCamera *self) self->priv = priv = UCA_UFO_CAMERA_GET_PRIVATE(self); priv->construct_error = NULL; priv->async_thread = NULL; - priv->timeout = 5000; + priv->timeout = 100000; if (!setup_pcilib (priv)) return; -- cgit v1.2.3 From 199edb1bbf35da2b0d0624a6f3d2860b8be7a6e3 Mon Sep 17 00:00:00 2001 From: Matthias Vogelgesang Date: Tue, 12 Jul 2016 10:40:22 +0200 Subject: Fix default value trigger timeout --- uca-ufo-camera.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'uca-ufo-camera.c') diff --git a/uca-ufo-camera.c b/uca-ufo-camera.c index be06040..7fb6781 100644 --- a/uca-ufo-camera.c +++ b/uca-ufo-camera.c @@ -761,7 +761,7 @@ uca_ufo_camera_class_init(UcaUfoCameraClass *klass) g_param_spec_uint64("timeout", "Timeout in milliseconds", "Timeout in milliseconds", - 0, G_MAXUINT64, 5000, + 0, G_MAXUINT64, 100000, G_PARAM_READWRITE); g_type_class_add_private(klass, sizeof(UcaUfoCameraPrivate)); -- cgit v1.2.3