From 27f2aa86ac2458e8dfaca5b50aeb31d7dd710257 Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Tue, 19 Dec 2017 16:24:06 -0800 Subject: n310: Move SID framing all the way to n310.py MPM will now no longer keep a SID framer variable. Reviewed-by: Trung Tran Reviewed-by: Brent Stapleton --- mpm/python/usrp_mpm/periph_manager/n310.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'mpm/python/usrp_mpm/periph_manager/n310.py') diff --git a/mpm/python/usrp_mpm/periph_manager/n310.py b/mpm/python/usrp_mpm/periph_manager/n310.py index 135f5e290..4a7997d75 100644 --- a/mpm/python/usrp_mpm/periph_manager/n310.py +++ b/mpm/python/usrp_mpm/periph_manager/n310.py @@ -297,6 +297,7 @@ class n310(PeriphManagerBase): self._ext_clock_freq = None self._clock_source = None self._time_source = None + self._available_endpoints = list(range(256)) try: self._init_peripherals(args) self._device_initialized = True @@ -417,6 +418,7 @@ class n310(PeriphManagerBase): super(n310, self).deinit() for xport_mgr in itervalues(self._xport_mgrs): xport_mgr.deinit() + self._available_endpoints = list(range(256)) def tear_down(self): """ @@ -443,14 +445,19 @@ class n310(PeriphManagerBase): """ See PeriphManagerBase.request_xport() for docs. """ - # For now, we always accept the suggestion if available, or fail + # Try suggested address first, then just pick the first available one: src_address = suggested_src_address if src_address not in self._available_endpoints: - raise RuntimeError("no more sids yo") + if len(self._available_endpoints) == 0: + raise RuntimeError( + "Depleted pool of SID endpoints for this device!") + else: + src_address = self._available_endpoints[0] sid = SID(src_address << 16 | dst_address) + # Note: This SID may change its source address! self.log.debug( "request_xport(dst=0x%04X, suggested_src_address=0x%04X, xport_type=%s): " \ - "operating on SID: %s", + "operating on temporary SID: %s", dst_address, suggested_src_address, str(xport_type), str(sid)) # FIXME token! assert self.mboard_info['rpc_connection'] in ('remote', 'local') -- cgit v1.2.3