Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ classifiers = [
[tool.poetry.dependencies]
python = ">=3.10,<4.0"
bacpypes3 = ">=0.0.102"
protocol-proxy = ">=2.0.0rc0"
protocol-proxy = ">=2.0.0rc2"

[tool.poetry.group.dev.dependencies]
# No additional dependencies.
Expand Down
26 changes: 17 additions & 9 deletions src/protocol_proxy/protocol/bacnet/bacnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,17 @@ def __init__(self, local_interface, bacnet_port=0, vendor_id=999, object_name='V
objectIdentifier=("network-port", bacnet_port),
objectName="NetworkPort-1", networkNumber=bacnet_port,
networkNumberQuality="configured")
# TODO: In order to implement better error handling, it may be necessary to sublcass Application.
# BACPypes3 raises an AssertionError, for instance in the Application.confirmation which does not
# seem to be possible to catch without overriding the method.
# It should be possilble to make this class a subclass of Application,
# instead of having Application as an attribute.
self.app = Application.from_object_list(
[device_object, network_port_object],
device_info_cache=device_info_cache, # TODO: If these should be passed in, add to args & launch.
router_info_cache=router_info_cache,
aseID=ase_id
)
#_log.debug(f'WE HAVE AN APP: {self.app.device_info_cache}')

async def query_device(self, address: str, property_name: str = 'object-identifier'):
"""Returns properties about the device at the given address.
Expand Down Expand Up @@ -186,15 +190,19 @@ async def confirmed_private_transfer(self, address: Address, vendor_id: int, ser
serviceNumber=service_number)
if service_parameters:
cpt_request.serviceParameters = service_parameters
response = await self.app.request(cpt_request)
if isinstance(response, ConfirmedPrivateTransferError):
_log.warning(f'Error calling Confirmed Private Transfer Service: {response}')
return None
elif isinstance(response, ConfirmedPrivateTransferACK):
return response
try:
response = await self.app.request(cpt_request)
except Exception as e:
_log.warning(f'Exception sending Confirmed Private Transfer Request: {e}')
else:
_log.warning(f'Some other Error: {response}') # TODO: Improve error handling.
return None
if isinstance(response, ConfirmedPrivateTransferError):
_log.warning(f'Error calling Confirmed Private Transfer Service: {response}')
return None
elif isinstance(response, ConfirmedPrivateTransferACK):
return response
else:
_log.warning(f'Some other Error: {response}') # TODO: Improve error handling.
return None

async def scan_subnet(self,
network_str: str,
Expand Down
Loading