alliedvision / VimbaPython

Old Allied Vision Vimba Python API. The successor to this API is VmbPy
BSD 2-Clause "Simplified" License
93 stars 40 forks source link

IndexError when disconnecting Ethernet #156

Open JaegerStephan opened 1 year ago

JaegerStephan commented 1 year ago

Setup

Issue

when a vimba instance is running and the ethernet cable is disconnected from PC, an unexpected error raises

Exemplary code

import vimba
import time

with vimba.Vimba.get_instance() as vb:
    print(vb.get_all_interfaces())
    while True:
        time.sleep(5)
        print(vb.get_all_interfaces())

Error

Traceback (most recent call last):
  File "C:\Users\jaegeste\Documents\Coding\insight-vision-capture\venv311\Lib\site-packages\vimba\feature.py", line 310, in __feature_cb_wrapper
    raise e
  File "C:\Users\jaegeste\Documents\Coding\insight-vision-capture\venv311\Lib\site-packages\vimba\feature.py", line 302, in __feature_cb_wrapper
    handler(self)
  File "C:\Users\jaegeste\Documents\Coding\insight-vision-capture\venv311\Lib\site-packages\vimba\vimba.py", line 573, in __inter_cb_wrapper
    inter = [i for i in self.__inters if inter_id == i.get_id()].pop()

Since there is an IndexError mentioned, I tried to catch the exception like

import vimba
import time

try:
    with vimba.Vimba.get_instance() as vb:
        print(vb.get_all_interfaces())
        while True:
            time.sleep(5)
            print(vb.get_all_interfaces())
except IndexError as e:
    print("error")
    print(e)

which unfortunately does not result in any print.

Help

Can you please provide some information what might be the issue or if you consider it as an bug, fix it.

Teresa-AlliedVision commented 1 year ago

Hi, I was unable to reproduce the issue with connecting and disconnecting the camera. Please enable logging, vb.enable_log(LOG_CONFIG_TRACE_FILE_ONLY) should do the trick, but have a look at the manual for more options. Please don't post the trace log as text, but as a file, they can get really long. Do you have Vimba6 and Vimba Python 1.2.1 ?

JaegerStephan commented 1 year ago

The error does not raise if I disconnect the plug from the camera but if I disconnect the plug from my notebook. Is it possible that there are any differences?

I use Vimba6 and VimbaPython 1.2.1.

Please find attached the log file (renamed to trace.txt because I cannot upload a .log file). trace.txt

Teresa-AlliedVision commented 1 year ago

Are you using a switch? The same error happened when I disconnected my switch, that had a camera connected. I'll forward a bug report, but a fix will probably be only in VimbaX.

JaegerStephan commented 1 year ago

Yes, you are right, I'm using a switch. Sorry, that forgot to mention. Since you mention VimbaX: is there a general recommendation for using VimbaX. Few weeks ago I sent a message via your web contact formular in which I asked for which Vimba is best to choose (Vimba or VimbaX). The result of messaging was to keep with Vimba instead of VimbaX (at least for Manta cameras). Would you agree?

Teresa-AlliedVision commented 1 year ago

If you are using non-Alvium cameras with chunk data and/or events or have a well running system on Vimba already and no time for migration, then we generally don't encourage a change right now. Chunk and Events were non-GenICam compliant in Manta/Mako/Prosilica, so they do not work with VimbaX. Generally the cameras can be run with VimbaX too, of course. If you need a bug fix, that came in VimbaX, the newer runtime dll for the underlying C-API or start a new development, then switching would be encouraged. I found the case and agree with my collegue, that if it is possible that you will need any of the proprietary features I mentioned, then staying with Vimba might be better. I think this is a decsion that depends heavily on your application and what future add ons should be planned for.