diff options
author | Matthias Vogelgesang <matthias.vogelgesang@kit.edu> | 2016-07-07 10:09:49 +0200 |
---|---|---|
committer | Matthias Vogelgesang <matthias.vogelgesang@kit.edu> | 2016-07-07 10:12:31 +0200 |
commit | d50e109380ef3a91e286ccd858b87e732eba0f1f (patch) | |
tree | 45371da372587887002135c69f3308778afffef1 /uca-ufo-camera.c | |
parent | ae0269155e1e2d0d602a0892b4bcdd2df708d53c (diff) | |
download | uca-ufo-d50e109380ef3a91e286ccd858b87e732eba0f1f.tar.gz uca-ufo-d50e109380ef3a91e286ccd858b87e732eba0f1f.tar.bz2 uca-ufo-d50e109380ef3a91e286ccd858b87e732eba0f1f.tar.xz uca-ufo-d50e109380ef3a91e286ccd858b87e732eba0f1f.zip |
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.
Diffstat (limited to 'uca-ufo-camera.c')
-rw-r--r-- | uca-ufo-camera.c | 18 |
1 files changed, 13 insertions, 5 deletions
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; |