diff --git a/py25/bacpypes/__init__.py b/py25/bacpypes/__init__.py index 8e201b5..dbb4564 100755 --- a/py25/bacpypes/__init__.py +++ b/py25/bacpypes/__init__.py @@ -18,7 +18,7 @@ if _sys.platform not in _supported_platforms: # Project Metadata # -__version__ = '0.17.2' +__version__ = '0.17.3' __author__ = 'Joel Bender' __email__ = 'joel@carrickbender.com' diff --git a/py25/bacpypes/appservice.py b/py25/bacpypes/appservice.py index b30a7e8..b411c02 100755 --- a/py25/bacpypes/appservice.py +++ b/py25/bacpypes/appservice.py @@ -1525,7 +1525,7 @@ class ApplicationServiceAccessPoint(ApplicationServiceElement, ServiceAccessPoin xpdu = atype() xpdu.decode(apdu) except Exception, err: - ApplicationServiceAccessPoint._exception("unconfirmed request decoding error: %r", err) + ApplicationServiceAccessPoint._exception("complex ack decoding error: %r", err) return elif isinstance(apdu, ErrorPDU): diff --git a/py25/bacpypes/iocb.py b/py25/bacpypes/iocb.py index 6906d3c..fadee88 100644 --- a/py25/bacpypes/iocb.py +++ b/py25/bacpypes/iocb.py @@ -140,12 +140,12 @@ class IOCB(DebugContents): if self.ioComplete.isSet(): self.trigger() - def wait(self, *args): + def wait(self, *args, **kwargs): """Wait for the completion event to be set.""" - if _debug: IOCB._debug("wait(%d) %r", self.ioID, args) + if _debug: IOCB._debug("wait(%d) %r %r", self.ioID, args, kwargs) # waiting from a non-daemon thread could be trouble - self.ioComplete.wait(*args) + return self.ioComplete.wait(*args, **kwargs) def trigger(self): """Set the completion event and make the callback(s).""" diff --git a/py25/bacpypes/netservice.py b/py25/bacpypes/netservice.py index 9cbf531..97278ff 100755 --- a/py25/bacpypes/netservice.py +++ b/py25/bacpypes/netservice.py @@ -776,7 +776,7 @@ class NetworkServiceElement(ApplicationServiceElement): self.response(adapter, iamrtn) else: - if _debug: NetworkServiceElement._debug(" - forwarding request to other adapters") + if _debug: NetworkServiceElement._debug(" - forwarding to other adapters") # build a request whoisrtn = WhoIsRouterToNetwork(dnet, user_data=npdu.pduUserData) @@ -806,19 +806,21 @@ class NetworkServiceElement(ApplicationServiceElement): sap.add_router_references(adapter.adapterNet, npdu.pduSource, npdu.iartnNetworkList) # skip if this is not a router - if len(sap.adapters) > 1: + if len(sap.adapters) == 1: + if _debug: NetworkServiceElement._debug(" - not a router") + + else: + if _debug: NetworkServiceElement._debug(" - forwarding to other adapters") + # build a broadcast annoucement iamrtn = IAmRouterToNetwork(npdu.iartnNetworkList, user_data=npdu.pduUserData) iamrtn.pduDestination = LocalBroadcast() # send it to all of the connected adapters for xadapter in sap.adapters.values(): - # skip the horse it rode in on - if (xadapter is adapter): - continue - - # request this - self.request(xadapter, iamrtn) + if xadapter is not adapter: + if _debug: NetworkServiceElement._debug(" - sending on adapter: %r", xadapter) + self.request(xadapter, iamrtn) # look for pending NPDUs for the networks for dnet in npdu.iartnNetworkList: diff --git a/py27/bacpypes/__init__.py b/py27/bacpypes/__init__.py index 8e201b5..dbb4564 100755 --- a/py27/bacpypes/__init__.py +++ b/py27/bacpypes/__init__.py @@ -18,7 +18,7 @@ if _sys.platform not in _supported_platforms: # Project Metadata # -__version__ = '0.17.2' +__version__ = '0.17.3' __author__ = 'Joel Bender' __email__ = 'joel@carrickbender.com' diff --git a/py27/bacpypes/appservice.py b/py27/bacpypes/appservice.py index 641e655..7adace6 100755 --- a/py27/bacpypes/appservice.py +++ b/py27/bacpypes/appservice.py @@ -1522,7 +1522,7 @@ class ApplicationServiceAccessPoint(ApplicationServiceElement, ServiceAccessPoin xpdu = atype() xpdu.decode(apdu) except Exception as err: - ApplicationServiceAccessPoint._exception("unconfirmed request decoding error: %r", err) + ApplicationServiceAccessPoint._exception("complex ack decoding error: %r", err) return elif isinstance(apdu, ErrorPDU): diff --git a/py27/bacpypes/iocb.py b/py27/bacpypes/iocb.py index db96cba..730d383 100644 --- a/py27/bacpypes/iocb.py +++ b/py27/bacpypes/iocb.py @@ -141,12 +141,12 @@ class IOCB(DebugContents): if self.ioComplete.isSet(): self.trigger() - def wait(self, *args): + def wait(self, *args, **kwargs): """Wait for the completion event to be set.""" - if _debug: IOCB._debug("wait(%d) %r", self.ioID, args) + if _debug: IOCB._debug("wait(%d) %r %r", self.ioID, args, kwargs) # waiting from a non-daemon thread could be trouble - self.ioComplete.wait(*args) + return self.ioComplete.wait(*args, **kwargs) def trigger(self): """Set the completion event and make the callback(s).""" diff --git a/py27/bacpypes/netservice.py b/py27/bacpypes/netservice.py index 835bbf0..64c5bfb 100755 --- a/py27/bacpypes/netservice.py +++ b/py27/bacpypes/netservice.py @@ -762,6 +762,9 @@ class NetworkServiceElement(ApplicationServiceElement): if router_net not in sap.adapters: if _debug: NetworkServiceElement._debug(" - path error (6)") return + if sap.adapters[router_net] is adapter: + if _debug: NetworkServiceElement._debug(" - same network") + return # build a response iamrtn = IAmRouterToNetwork([dnet], user_data=npdu.pduUserData) @@ -771,7 +774,7 @@ class NetworkServiceElement(ApplicationServiceElement): self.response(adapter, iamrtn) else: - if _debug: NetworkServiceElement._debug(" - forwarding request to other adapters") + if _debug: NetworkServiceElement._debug(" - forwarding to other adapters") # build a request whoisrtn = WhoIsRouterToNetwork(dnet, user_data=npdu.pduUserData) @@ -801,19 +804,21 @@ class NetworkServiceElement(ApplicationServiceElement): sap.add_router_references(adapter.adapterNet, npdu.pduSource, npdu.iartnNetworkList) # skip if this is not a router - if len(sap.adapters) > 1: + if len(sap.adapters) == 1: + if _debug: NetworkServiceElement._debug(" - not a router") + + else: + if _debug: NetworkServiceElement._debug(" - forwarding to other adapters") + # build a broadcast annoucement iamrtn = IAmRouterToNetwork(npdu.iartnNetworkList, user_data=npdu.pduUserData) iamrtn.pduDestination = LocalBroadcast() # send it to all of the connected adapters for xadapter in sap.adapters.values(): - # skip the horse it rode in on - if (xadapter is adapter): - continue - - # request this - self.request(xadapter, iamrtn) + if xadapter is not adapter: + if _debug: NetworkServiceElement._debug(" - sending on adapter: %r", xadapter) + self.request(xadapter, iamrtn) # look for pending NPDUs for the networks for dnet in npdu.iartnNetworkList: diff --git a/py34/bacpypes/__init__.py b/py34/bacpypes/__init__.py index f556be2..bddb134 100755 --- a/py34/bacpypes/__init__.py +++ b/py34/bacpypes/__init__.py @@ -18,7 +18,7 @@ if _sys.platform not in _supported_platforms: # Project Metadata # -__version__ = '0.17.2' +__version__ = '0.17.3' __author__ = 'Joel Bender' __email__ = 'joel@carrickbender.com' diff --git a/py34/bacpypes/appservice.py b/py34/bacpypes/appservice.py index 43316f1..75591f7 100755 --- a/py34/bacpypes/appservice.py +++ b/py34/bacpypes/appservice.py @@ -1522,7 +1522,7 @@ class ApplicationServiceAccessPoint(ApplicationServiceElement, ServiceAccessPoin xpdu = atype() xpdu.decode(apdu) except Exception as err: - ApplicationServiceAccessPoint._exception("unconfirmed request decoding error: %r", err) + ApplicationServiceAccessPoint._exception("complex ack decoding error: %r", err) return elif isinstance(apdu, ErrorPDU): diff --git a/py34/bacpypes/iocb.py b/py34/bacpypes/iocb.py index db96cba..730d383 100644 --- a/py34/bacpypes/iocb.py +++ b/py34/bacpypes/iocb.py @@ -141,12 +141,12 @@ class IOCB(DebugContents): if self.ioComplete.isSet(): self.trigger() - def wait(self, *args): + def wait(self, *args, **kwargs): """Wait for the completion event to be set.""" - if _debug: IOCB._debug("wait(%d) %r", self.ioID, args) + if _debug: IOCB._debug("wait(%d) %r %r", self.ioID, args, kwargs) # waiting from a non-daemon thread could be trouble - self.ioComplete.wait(*args) + return self.ioComplete.wait(*args, **kwargs) def trigger(self): """Set the completion event and make the callback(s).""" diff --git a/py34/bacpypes/netservice.py b/py34/bacpypes/netservice.py index 835bbf0..64c5bfb 100755 --- a/py34/bacpypes/netservice.py +++ b/py34/bacpypes/netservice.py @@ -762,6 +762,9 @@ class NetworkServiceElement(ApplicationServiceElement): if router_net not in sap.adapters: if _debug: NetworkServiceElement._debug(" - path error (6)") return + if sap.adapters[router_net] is adapter: + if _debug: NetworkServiceElement._debug(" - same network") + return # build a response iamrtn = IAmRouterToNetwork([dnet], user_data=npdu.pduUserData) @@ -771,7 +774,7 @@ class NetworkServiceElement(ApplicationServiceElement): self.response(adapter, iamrtn) else: - if _debug: NetworkServiceElement._debug(" - forwarding request to other adapters") + if _debug: NetworkServiceElement._debug(" - forwarding to other adapters") # build a request whoisrtn = WhoIsRouterToNetwork(dnet, user_data=npdu.pduUserData) @@ -801,19 +804,21 @@ class NetworkServiceElement(ApplicationServiceElement): sap.add_router_references(adapter.adapterNet, npdu.pduSource, npdu.iartnNetworkList) # skip if this is not a router - if len(sap.adapters) > 1: + if len(sap.adapters) == 1: + if _debug: NetworkServiceElement._debug(" - not a router") + + else: + if _debug: NetworkServiceElement._debug(" - forwarding to other adapters") + # build a broadcast annoucement iamrtn = IAmRouterToNetwork(npdu.iartnNetworkList, user_data=npdu.pduUserData) iamrtn.pduDestination = LocalBroadcast() # send it to all of the connected adapters for xadapter in sap.adapters.values(): - # skip the horse it rode in on - if (xadapter is adapter): - continue - - # request this - self.request(xadapter, iamrtn) + if xadapter is not adapter: + if _debug: NetworkServiceElement._debug(" - sending on adapter: %r", xadapter) + self.request(xadapter, iamrtn) # look for pending NPDUs for the networks for dnet in npdu.iartnNetworkList: diff --git a/samples/WhoIsRouter.py b/samples/WhoIsRouter.py index 66f8a47..9bd482d 100755 --- a/samples/WhoIsRouter.py +++ b/samples/WhoIsRouter.py @@ -12,7 +12,7 @@ from bacpypes.consolecmd import ConsoleCmd from bacpypes.core import run, enable_sleeping from bacpypes.pdu import Address -from bacpypes.npdu import InitializeRoutingTable, WhoIsRouterToNetwork +from bacpypes.npdu import InitializeRoutingTable, WhoIsRouterToNetwork, IAmRouterToNetwork from bacpypes.app import BIPNetworkApplication @@ -41,6 +41,10 @@ class WhoIsRouterApplication(BIPNetworkApplication): def indication(self, adapter, npdu): if _debug: WhoIsRouterApplication._debug("indication %r %r", adapter, npdu) + + if isinstance(npdu, IAmRouterToNetwork): + print("{} -> {}, {}".format(npdu.pduSource, npdu.pduDestination, npdu.iartnNetworkList)) + BIPNetworkApplication.indication(self, adapter, npdu) def response(self, adapter, npdu):