genicam / harvesters

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

_gentl.IoException: GenTL exception: Communication error when trying to execute SoftwareTrigger #459

Open danielm-code opened 1 month ago

danielm-code commented 1 month ago

Describe the Issue When trying to acquire images, and executing a Software Trigger to do that, we observe the following error that there is a communication error. This is likely due to the parameter 'TriggerReady' constantly being set to 'False'. Following the documentation provided by KEYENCE, this parameter should be set to 'True' after triggering AcquisitionStart, but using debug commands it shows that it does not get set to 'True' afterwards.

To Reproduce Steps to reproduce the behavior:

  1. Execute the provided code in Python
  2. See error

Sample Code I can show a piece of code that demonstrates the reported phenomenon:

If yes, please provide a sample code:

h = Harvester()

h.add_file(r'/opt/mvIMPACT_Acquire/lib/x86_64/mvGenTLProducer.cti', check_existence=True, check_validity=True)

h.update()

ia = h.create(0)

# ========== SETUP MODE ==========
ia.remote_device.node_map.OperationMode.value = 'SetupMode'
ia.remote_device.node_map.ImageCaptureBufferEnable.value = True
ia.remote_device.node_map.TriggerSource.value = 'Software'
ia.remote_device.node_map.TriggerMode.value = 'On'

# ========== RUN MODE ==========
ia.remote_device.node_map.OperationMode.value = 'RunMode'

ia.remote_device.node_map.AcquisitionMode.value = 'SingleFrame'
ia.remote_device.node_map.MultiCaptureUpdateImage.value = True
ia.remote_device.node_map.MultiCaptureImageType.value = 'StdNormalImage'

print('TriggerSource:', ia.remote_device.node_map.TriggerSource.value)
print('TriggerMode:', ia.remote_device.node_map.TriggerMode.value)
print('TriggerReady:', ia.remote_device.node_map.TriggerReady.value, '\n')

ia.remote_device.node_map.TriggerSoftware.execute()

ia.destroy()
h.reset()
exit(0)

If applicable, please paste the actual output (its whole traceback, etc) here:

>>> ia.remote_device.node_map.TriggerSoftware.execute()
Traceback (most recent call last):
  File "test.py", line 37, in <module>
    ia.remote_device.node_map.TriggerSoftware.execute()
  File "/home/ubuntu/.local/lib/python3.8/site-packages/genicam/genapi.py", line 2796, in execute
    return _genapi.ICommand_execute(self, Verify)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/harvesters/_private/core/port.py", line 54, in write
    self.port.write(address, value)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/genicam/gentl.py", line 5016, in write
    return _gentl.Port_write(self, address, buffer)
_gentl.IoException: GenTL exception: Communication error, read or write to remote device failed. (Message from the source: Could not write data to 0xa214(4 bytes). Status: GEV_STATUS_ERROR.
) (ID: -1010)

Expected Behavior I expect the trigger command to be executed without error so that in parallel filled image buffers can be retrieved.

Screenshots

Configuration

Reproducibility

This phenomenon can be stably reproduced:

If applicable, please provide your observation about the reproducibility.

Actions You Have Taken

Additional context When trying to fetch a buffer filled with an image like in the tutorial, only a timeout is happening. So my understanding is, that for a buffer to be filled, first the image acquisition needs to be triggered (be it a hardware or a software trigger). In my use case I can only use a software trigger, which is the reason this error occurs.

sunavlis commented 1 week ago

Hi @danielm-code

Maybe there is a small adaption in your provided script required. Unfortunately I don't have the Camera which you are using. But usually the setup and run sequence looks like the following:

# snip...
camera = h.create(0)

camera.remote_device.node_map.TriggerSelector.value = 'FrameStart'
camera.remote_device.node_map.TriggerSource.value = 'Software'
camera.remote_device.node_map.TriggerMode.value = 'On'

camera.start()
camera.remote_device.node_map.TriggerSoftware.execute()
with camera.fetch(timeout=1000) as buffer:
    component = buffer.payload.components[0]
    print(f"Width: {component.width}")
    print(f"Height: {component.height}")
camera.stop()
# snip...

There are two main points:

  1. The feature TriggerSource has an selector TriggerSelector according to the GenICam standard which has to be configured as well.
  2. The acquisition engine on the device and on the computer must be started. This is done with camera.start(). It is possible that a software trigger is rejected when the device is not in the acquisition mode.

Please let me know, if this was useful.