From 0c94fff3300d2c1c1c98367d99e1457f073a1892 Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Thu, 14 Dec 2017 14:53:45 -0800 Subject: mpm: rpc_server: Unregister old RPC calls _init_rpc_calls() On FPGA loads, when the periph_manager is respawned, this will now clear the previously registered methods. Reviewed-By: Brent Stapleton --- mpm/python/usrp_mpm/rpc_server.py | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'mpm') diff --git a/mpm/python/usrp_mpm/rpc_server.py b/mpm/python/usrp_mpm/rpc_server.py index 51ba9272b..c3b4fc2dd 100644 --- a/mpm/python/usrp_mpm/rpc_server.py +++ b/mpm/python/usrp_mpm/rpc_server.py @@ -68,12 +68,32 @@ class MPMServer(RPCServer): def _init_rpc_calls(self, mgr): """ - Register all RPC calls for the motherboard and daughterboards - """ + Register all RPC calls for the motherboard and daughterboards. + + First clears out all previously registered RPC calls. + """ + # Clear old calls: + for meth_list in (self._db_methods, self._mb_methods): + for method in meth_list: + if hasattr(self, method): + delattr(self, method) + else: + self.log.warning( + "Attempted to remove non-existant method: %s", + method + ) + self._db_methods = [] + self._mb_methods = [] + # Register new ones: self._update_component_commands(mgr, '', '_mb_methods') for db_slot, dboard in enumerate(mgr.dboards): cmd_prefix = 'db_' + str(db_slot) + '_' self._update_component_commands(dboard, cmd_prefix, '_db_methods') + self.log.debug( + "Registered %d motherboard methods, %d daughterboard methods.", + len(self._mb_methods), + len(self._db_methods), + ) def _check_token_valid(self, token): """ -- cgit v1.2.3