JoelBender / BACpypes3

BACnet communications library
33 stars 7 forks source link

read-property.py #4

Closed bbartling closed 1 year ago

bbartling commented 1 year ago

Am trying out the read-proprety.py from the sample running locally on Ubuntu with Pypi installed bacpypes 3 updated to

$ python3.10 read-property.py 12345:2 analog-input,2 present-value --debug
DEBUG:__main__:args: Namespace(loggers=False, debug=[], color=None, route_aware=None, name='Excelsior', instance=999, network=0, address=None, vendoridentifier=999, foreign=None, ttl=30, bbmd=None, device_address='12345:2', object_identifier='analog-input,2', property_identifier='present-value')
DEBUG:__main__:device_address: <RemoteStation 12345:2>
DEBUG:__main__:object_identifier: (<ObjectType: analog-input>, 2)
DEBUG:__main__:app: <bacpypes3.app.Application object at 0x7fa4f6b3da80>
Task exception was never retrieved
future: <Task finished name='Task-4' coro=<ApplicationServiceElement.request() done, defined at /home/ben/.local/lib/python3.10/site-packages/bacpypes3/comm.py:132> exception=RuntimeError('no broadcast')>
Traceback (most recent call last):
  File "/home/ben/.local/lib/python3.10/site-packages/bacpypes3/comm.py", line 135, in request
    await self.elementService.sap_indication(*args)
  File "/home/ben/.local/lib/python3.10/site-packages/bacpypes3/netservice.py", line 1006, in sap_indication
    await adapter.process_npdu(npdu)
  File "/home/ben/.local/lib/python3.10/site-packages/bacpypes3/netservice.py", line 380, in process_npdu
    await self.request(pdu)
  File "/home/ben/.local/lib/python3.10/site-packages/bacpypes3/comm.py", line 59, in request
    await self.clientPeer.indication(pdu)
  File "/home/ben/.local/lib/python3.10/site-packages/bacpypes3/ipv4/service.py", line 300, in indication
    await self.request(lpdu)
  File "/home/ben/.local/lib/python3.10/site-packages/bacpypes3/comm.py", line 59, in request
    await self.clientPeer.indication(pdu)
  File "/home/ben/.local/lib/python3.10/site-packages/bacpypes3/ipv4/bvll.py", line 228, in indication
    await self.request(pdu)
  File "/home/ben/.local/lib/python3.10/site-packages/bacpypes3/comm.py", line 59, in request
    await self.clientPeer.indication(pdu)
  File "/home/ben/.local/lib/python3.10/site-packages/bacpypes3/ipv4/service.py", line 63, in indication
    await self.multiplexer.indication(self, pdu)
  File "/home/ben/.local/lib/python3.10/site-packages/bacpypes3/ipv4/service.py", line 94, in indication
    await self.request(pdu)
  File "/home/ben/.local/lib/python3.10/site-packages/bacpypes3/comm.py", line 59, in request
    await self.clientPeer.indication(pdu)
  File "/home/ben/.local/lib/python3.10/site-packages/bacpypes3/ipv4/__init__.py", line 218, in indication
    raise RuntimeError("no broadcast")
RuntimeError: no broadcast
DEBUG:__main__:    - exception: <bacpypes3.apdu.Error(ErrorPDU,0) instance at 0x7fa4f6bd15a0>
    <bacpypes3.apdu.Error(ErrorPDU,0) instance at 0x7fa4f6bd15a0>
        pduSource = <RemoteStation 12345:2>
        pduExpectingReply = False
        pduNetworkPriority = 0
        apduType = 5
        apduService = 12
        apduInvokeID = 0
        errorClass = <ErrorClass: communication>
        errorCode = <ErrorCode: unknown-route>
        pduData = x''
communication: unknown-route

Also curious to know for my own learning purposes when a read request is sent out is there also broadcast sent out as well? Is that who-is? I notice the no broadcast error.

The device I am working with are old Schneider electric MSTP devices sent out to pasture where in their retirement they are just test bench devices to play with.

Thanks!

JoelBender commented 1 year ago

Yes, it's trying to do a broadcast Who-Is-Router-To-Network and your settings and/or environment don't have enough information to figure out what the local broadcast address should be. There are two ways to solve this:

1) add --address 192.168.0.99/24 to the command line giving it the correct IPv4 address and network size (the number of 1-bits in your subnet mask) 2) install ifaddr with pip install ifaddr and run again, if the module is available then it will be used to scan through your interfaces and try to pick the right one. It's fine most of the time, but if you have some docker networking and VPN tunnels and such it can get confused.

Note that ifaddr is the replacement for netifaces which hasn't found someone to continue development.

bbartling commented 1 year ago

Works great with the pip install ifaddr! I added that to my notes.