areaDetector / ADVimba

areaDetector driver for Allied Vision Technology camera using their Vimba SDK
https://areadetector.github.io/master/ADVimba/ADVimba.html
1 stars 6 forks source link

ADVimba doesn't open camera successfully, but example code does #3

Closed jwlodek closed 2 years ago

jwlodek commented 2 years ago

Working on configuring a new Allied Vision camera with ADVimba (1800 u811m), USB3 based, and have ran into an issue that I can't seem to figure out. I was able to get the camera ID using the ListCameras example:

[jwlodek@dell-rhel8 x86_64bit]$ ./ListCameras 

//////////////////////////////////////
/// Vimba API List Cameras Example ///
//////////////////////////////////////

Vimba C++ API Version 1.9.0
Cameras found: 1

/// Camera Name    : Allied Vision 1800 U-811m
/// Model Name     : 1800 U-811m
/// Camera ID      : DEV_1AB22C012B2F
/// Serial Number  : 01N3J
/// @ Interface ID : VimbaUSBInterface_0x0

However, when running the Vimba IOC with this camera ID I get:

2022/06/29 17:02:16.085 ADVimba:connectCamera: ERROR calling VimbaSystem::OpenCameraByID error=-3
2022/06/29 17:02:16.085 ADVimba::connectCamera error opening camera DEV_1AB22C012B2F
2022/06/29 17:02:16.085 ADVimba:ADVimba:  camera connection failed (3)

Number of cameras detected: 0
Feature list
Port: VMB1
  Timestamp: <undefined>
  Input EOS[0]: 
  Output EOS[0]: 
Parameter list 0
Number of parameters is: 103

I know this is the correct ID, because another example, ListFeatures works, with this, and uses the same OpenCameraByID function that is called in connectCamera in ADVimba:

[jwlodek@dell-rhel8 x86_64bit]$ ./ListFeatures DEV_1AB22C012B2F

///////////////////////////////////////
/// Vimba API List Features Example ///
///////////////////////////////////////

Vimba C++ API Version 1.9.0
Printing all features of camera with ID: DEV_1AB22C012B2F
/// Feature Name   : AcquisitionFrameCount
/// Display Name   : Acquisition Frame Count
/// Tooltip        : Number of frames to acquire in MultiFrame Acquisition mode.
/// Description    : Number of frames to acquire in MultiFrame Acquisition mode.
/// SNFC Namespace : Standard
/// Unit           : 
/// Value          : Could not get feature value. Error code: -6 (Invalid access.)
/// Minimum        : 1
/// Maximum        : 65534
/// Type           : Long long integer
...

The output of the above command is very long so I cropped it just to show that the camera was found and opened.

This is the function from ListFeatures:

err = sys.OpenCameraByID( "DEV_1AB22C012B2F", VmbAccessModeFull, pCamera ); // Get and open the camera

I have setup ADVimba to build with Vimba 6.0 which is the version I have downloaded, but that hasn't seemed to change much. I also thought it could be permission related, but I can run the examples as myself and have no problem, and running as root had the same issue.

Is there something else I'm missing here?

MarkRivers commented 2 years ago

I am trying to understand how this could happen. Are you running the version of ListCameras.cpp that is in vimbaApp/src, or a version in their SDK?

Note that when the driver fails to connect to the camera then it calls report(stdout, 1) in this line: https://github.com/areaDetector/ADVimba/blob/a8a8bdd27149f7b8b8d73a4ea8397c0e25cf5bb0/vimbaApp/src/ADVimba.cpp#L156

report() does this:

    checkError(system_.GetCameras(cameras), functionName, "VimbaSystem::GetCameras()");
    numCameras = (int)cameras.size();
    fprintf(fp, "\nNumber of cameras detected: %d\n", numCameras);

The output you get is this:

Number of cameras detected: 0
Feature list

That means that GetCameras did not return an error, because if it did checkError() would have printed an error message. However, the cameras vector that it returned was 0 length, so it says that 0 cameras are found.

If you are running the version of ListCameras.cpp in vimbaApp/src then I don't understand why in GetCameras returned 1 camera in ListCameras.cpp but 0 cameras in ADVimba.cpp.

I have setup ADVimba to build with Vimba 6.0 which is the version I have downloaded, but that hasn't seemed to change much.

Did you first try with the version of Vimba that is included with ADVimba? You should not need to download anything to do that.

Note that when you ran "ListFeatures" you did get an error:

/// Value          : Could not get feature value. Error code: -6 (Invalid access.)

Could that be indicating that some other process has the camera open and prevents you from reading the feature value?

jwlodek commented 2 years ago

The ListCameras and ListFeatures I was running was from their SDK, installed in /opt/Vimba64_v6.0..., I am out of office at the moment but tomorrow I can try to see if the examples in vimbaApp produce a different result.

I originally tried the Vimba SDK included with ADVimba, but was getting this same issue, and considering the camera is a fairly new model I assumed that I needed the newer SDK. Another thing I tried was to link against some additional libraries (libusb-1.0 etc.) thinking that maybe GetCameras was silently failing to detect a USB based camera, but this gave the same result.

Could that be indicating that some other process has the camera open and prevents you from reading the feature value?

I think this is unlikely, I didn't have any other programs opened, and most of the other features listed correctly - I'm not entirely sure why this first one did not

MarkRivers commented 2 years ago

