Adding reconnect method to XHALDevice class, which will load all required modules. In case the interface is still connected, reconnection attempt will fail and corresponding exception raised.
Adding disconnect method which clears RPC connection
Providing python bindings for the following exception classes :
XHALException
XHALXMLParserException
XHALRPCException
XHALRPCNotConnectedException
Example code:
import xhalpy as xi
print "TEST OF XHAL RPC EXCEPTIONS HANDLING"
eagle64=xi.XHALDevice("eagle64","/opt/cmsgemos/etc/maps/amc_address_table_top.xml")
print "read reg by name: eagle64.readReg(GEM_AMC.GEM_SYSTEM.BOARD_ID)=%08x"%(eagle64.readReg("GEM_AMC.GEM_SYSTEM.BOARD_ID"))
print "Now disconnect"
eagle64.disconnect()
print "RPC service disconnected. Now try to read register by name again"
try:
print "read reg by name: eagle64.readReg(GEM_AMC.GEM_SYSTEM.BOARD_ID)=%08x"%(eagle64.readReg("GEM_AMC.GEM_SYSTEM.BOARD_ID"))
except xi.XHALRPCNotConnectedException as e:
print "Caught exception: %s" %(e)
print "Now reconnect"
eagle64.reconnect()
print "RPC service reconnected. Now try to read register by name again"
try:
print "read reg by name: eagle64.readReg(GEM_AMC.GEM_SYSTEM.BOARD_ID)=%08x"%(eagle64.readReg("GEM_AMC.GEM_SYSTEM.BOARD_ID"))
except xi.XHALRPCNotConnectedException as e:
print "Caught exception: %s" %(e)
print "Test reconnection attempt on connected service"
try:
eagle64.reconnect()
except xi.XHALRPCException as e:
print "Caught exception: %s" %(e)
Expected output:
1 [140054805878592] INFO XHALInterface_eagle64_0 <> - XHAL Logger tuned up
5 [140054805878592] INFO XHALInterface_eagle64_0 <> - RPC connected
5 [140054805878592] INFO XHALInterface_eagle64_0 <> - XHAL Interface connected
10 [140054805878592] INFO XHALXMLParser_0 <> - Successfully initialized XML4C system
read reg by name: eagle64.readReg(GEM_AMC.GEM_SYSTEM.BOARD_ID)=0000beef
Now disconnect
2133 [140054805878592] INFO XHALInterface_eagle64_0 <> - RPC disconnected
RPC service disconnected. Now try to read register by name again
2133 [140054805878592] ERROR XHALInterface_eagle64_0 <> - Caught NotConnectedException: Not connected to rpc service
Caught exception: RPC NotConnectedException: Not connected to rpc service
Now reconnect
2137 [140054805878592] INFO XHALInterface_eagle64_0 <> - RPC connected
RPC service reconnected. Now try to read register by name again
read reg by name: eagle64.readReg(GEM_AMC.GEM_SYSTEM.BOARD_ID)=0000beef
Test reconnection attempt on connected service
2476 [140054805878592] ERROR XHALInterface_eagle64_0 <> - Interface already connected. Reconnection failed
Caught exception: RPC exception: Interface already connected. Reconnection failed
2476 [140054805878592] INFO XHALInterface_eagle64_0 <> - RPC disconnected
Types of changes
[x] Bug fix (non-breaking change which fixes an issue)
[x] New feature (non-breaking change which adds functionality)
[ ] Breaking change (fix or feature that would cause existing functionality to change)
How Has This Been Tested?
Tested with (updated) testing script
Screenshots (if appropriate):
Checklist:
[x] My code follows the code style of this project.
[x] My change requires a change to the documentation.
reconnect
methoddisconnect
methodDescription
reconnect
method toXHALDevice
class, which will load all required modules. In case the interface is still connected, reconnection attempt will fail and corresponding exception raised.disconnect
method which clears RPC connectionExample code:
Expected output:
Types of changes
How Has This Been Tested?
Tested with (updated) testing script
Screenshots (if appropriate):
Checklist: