Example #1
0
 def __init__(self, state, default_args):
     self.log = get_main_logger().getChild('RPCServer')
     self.log.trace("Launching RPC server with compat num %d.%d",
                    MPM_COMPAT_NUM[0], MPM_COMPAT_NUM[1])
     self._state = state
     self._timer = Greenlet()
     # Setting this to True will disable an unclaim on timeout. Use with
     # care, and make sure to set it to False again when finished.
     self._disable_timeouts = False
     self._timeout_interval = float(
         default_args.get("rpc_timeout_interval", TIMEOUT_INTERVAL))
     self.session_id = None
     # Create the periph_manager for this device
     # This call will be forwarded to the device specific implementation
     # e.g. in periph_manager/n3xx.py
     # Which implementation is called will be determined during
     # configuration with cmake (-DMPM_DEVICE).
     # mgr is thus derived from PeriphManagerBase
     # (see periph_manager/base.py)
     from usrp_mpm.periph_manager import periph_manager
     self._mgr_generator = lambda: periph_manager(default_args)
     self.periph_manager = self._mgr_generator()
     device_info = self.periph_manager.get_device_info()
     self._state.dev_type.value = \
             to_binary_str(device_info.get("type", "n/a"))
     self._state.dev_product.value = \
             to_binary_str(device_info.get("product", "n/a"))
     self._state.dev_serial.value = \
             to_binary_str(device_info.get("serial", "n/a"))
     self._state.dev_fpga_type.value = \
             to_binary_str(device_info.get("fpga", "n/a"))
     self._db_methods = []
     self._mb_methods = []
     self.claimed_methods = copy.copy(self.default_claimed_methods)
     self._last_error = ""
     self._init_rpc_calls(self.periph_manager)
     # We call the server __init__ function here, and not earlier, because
     # first the commands need to be registered
     super(MPMServer, self).__init__(
         pack_params={'use_bin_type': True},
         unpack_params={
             'max_buffer_size': 50000000,
             'raw': False
         },
     )
     self._state.system_ready.value = True
     self.log.info("RPC server ready!")
     # Optionally spawn watchdog. Note: In order for us to be able to spawn
     # the task from this thread, the main process needs to hand control to
     # us using watchdog.transfer_control().
     if watchdog.has_watchdog():
         self.log.info("Spawning watchdog task...")
         watchdog.spawn_watchdog_task(self._state, self.log)
Example #2
0
 def __init__(self, state, default_args):
     self.log = get_main_logger().getChild('RPCServer')
     self.log.trace("Launching RPC server with compat num %d.%d",
                    MPM_COMPAT_NUM[0], MPM_COMPAT_NUM[1])
     self._state = state
     self._timer = Greenlet()
     # Setting this to True will disable an unclaim on timeout. Use with
     # care, and make sure to set it to False again when finished.
     self._disable_timeouts = False
     self._timeout_interval = float(default_args.get(
         "rpc_timeout_interval",
         TIMEOUT_INTERVAL
     ))
     self.session_id = None
     # Create the periph_manager for this device
     # This call will be forwarded to the device specific implementation
     # e.g. in periph_manager/n3xx.py
     # Which implementation is called will be determined during
     # configuration with cmake (-DMPM_DEVICE).
     # mgr is thus derived from PeriphManagerBase
     # (see periph_manager/base.py)
     from usrp_mpm.periph_manager import periph_manager
     self._mgr_generator = lambda: periph_manager(default_args)
     self.periph_manager = self._mgr_generator()
     device_info = self.periph_manager.get_device_info()
     self._state.dev_type.value = \
             to_binary_str(device_info.get("type", "n/a"))
     self._state.dev_product.value = \
             to_binary_str(device_info.get("product", "n/a"))
     self._state.dev_serial.value = \
             to_binary_str(device_info.get("serial", "n/a"))
     self._db_methods = []
     self._mb_methods = []
     self.claimed_methods = copy.copy(self.default_claimed_methods)
     self._last_error = ""
     self._init_rpc_calls(self.periph_manager)
     # We call the server __init__ function here, and not earlier, because
     # first the commands need to be registered
     super(MPMServer, self).__init__(
         pack_params={'use_bin_type': True},
     )
     self._state.system_ready.value = True
     self.log.info("RPC server ready!")
     # Optionally spawn watchdog. Note: In order for us to be able to spawn
     # the task from this thread, the main process needs to hand control to
     # us using watchdog.transfer_control().
     if watchdog.has_watchdog():
         self.log.info("Spawning watchdog task...")
         watchdog.spawn_watchdog_task(self._state, self.log)
Example #3
0
 def __init__(self, state, default_args):
     self.log = get_main_logger().getChild('RPCServer')
     self._state = state
     self._timer = Greenlet()
     self.session_id = None
     # Create the periph_manager for this device
     # This call will be forwarded to the device specific implementation
     # e.g. in periph_manager/n310.py
     # Which implementation is called will be determined during
     # configuration with cmake (-DMPM_DEVICE).
     # mgr is thus derived from PeriphManagerBase
     # (see periph_manager/base.py)
     from usrp_mpm.periph_manager import periph_manager
     self._mgr_generator = lambda: periph_manager(default_args)
     self.periph_manager = self._mgr_generator()
     device_info = self.periph_manager.get_device_info()
     self._state.dev_type.value = \
             to_binary_str(device_info.get("type", "n/a"))
     self._state.dev_product.value = \
             to_binary_str(device_info.get("product", "n/a"))
     self._state.dev_serial.value = \
             to_binary_str(device_info.get("serial", "n/a"))
     self._db_methods = []
     self._mb_methods = []
     self.claimed_methods = copy.copy(self.default_claimed_methods)
     self._last_error = ""
     self._init_rpc_calls(self.periph_manager)
     # We call the server __init__ function here, and not earlier, because
     # first the commands need to be registered
     super(MPMServer, self).__init__(
         pack_params={'use_bin_type': True},
     )
     self._state.system_ready.value = True
     self.log.info("RPC server ready!")
     # Optionally spawn watchdog. Note: In order for us to be able to spawn
     # the task from this thread, the main process needs to hand control to
     # us using watchdog.transfer_control().
     if watchdog.has_watchdog():
         self.log.info("Spawning watchdog task...")
         watchdog.spawn_watchdog_task(self._state, self.log)