I originally tried the Vimba SDK included with ADVimba, but was getting this same issue, and considering the camera is a fairly new model I assumed that I needed the newer SDK.

Did you replace all of the files in ADVimba/vimbaSupport with those from the new SDK? If so, did that lead to any warnings or errors when building ADVimba?

I found that the master branch was not building vimbaApp/src/ListCameras.cpp. I fixed the Makefile to do that. I also updated an include file that was out of date. It is needed only for the test program. Be sure to pull the latest master branch. To run ListCameras you need to define the environment variable described in vimbaApp/src/Makefile.

I suggest using the master branch and testing if ListCameras there works.

It is finding my GigE cameras fine on Linux and Windows. This is Linux:

corvette:~/devel/areaDetector/ADVimba>bin/linux-x86_64/ListCameras

//////////////////////////////////////
/// Vimba API List Cameras Example ///
//////////////////////////////////////

Vimba C++ API Version 1.8.2
Cameras found: 5

/// Camera Name    : GC1380H
/// Model Name     : GC1380H (02-2142A)
/// Camera ID      : DEV_000F3100C3BE
/// Serial Number  : 02-2142A-06110
/// @ Interface ID : p5p1

/// Camera Name    : GC1380CH
/// Model Name     : GC1380CH (02-2143A)
/// Camera ID      : DEV_000F3100C75F
/// Serial Number  : 02-2143A-06039
/// @ Interface ID : p5p1

/// Camera Name    : GT1380
/// Model Name     : GT1380 (02-2604A)
/// Camera ID      : DEV_000F31021909
/// Serial Number  : 02-2604A-07008
/// @ Interface ID : p5p1

/// Camera Name    : Manta_G-146C
/// Model Name     : Manta_G-146C (E0020011)
/// Camera ID      : DEV_000F314C4DFA
/// Serial Number  : 50-0503317598
/// @ Interface ID : p5p1

/// Camera Name    : Manta
/// Model Name     : Manta G-507C (E0022705)
/// Camera ID      : DEV_000F314DDB16
/// Serial Number  : 50-0503419258
/// @ Interface ID : p5p1

This is Windows:

J:\epics\devel\areaDetector-3-12-1\ADVimba>bin\windows-x64-static\ListCameras.exe

//////////////////////////////////////
/// Vimba API List Cameras Example ///
//////////////////////////////////////

Vimba C++ API Version 1.8.2
Cameras found: 5

/// Camera Name    : GC1380H
/// Model Name     : GC1380H (02-2142A)
/// Camera ID      : DEV_000F3100C3BE
/// Serial Number  : 02-2142A-06110
/// @ Interface ID : Ethernet

/// Camera Name    : GC1380CH
/// Model Name     : GC1380CH (02-2143A)
/// Camera ID      : DEV_000F3100C75F
/// Serial Number  : 02-2143A-06039
/// @ Interface ID : Ethernet

/// Camera Name    : GT1380
/// Model Name     : GT1380 (02-2604A)
/// Camera ID      : DEV_000F31021909
/// Serial Number  : 02-2604A-07008
/// @ Interface ID : Ethernet

/// Camera Name    : Manta_G-146C
/// Model Name     : Manta_G-146C (E0020011)
/// Camera ID      : DEV_000F314C4DFA
/// Serial Number  : 50-0503317598
/// @ Interface ID : Ethernet

/// Camera Name    : Manta
/// Model Name     : Manta G-507C (E0022705)
/// Camera ID      : DEV_000F314DDB16
/// Serial Number  : 50-0503419258
/// @ Interface ID : Ethernet

I don't have any Allied Vision USB cameras so I can't test that.

MarkRivers commented 2 years ago

I think I may have just figured out the problem. ADVimba was only installing the Transport Layer (TL) files for GigE, not for USB. I just added the USB TL files to ADVimba and changed the Makefile to install them. I am 99% sure this was the problem. When you run the IOC the environment variable to set the path to them was already done in st.cmd.base. When running ListCameras you need to manually set that environment variable as described in the Makefile.

At some point we should also install the CameraLink TL files.

jwlodek commented 2 years ago

Trying to build the master branch now, but seems the USB TL files weren't commited? At least I don't see them here: https://github.com/areaDetector/ADVimba/tree/master/vimbaSupportC/os/linux-x86_64

Installing VimbaGigETL.xml
make[2]: *** No rule to make target '../os/linux-x86_64/VimbaUSBTL.cti', needed by '..//../bin/linux-x86_64/VimbaUSBTL.cti'.  Stop.
make[2]: Leaving directory '/epics/utils/rhel8-epics-config/BUILD/support/areaDetector/ADVimba/vimbaSupportC/O.linux-x86_64'
make[1]: *** [/epics/utils/rhel8-epics-config/BUILD/base/configure/RULES_ARCHS:58: install.linux-x86_64] Error 2
make[1]: Leaving directory '/epics/utils/rhel8-epics-config/BUILD/support/areaDetector/ADVimba/vimbaSupportC'
make: *** [/epics/utils/rhel8-epics-config/BUILD/base/configure/RULES_DIRS:85: vimbaSupportC.install] Error 2
MarkRivers commented 2 years ago

Sorry, I forgot to add them. They are there now.

jwlodek commented 2 years ago

That seems to have been the problem, I can now connect to the camera successfully. I guess if I had set the environment variable to point to those files in /opt... it would have worked as well. Thanks!