areaDetector / ADAravis

areaDetector driver for GenICam cameras using the Aravis library on Linux.
https://areadetector.github.io/master/ADAravis/ADAravis.html
6 stars 8 forks source link

Channel control not relinquished on camera reset #22

Closed daykin closed 12 months ago

daykin commented 1 year ago

On our Imaging Source cameras, hitting ARResetCamera when the camera is already initialized and connected results in a degraded state where the camera cannot be controlled. The only remedy I have found at this point is to restart the camera.

to reproduce:

aravisConfig("ARV1", "The Imaging Source Europe GmbH-36510395")
ADAravis: Looking for camera 'The Imaging Source Europe GmbH-36510395'... 
ADAravis: Your tick frequency is 1000000
So your timestamp resolution is 1000.000000 ns
epics> dbpf test-cam:ARResetCamera 1
ADAravis: Looking for camera 'The Imaging Source Europe GmbH-36510395'... 
I am a GigEVision device.
2023/04/28 14:11:25.791 ADAravis:makeCameraObject: Another client has control of this camera.
2023/04/28 14:11:25.791 ADAravis:writeInt32 error, status=3 function=115 ARAVIS_RESET, value=1
2023/04/28 14:11:25.791 FE_SCS1:VD_D0739:cam1:ARResetCamera devAsynInt32::processCallbackOutput process write error 
2023/04/28 14:11:25.792 FE_SCS1:VD_D0739:cam1:ARConnectCamera devAsynInt32::processCallbackOutput process write error 
2023/04/28 14:11:26.322 ADAravis:writeInt32 error, status=3 function=90 READ_STATUS, value=1
2023/04/28 14:11:26.322 FE_SCS1:VD_D0739:cam1:ReadStatus devAsynInt32::processCallbackOutput process write error 
2023/04/28 14:11:27.322 ADAravis:writeInt32 error, status=3 function=90 READ_STATUS, value=1
...

The cause (I think): the GigE channel control privilege register is not reset when ARResetCamera is toggled and makeCameraObject() is called. Therefore, the new device instance comes back without control of the camera.

Proposed solution: relinquish control of the channel if we have an existing camera, that camera is a GigEVision device, and we have client control of the device.

From d84d90db2ead73c53ad6e157c2e5f15dc8daa43c Mon Sep 17 00:00:00 2001
From: Evan Daykin <daykin@frib.msu.edu>
Date: Fri, 28 Apr 2023 14:39:56 -0400
Subject: [PATCH 1/1] Fix: Relinquish channel control on reset

---
 aravisApp/src/ADAravis.cpp | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/aravisApp/src/ADAravis.cpp b/aravisApp/src/ADAravis.cpp
index 72fcdef..feb2068 100644
--- a/aravisApp/src/ADAravis.cpp
+++ b/aravisApp/src/ADAravis.cpp
@@ -398,7 +398,20 @@ asynStatus ADAravis::makeCameraObject() {

     GErrorHelper err;
     /* remove old camera if it exists */
+    /* relinquish CCP before unreferencing it */
     if (this->camera != NULL) {
+        if(arv_camera_is_gv_device(this->camera) && arv_gv_device_is_controller(ARV_GV_DEVICE(this->device))){
+            if (!(arv_gv_device_leave_control(ARV_GV_DEVICE(this->device),err.get()))){
+                asynPrint(this->pasynUserSelf, ASYN_TRACE_ERROR,
+                    "%s:%s: Current ArvGvDevice has control, but control couldn't be relinquished. err=%s\n",
+                    driverName, functionName, err->message);
+            }
+            else {
+                asynPrint(this->pasynUserSelf, ASYN_TRACE_FLOW,
+                    "%s:%s: Relinquished control of camera.\n",
+                    driverName, functionName);
+            }
+        }
         g_object_unref(this->camera);
         this->camera = NULL;
     }
-- 
2.30.2
MarkRivers commented 12 months ago

Closed via #23

davidwx commented 7 months ago

../ADAravis.cpp:404:84: error:‘arv_gv_device_leave_control’ not defined?

MarkRivers commented 7 months ago

You need a more recent release of aravis 8.

davidwx commented 7 months ago

I followed the instrcution from https://areadetector.github.io/areaDetector/ADGenICam/ADGenICam.html#installing-aravis git clone https://github.com/AravisProject/aravis cd aravis/ git checkout ARAVIS_0_8_1 Mybe it need to be updated.

MarkRivers commented 7 months ago

I added a note to the ADAravis RELEASE.md for R2-3: https://github.com/areaDetector/ADAravis/blob/master/RELEASE.md

This release requires aravis version ARAVIS_0_8_3 or higher, because that is when arv_gv_leave_control() was added.
MarkRivers commented 7 months ago

I also changed the documentation for installing aravis in ADGenICam, to recommend using the latest release, and 0.8.3 as a minimum. https://areadetector.github.io/areaDetector/ADGenICam/ADGenICam.html#installing-aravis