Blackfly Camera Error Writing To Registers After Initialization
Hi,
I am using a Blackfly S BFLY-U3-51S5M-C camera (firmware version 1605.1.3.0) and I am encountering a sporadic issue where registers can't be set after initializing the camera. The following python script using PySpin can be used to replicate the issue:
import PySpin
def setEnumerationNode(enum_node, enum_node_name, entry_name):
enumNodePtr = PySpin.CEnumerationPtr(enum_node)
if PySpin.IsAvailable(enumNodePtr) and PySpin.IsWritable(enumNodePtr):
# Retrieve the desired entry node from the enumeration node
entryNodePtr = PySpin.CEnumEntryPtr(enumNodePtr.GetEntryByName(entry_name))
if PySpin.IsAvailable(entryNodePtr) and PySpin.IsReadable(entryNodePtr):
# Retrieve the integer value from the entry node
entryNodeVal = entryNodePtr.GetValue()
# Set integer as new value for enumeration node
enumNodePtr.SetIntValue(entryNodeVal)
else:
raise PySpin.SpinnakerException(f"Entry node {entry_name} of enumeration node {enum_node_name} either not "
f"available or not readable")
else:
raise PySpin.SpinnakerException(f"Enumeration node {enum_node_name} either not available or not writable")
print(f'Set {enum_node_name} to {entry_name}')
system = PySpin.System.GetInstance()
camList = system.GetCameras()
cam = camList[0]
cam.Init()
nodeMap = cam.GetNodeMap()
triggerModeNode = nodeMap.GetNode('TriggerMode')
setEnumerationNode(triggerModeNode, 'TriggerMode', 'Off')
when the enumNodePtr.SetIntValue(entryNodeVal) line is executed, an exception with the following error is raised:
"error writing to device at register address: 000C004. Please try reconnecting the device [-1008]"
Any help would be much appreciated! Thanks!
-
Hello Neil,
I do not see anything wrong with this code except that camera resources are not managed very well. The section to delete camera object, clear camera list and release system instance are missing:
# delete camera object
del cam# Clear camera list before releasing system
camList.Clear()# Release system instance
system.ReleaseInstance()Omitting these sections may lead camera to enter bad state after mulitple run. I would include this code section and power cycle camera.
Note: It should also work fine with "enumNodePtr.GetEntryByName(entry_name)" instead of "PySpin.CEnumEntryPtr(enumNodePtr.GetEntryByName(entry_name))"
For further related question, please reference projects in "Examples" folder part of spinnaker python package.
I hope the provided information answered your question.
Thanks,
Ifeanyi0
Please sign in to leave a comment.
Comments
1 comment