Hi, I am writing a custom script were I am receiving str data thru the serial port of the mcu and the bfs camera. Three of this commands are used to set the configuration for the gpio pins, specifically BFS_GPIO, pin 3, line 2. I am getting an issue were I write twice to the same line and then an exception is thrown stating:
Error: Spinnaker: GenICam::AccessException= Failed to write enumeration value. Enum entry is not writable : AccessException thrown in node 'LineMode' while calling 'LineMode.SetIntValue()' (file 'Enumeration.cpp', line 149) [-2006]
The way I found out this was when, I would set the bfs configuration for line 2 as output and then i would like to set it as input, the exception is thrown and vice-versa. If I power cycle the camera and run the script again I would be able to set the configuration again but only once to either output w 3v3 rail or input. is there a node that I am missing???? or is there a way to reset the 'LineMode' node ????
import PySpin
from enum import Enum, auto
from general import Singleton
class enviromentPwr(Enum):
PWR_MODE_POE = 0
PWR_DISCRETE_2 = 1
PWR_DISCRETE_3 = 2
class mock_gpioSystemState(metaclass=Singleton):
def __init__(self,nodemap) -> None:
self.case = 0
self.nodemap = nodemap
self.prevState = 0
self.currentState = 0
self.tempState = 0
def reset(self):
pass
def set_serial_com_controller(self,serialCom):
self.serialCom = serialCom
def bfsGpio_statusLine(self):
try:
node_statusAll = PySpin.CIntegerPtr(self.nodemap.GetNode('LineStatusAll'))
if not PySpin.IsReadable(node_statusAll):
print('error trying to read LineStatusAll')
return False
node_statusAll = node_statusAll.GetValue()
print(f'status: {node_statusAll}')
returnnode_statusAll
except PySpin.SpinnakerException as ex:
print('Error: %s' % ex)
def getpowerModeBfs(self):
print(f'current state: {self.currentState}')
return self.currentState
def mode(self,case):
self.case = case
setCase = False
node_line3 = PySpin.CEnumerationPtr(self.nodemap.GetNode('LineSelector'))
if not PySpin.IsWritable(node_line3):
pass
node_line3.SetIntValue(3) #line3
node_line3Mode = PySpin.CEnumerationPtr(self.nodemap.GetNode('LineMode'))
if not PySpin.IsWritable(node_line3Mode):
pass
node_line3Mode.SetIntValue(0) #input
try:
match(self.case):
case(0):
print('\rError...\n')
case(1):
if self.currentState != enviromentPwr.PWR_MODE_POE:
#set cmr gpio pin3 line2 red to 3.3vout
node_lineSelector = PySpin.CEnumerationPtr(self.nodemap.GetNode('LineSelector'))
if not PySpin.IsWritable(node_lineSelector):
setCase = False
node_lineSelector.SetIntValue(2) #line2
node_lineMode = PySpin.CEnumerationPtr(self.nodemap.GetNode('LineMode'))
if not PySpin.IsWritable(node_lineMode):
setCase = False
node_lineMode.SetIntValue(1) #out
node_V3_3Enable = PySpin.CBooleanPtr(self.nodemap.GetNode('V3_3Enable'))
if not PySpin.IsWritable(node_V3_3Enable):
setCase = False
node_V3_3Enable.SetValue(True)
self.currentState = enviromentPwr(0)
setCase = True
else:
setCase = True
case(2):
if self.currentState == enviromentPwr.PWR_MODE_POE:
#set cmr gpio pin3 line2 red to 3.3vout
node_lineSelector = PySpin.CEnumerationPtr(self.nodemap.GetNode('LineSelector'))
if not PySpin.IsWritable(node_lineSelector):
setCase = False
node_lineSelector.SetIntValue(2) #line2
node_lineMode = PySpin.CEnumerationPtr(self.nodemap.GetNode('LineMode'))
if not PySpin.IsWritable(node_lineMode):
setCase = False
node_lineMode.SetIntValue(1) #out
node_V3_3Enable = PySpin.CBooleanPtr(self.nodemap.GetNode('V3_3Enable'))
if not PySpin.IsWritable(node_V3_3Enable):
setCase = False
node_V3_3Enable.SetValue(False)
node_lineMode = PySpin.CEnumerationPtr(self.nodemap.GetNode('LineMode'))
if not PySpin.IsWritable(node_lineMode):
setCase = False
node_lineMode.SetIntValue(0) #input
self.currentState = enviromentPwr(1)
setCase = True
case(3):
#set cmr gpio pin3 line2 red wire to out I/O
node_lineSelector = PySpin.CEnumerationPtr(self.nodemap.GetNode('LineSelector'))
if not PySpin.IsWritable(node_lineSelector):
setCase = False
node_lineSelector.SetIntValue(2) #line2
node_lineMode = PySpin.CEnumerationPtr(self.nodemap.GetNode('LineMode'))
if not PySpin.IsWritable(node_lineMode):
setCase = False
node_lineMode.SetIntValue(1)
self.currentState = enviromentPwr(2)
setCase = True
return self.bfsGpio_statusLine()
except PySpin.SpinnakerException as ex:
print('Error: %s' % ex)
return False
Would some one be able to help me out with this issue ???
Comments
2 comments