genicam / harvesters

Image Acquisition Library for GenICam-based Machine Vision System
Apache License 2.0
500 stars 86 forks source link

"Error connecting FLIR and HikRobot: InvalidParameterException (ID: -1009)" #434

Open pathu999 opened 8 months ago

pathu999 commented 8 months ago

Describe the Issue I am encountering an error when attempting to connect FLIR and HikRobot devices within the Harvester repository.

To Reproduce Steps to reproduce the behavior: Initialize the connection to FLIR and HikRobot devices. Encounter the error: gentl.InvalidParameterException: GenTL exception: Parameter not valid or out of range. (Message from the source: Invalid enum. EVENT_TYPE iEventID = 5 Expected value = 1003.) (ID: -1009) Sample Code

Sample Code def _open_gentl_producers(self) -> None: global _logger

    for file_path in self._cti_files:
        raw_producer = GenTLProducer.create_producer()
        try:
            raw_producer.open(file_path)
        except GenTL_GenericException as e:
            _logger.warning(e, exc_info=True)
        else:
            self._producers.append(Producer(module=raw_producer))
            _logger.debug('initialized file: {0}'.format(raw_producer.path_name))

def _open_systems(self) -> None:
    global _logger

    for producer in self._producers:
        raw_system = producer.create_system()
        try:
            raw_system.open()
        except GenTL_GenericException as e:
            _logger.warning(e, exc_info=True)
        else:
            self._systems.append(System(module=raw_system, parent=producer))
            _logger.debug('opened: {0}'.format(_family_tree(raw_system)))

Proposed Solution: I have identified a potential solution to the issue. After investigating the problem, it appears that the connection issue might be resolved by ensuring the correct setup of the GenTL Producer object and the GenTL System object. Here is a proposed solution that you can try:

# Specify the path to the CTI file
path_name = os.path.join('MvProducerU3V.cti')

# Create a GenTLProducer object and open the CTI file
producer = GenTLProducer.create_producer()
producer.open(path_name)

# Create a GenTL System object and open it
system = producer.create_system()
system.open()
system.update_interface_info_list(5000)
interface = system.interface_info_list[0].create_interface()
interface.open()
interface.update_device_info_list(5000)
deviceTest = interface.device_info_list[0].create_device()
deviceTest.open(DEVICE_ACCESS_FLAGS_LIST.DEVICE_ACCESS_EXCLUSIVE)

Expected Behavior I expected the FLIR and HikRobot devices to connect successfully without any errors.

Actual Behavior: The connection attempt resulted in the specified error message, preventing the devices from connecting.

Configuration

Reproducibility

This phenomenon can be stably reproduced:

I can reliably reproduce this issue every time I attempt to connect the devices using the provided code snippet.

Additional context I have double-checked the CTI file path and confirmed that it is correct. I have also ensured that the necessary drivers for both FLIR and HikRobot devices are installed and up to date. Despite these efforts, the issue persists.