Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't read device with new version while it works with 23.7.3 #495

Open
eloigabal opened this issue Nov 7, 2024 · 5 comments
Open

Can't read device with new version while it works with 23.7.3 #495

eloigabal opened this issue Nov 7, 2024 · 5 comments

Comments

@eloigabal
Copy link

We are using the Library to read from a few buildings and it does not work with the new version.

Here are the snippets we are using

import asyncio
import BAC0

async def bac():
    bacnet_dev = {'deviceIp': '10.10.10.15',  'type': 'analogInput', 'objectId': '27'}
    print(BAC0.infos.__version__) # 2024.9.20
    async with BAC0.start('10.187.176.185/16', bbmdAddress='10.187.104.102:47808', bbmdTTL=900) as bacnet:
        # there is a routing to the external IP to the internal one
        try:
            value = await bacnet.read(f"{bacnet_dev['deviceIp']} {bacnet_dev['type']} {bacnet_dev['objectId']} presentValue")
        except Exception as e:
            print(f"can't read {attempt}/5: {e}")
asyncio.run(bac())
OUTPUT:
2024.09.10
2024-11-07 14:59:43,323 - INFO    | Starting Asynchronous BAC0 version 2024.09.10 (Lite)
2024-11-07 14:59:43,323 - INFO    | Using bacpypes3 version 0.0.98
2024-11-07 14:59:43,323 - INFO    | Use BAC0.log_level to adjust verbosity of the app.
2024-11-07 14:59:43,324 - INFO    | Ex. BAC0.log_level('silence') or BAC0.log_level('error')
2024-11-07 14:59:43,326 - INFO    | Using ip : 10.187.176.185/16 on port 47808 | broadcast : 10.187.255.255
2024-11-07 14:59:43,330 - INFO    | Using default JSON configuration file
2024-11-07 14:59:43,341 - INFO    | Registering as a foreign device to host 10.187.104.102:47808 for 900 seconds
2024-11-07 14:59:43,343 - INFO    | Registered as BACnet/IP App | mode foreign
2024-11-07 14:59:43,345 - INFO    | Device instance (id) : 3056980
2024-11-07 14:59:43,345 - INFO    | BAC0|3056980 connected. Entering context manager.
/Users/eloigabal/Developement/CIMNE/bacnet_ingestor/venv/lib/python3.10/site-packages/bacpypes3/vendor.py:111: UserWarning: object type 56 for vendor identifier 842 already registered: <class 'bacpypes3.local.networkport.NetworkPortObject'>
  warnings.warn(
/Users/eloigabal/Developement/CIMNE/bacnet_ingestor/venv/lib/python3.10/site-packages/bacpypes3/vendor.py:111: UserWarning: object type 8 for vendor identifier 842 already registered: <class 'bacpypes3.local.device.DeviceObject'>
  warnings.warn(
2024-11-07 14:59:43,347 - INFO    | Installing recurring task Ping Task (id:4509907648)
2024-11-07 14:59:46,360 - ERROR   | BAC0.scripts.Lite | Lite | BAC0.core.io.Read | Trouble with Iam... Response received from 10.10.10.15 = []
can't read: 
2024-11-07 14:59:46,370 - INFO    | Stopping all tasks
2024-11-07 14:59:46,370 - INFO    | Ok all tasks stopped
2024-11-07 14:59:46,376 - INFO    | BACnet stopped
2024-11-07 14:59:46,376 - INFO    | BAC0|3056980 disconnected. Exiting context manager.
Exception in callback IPv4DatagramServer.set_broadcast_transport_protocol(<IPv4Address 10.187.176.185>)(<Task cancell...nit__.py:150>>)
handle: <Handle IPv4DatagramServer.set_broadcast_transport_protocol(<IPv4Address 10.187.176.185>)(<Task cancell...nit__.py:150>>)>
Traceback (most recent call last):
  File "/Users/eloigabal/Developement/CIMNE/bacnet_ingestor/venv/lib/python3.10/site-packages/bacpypes3/ipv4/__init__.py", line 159, in retrying_create_datagram_endpoint
    return await loop.create_datagram_endpoint(
  File "/usr/local/Cellar/[email protected]/3.10.14_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/base_events.py", line 1385, in create_datagram_endpoint
    raise exceptions[0]
  File "/usr/local/Cellar/[email protected]/3.10.14_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/base_events.py", line 1369, in create_datagram_endpoint
    sock.bind(local_address)
OSError: [Errno 49] Can't assign requested address

while with the old version:

def bac():
    bacnet_dev = {'deviceIp': '10.10.10.15', 'device_uri': 'https://icat.cat#measurement-INE-08363-ixon-bacnet-10.10.10.15-analogInput-27-PT15M', 'type': 'analogInput', 'objectId': '27'}
    print(BAC0.infos.__version__)
    bacnet = BAC0.lite('10.187.176.185/16', bbmdAddress='10.187.104.102:47808', bbmdTTL=900) 
    for attempt in range(5):
        try:
            value = bacnet.read(
                f"{bacnet_dev['deviceIp']} {bacnet_dev['type']} {bacnet_dev['objectId']} presentValue")
            print(value)
            break
        except Exception as e:
            print(f"can't read {attempt}/5")
    bacnet.disconnect()
bac()
OUTPUT
23.07.03
2024-11-07 15:02:56,521 - INFO    | Starting BAC0 version 23.07.03 (Lite)
2024-11-07 15:02:56,522 - INFO    | Use BAC0.log_level to adjust verbosity of the app.
2024-11-07 15:02:56,522 - INFO    | Ex. BAC0.log_level('silence') or BAC0.log_level('error')
2024-11-07 15:02:56,522 - INFO    | Starting TaskManager
2024-11-07 15:02:56,522 - INFO    | Using ip : 10.187.176.185 on port 47808 | broadcast : 10.187.255.255
2024-11-07 15:02:56,543 - INFO    | Starting app...
2024-11-07 15:02:56,543 - INFO    | BAC0 started
2024-11-07 15:02:56,543 - INFO    | Registered as Foreign Device
2024-11-07 15:02:56,544 - INFO    | Device instance (id) : 3056224
2024-11-07 15:02:56,545 - INFO    | Update Local COV Task started (required to support COV)
20.527509689331055
2024-11-07 15:02:56,986 - INFO    | Stopping all tasks
2024-11-07 15:02:57,540 - INFO    | Stopping TaskManager
2024-11-07 15:02:57,553 - INFO    | Ok all tasks stopped
2024-11-07 15:02:57,561 - INFO    | BACnet stopped

Are we doing something wrong?

@ChristianTremblay
Copy link
Owner

I suspect bacpypes doesn't know which route to take to reach the device.

Can you try a discover before the read ?

@eloigabal
Copy link
Author

eloigabal commented Nov 14, 2024

Tank you for the fast response!

I tried the discover and in both versions, the new and the old one. Both versions does not find any devices. however the old can read the values if I explicitly specify the deviceIP.

I also noticed that both libraries trow an exception when I close the connection.

code BAC0-2024.9.20
import asyncio
import BAC0

async def bac():
    bacnet_dev = {'deviceIp': '10.10.10.15', 'device_uri': '***', 'type': 'analogInput', 'objectId': '27'}
    print(BAC0.infos.__version__)
    async with BAC0.start('10.187.24.210/16', bbmdAddress='10.187.104.102:47808', bbmdTTL=900) as bacnet:
        await bacnet._discover()
        print(await bacnet.devices)
        try:
            value = await bacnet.read(
            f"{bacnet_dev['deviceIp']} {bacnet_dev['type']} {bacnet_dev['objectId']} presentValue")
        except Exception:
            print("ERROR: CANT READ DEVICE")
asyncio.run(bac())
output
2024.09.10
2024-11-14 10:46:31,208 - INFO    | Starting Asynchronous BAC0 version 2024.09.10 (Lite)
2024-11-14 10:46:31,209 - INFO    | Using bacpypes3 version 0.0.98
2024-11-14 10:46:31,209 - INFO    | Use BAC0.log_level to adjust verbosity of the app.
2024-11-14 10:46:31,209 - INFO    | Ex. BAC0.log_level('silence') or BAC0.log_level('error')
2024-11-14 10:46:31,236 - INFO    | Using ip : 10.187.24.210/16 on port 47808 | broadcast : 10.187.255.255
2024-11-14 10:46:31,252 - INFO    | Using default JSON configuration file
2024-11-14 10:46:31,261 - INFO    | Registering as a foreign device to host 10.187.104.102:47808 for 900 seconds
2024-11-14 10:46:31,262 - INFO    | Registered as BACnet/IP App | mode foreign
2024-11-14 10:46:31,264 - INFO    | Device instance (id) : 3056649
2024-11-14 10:46:31,264 - INFO    | BAC0|3056649 connected. Entering context manager.
2024-11-14 10:46:31,264 - INFO    | Installing recurring task Ping Task (id:4485000896)
2024-11-14 10:46:34,274 - WARNING | BAC0.scripts.Lite | Lite | BAC0.core.functions.Alias | Request timed out for what_is_network_number, no response
2024-11-14 10:46:38,277 - INFO    | Found those networks : set()
2024-11-14 10:46:38,278 - INFO    | No BACnet network found, attempting a simple whois using provided device instances limits (0 - 4194303)
2024-11-14 10:46:38,278 - INFO    | Issuing a local broadcast whois request.
2024-11-14 10:46:41,280 - INFO    | Discovery done. Found 0 devices on 0 BACnet networks.
None
2024-11-14 10:46:44,298 - ERROR   | BAC0.scripts.Lite | Lite | BAC0.core.io.Read | Trouble with Iam... Response received from 10.10.10.15 = []
ERROR: CANT READ DEVICE
2024-11-14 10:46:44,308 - INFO    | Stopping all tasks
2024-11-14 10:46:44,308 - INFO    | Ok all tasks stopped
2024-11-14 10:46:44,313 - INFO    | BACnet stopped
2024-11-14 10:46:44,313 - INFO    | BAC0|3056649 disconnected. Exiting context manager.
Exception in callback IPv4DatagramServer.set_broadcast_transport_protocol(<IPv4Address 10.187.24.210>)(<Task cancell...nit__.py:150>>)
handle: <Handle IPv4DatagramServer.set_broadcast_transport_protocol(<IPv4Address 10.187.24.210>)(<Task cancell...nit__.py:150>>)>
Traceback (most recent call last):
  File "/Users/eloigabal/Developement/CIMNE/Infraestructures/bacnet_ingestor/venv/lib/python3.10/site-packages/bacpypes3/ipv4/__init__.py", line 159, in retrying_create_datagram_endpoint
    return await loop.create_datagram_endpoint(
  File "/usr/local/Cellar/[email protected]/3.10.14_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/base_events.py", line 1385, in create_datagram_endpoint
    raise exceptions[0]
  File "/usr/local/Cellar/[email protected]/3.10.14_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/base_events.py", line 1369, in create_datagram_endpoint
    sock.bind(local_address)
OSError: [Errno 49] Can't assign requested address
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/Users/eloigabal/Developement/CIMNE/Infraestructures/bacnet_ingestor/venv/lib/python3.10/site-packages/bacpypes3/ipv4/__init__.py", line 167, in retrying_create_datagram_endpoint
    await asyncio.sleep(BACPYPES_ENDPOINT_RETRY_INTERVAL)
  File "/usr/local/Cellar/[email protected]/3.10.14_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/tasks.py", line 605, in sleep
    return await future
asyncio.exceptions.CancelledError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/local/Cellar/[email protected]/3.10.14_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "/Users/eloigabal/Developement/CIMNE/Infraestructures/bacnet_ingestor/venv/lib/python3.10/site-packages/bacpypes3/ipv4/__init__.py", line 207, in set_broadcast_transport_protocol
    transport, protocol = task.result()
asyncio.exceptions.CancelledError
Code BACO-23.7.3
import BAC0

def bac():
    bacnet_dev = {'deviceIp': '10.10.10.15', 'device_uri': '***', 'type': 'analogInput', 'objectId': '27'}
    print(BAC0.infos.__version__)
    bacnet = BAC0.lite('10.187.24.210/16', bbmdAddress='10.187.104.102:47808', bbmdTTL=900) 
    bacnet.discover()
    print(bacnet.devices)    
    try:
        value = bacnet.read(
            f"{bacnet_dev['deviceIp']} {bacnet_dev['type']} {bacnet_dev['objectId']} presentValue")
        print(value)        
    except Exception as e:
            print("ERROR: CANT READ DEVICE")
    bacnet.disconnect()
bac()
Output
23.07.03
2024-11-14 10:50:03,268 - INFO    | Starting BAC0 version 23.07.03 (Lite)
2024-11-14 10:50:03,268 - INFO    | Use BAC0.log_level to adjust verbosity of the app.
2024-11-14 10:50:03,268 - INFO    | Ex. BAC0.log_level('silence') or BAC0.log_level('error')
2024-11-14 10:50:03,268 - INFO    | Starting TaskManager
2024-11-14 10:50:03,269 - INFO    | Using ip : 10.187.24.210 on port 47808 | broadcast : 10.187.255.255
2024-11-14 10:50:03,282 - INFO    | Starting app...
2024-11-14 10:50:03,282 - INFO    | BAC0 started
2024-11-14 10:50:03,282 - INFO    | Registered as Foreign Device
2024-11-14 10:50:03,282 - INFO    | Device instance (id) : 3056614
2024-11-14 10:50:03,284 - INFO    | Update Local COV Task started (required to support COV)
2024-11-14 10:50:07,295 - INFO    | Found those networks : set()
2024-11-14 10:50:07,295 - INFO    | No BACnet network found, attempting a simple whois using provided device instances limits (0 - 4194303)
[]
18.717199325561523
2024-11-14 10:50:07,614 - INFO    | Stopping all tasks
2024-11-14 10:50:07,621 - INFO    | Stopping TaskManager
2024-11-14 10:50:07,626 - INFO    | Ok all tasks stopped
2024-11-14 10:50:07,628 - INFO    | BACnet stopped
an error has occurred: [Errno 9] Bad file descriptor
Traceback (most recent call last):
  File "/Users/eloigabal/Developement/CIMNE/Infraestructures/bacnet_ingestor/venv/lib/python3.10/site-packages/bacpypes/core.py", line 154, in run
    asyncore.loop(timeout=delta, count=1)
  File "/usr/local/Cellar/[email protected]/3.10.14_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncore.py", line 214, in loop
    poll_fun(timeout, map)
  File "/usr/local/Cellar/[email protected]/3.10.14_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncore.py", line 151, in poll
    r, w, e = select.select(r, w, e, timeout)
OSError: [Errno 9] Bad file descriptor

@rob2791
Copy link

rob2791 commented Nov 15, 2024

Following, I'm having a similar problem (to my knowledge).

@eloigabal
Copy link
Author

I have discovered that using the old version we can get the discover after running a whois. Buit this still does not work with the new version:

BAC0-2024.9.20
import asyncio
import BAC0

async def bac():
    bacnet_dev = {'deviceIp': '10.10.10.15', 'device_uri': 'https://icat.cat#measurement-INE-08363-ixon-bacnet-10.10.10.15-analogInput-27-PT15M', 'type': 'analogInput', 'objectId': '27'}
    print(BAC0.infos.__version__)
    async with BAC0.start('10.187.200.223/16', bbmdAddress='10.187.104.102:47808', bbmdTTL=900) as bacnet:
        await bacnet.who_is()
        await bacnet._discover()
        print(await bacnet.devices)
asyncio.run(bac())
Output
2024.09.10
2024-11-18 12:25:12,445 - INFO    | Starting Asynchronous BAC0 version 2024.09.10 (Lite)
2024-11-18 12:25:12,445 - INFO    | Using bacpypes3 version 0.0.98
2024-11-18 12:25:12,445 - INFO    | Use BAC0.log_level to adjust verbosity of the app.
2024-11-18 12:25:12,445 - INFO    | Ex. BAC0.log_level('silence') or BAC0.log_level('error')
2024-11-18 12:25:12,453 - INFO    | Using ip : 10.187.200.223/16 on port 47808 | broadcast : 10.187.255.255
/Users/eloigabal/Developement/CIMNE/Infraestructures/bacnet_ingestor/venv/lib/python3.10/site-packages/bacpypes3/vendor.py:111: UserWarning: object type 56 for vendor identifier 842 already registered: <class 'bacpypes3.local.networkport.NetworkPortObject'>
  warnings.warn(
/Users/eloigabal/Developement/CIMNE/Infraestructures/bacnet_ingestor/venv/lib/python3.10/site-packages/bacpypes3/vendor.py:111: UserWarning: object type 8 for vendor identifier 842 already registered: <class 'bacpypes3.local.device.DeviceObject'>
  warnings.warn(
2024-11-18 12:25:12,469 - INFO    | Using default JSON configuration file
2024-11-18 12:25:12,485 - INFO    | Registering as a foreign device to host 10.187.104.102:47808 for 900 seconds
2024-11-18 12:25:12,489 - INFO    | Registered as BACnet/IP App | mode foreign
2024-11-18 12:25:12,493 - INFO    | Device instance (id) : 3056973
2024-11-18 12:25:12,493 - INFO    | BAC0|3056973 connected. Entering context manager.
2024-11-18 12:25:12,494 - INFO    | Installing recurring task Ping Task (id:5047057568)
2024-11-18 12:25:18,503 - WARNING | BAC0.scripts.Lite | Lite | BAC0.core.functions.Alias | Request timed out for what_is_network_number, no response
2024-11-18 12:25:22,505 - INFO    | Found those networks : set()
2024-11-18 12:25:22,505 - INFO    | No BACnet network found, attempting a simple whois using provided device instances limits (0 - 4194303)
2024-11-18 12:25:22,505 - INFO    | Issuing a local broadcast whois request.
2024-11-18 12:25:25,507 - INFO    | Discovery done. Found 0 devices on 0 BACnet networks.
None
2024-11-18 12:25:25,533 - INFO    | Stopping all tasks
2024-11-18 12:25:25,533 - INFO    | Ok all tasks stopped
2024-11-18 12:25:25,542 - INFO    | BACnet stopped
2024-11-18 12:25:25,542 - INFO    | BAC0|3056973 disconnected. Exiting context manager.
Exception in callback IPv4DatagramServer.set_broadcast_transport_protocol(<IPv4Address 10.187.200.223>)(<Task cancell...nit__.py:150>>)
handle: <Handle IPv4DatagramServer.set_broadcast_transport_protocol(<IPv4Address 10.187.200.223>)(<Task cancell...nit__.py:150>>)>
Traceback (most recent call last):
  File "/Users/eloigabal/Developement/CIMNE/Infraestructures/bacnet_ingestor/venv/lib/python3.10/site-packages/bacpypes3/ipv4/__init__.py", line 159, in retrying_create_datagram_endpoint
    return await loop.create_datagram_endpoint(
  File "/usr/local/Cellar/[email protected]/3.10.14_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/base_events.py", line 1385, in create_datagram_endpoint
    raise exceptions[0]
  File "/usr/local/Cellar/[email protected]/3.10.14_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/base_events.py", line 1369, in create_datagram_endpoint
    sock.bind(local_address)
OSError: [Errno 49] Can't assign requested address
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/Users/eloigabal/Developement/CIMNE/Infraestructures/bacnet_ingestor/venv/lib/python3.10/site-packages/bacpypes3/ipv4/__init__.py", line 167, in retrying_create_datagram_endpoint
    await asyncio.sleep(BACPYPES_ENDPOINT_RETRY_INTERVAL)
  File "/usr/local/Cellar/[email protected]/3.10.14_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/tasks.py", line 605, in sleep
    return await future
asyncio.exceptions.CancelledError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/local/Cellar/[email protected]/3.10.14_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "/Users/eloigabal/Developement/CIMNE/Infraestructures/bacnet_ingestor/venv/lib/python3.10/site-packages/bacpypes3/ipv4/__init__.py", line 207, in set_broadcast_transport_protocol
    transport, protocol = task.result()
asyncio.exceptions.CancelledError
BAC0-23.7.3
import BAC0
import time
def bac():
    bacnet_dev = {'deviceIp': '10.10.10.15', 'device_uri': 'https://icat.cat#measurement-INE-08363-ixon-bacnet-10.10.10.15-analogInput-27-PT15M', 'type': 'analogInput', 'objectId': '27'}
    print(BAC0.infos.__version__)
    bacnet = BAC0.lite('10.187.200.223/16', bbmdAddress='10.187.104.102:47808', bbmdTTL=900) 
    bacnet.whois()
    time.sleep(1)
    bacnet.discover()
    time.sleep(1)
    print(bacnet.devices)   
    time.sleep(1) 
    try:
        value = bacnet.read(
            f"{bacnet_dev['deviceIp']} {bacnet_dev['type']} {bacnet_dev['objectId']} presentValue")
        print(value)        
    except Exception as e:
            print("ERROR: CANT READ DEVICE")
    bacnet.disconnect()
bac()
Output
2024-11-18 12:28:18,266 - INFO    | Starting BAC0 version 23.07.03 (Lite)
2024-11-18 12:28:18,266 - INFO    | Use BAC0.log_level to adjust verbosity of the app.
2024-11-18 12:28:18,266 - INFO    | Ex. BAC0.log_level('silence') or BAC0.log_level('error')
2024-11-18 12:28:18,266 - INFO    | Starting TaskManager
2024-11-18 12:28:18,267 - INFO    | Using ip : 10.187.200.223 on port 47808 | broadcast : 10.187.255.255
2024-11-18 12:28:18,286 - INFO    | Starting app...
2024-11-18 12:28:18,286 - INFO    | BAC0 started
2024-11-18 12:28:18,286 - INFO    | Registered as Foreign Device
2024-11-18 12:28:18,286 - INFO    | Device instance (id) : 3056519
2024-11-18 12:28:18,287 - INFO    | Update Local COV Task started (required to support COV)
2024-11-18 12:28:19,607 - INFO    | 10.10.10.15 network number is 1
2024-11-18 12:28:23,438 - INFO    | Found those networks : {1}
2024-11-18 12:28:23,438 - INFO    | Discovering network 1
2024-11-18 12:28:23,439 - INFO    | - discovered addr: ['1:*', '0', '4194303']
[('AS01_76', 'Tri', '10.10.10.80, 421321)]
21.06884002685547
2024-11-18 12:28:25,900 - INFO    | Stopping all tasks
2024-11-18 12:28:25,904 - INFO    | Stopping TaskManager
2024-11-18 12:28:25,911 - INFO    | Ok all tasks stopped
2024-11-18 12:28:25,916 - INFO    | BACnet stopped
an error has occurred: [Errno 9] Bad file descriptor
Traceback (most recent call last):
  File "/Users/eloigabal/Developement/CIMNE/Infraestructures/bacnet_ingestor/venv/lib/python3.10/site-packages/bacpypes/core.py", line 154, in run
    asyncore.loop(timeout=delta, count=1)
  File "/usr/local/Cellar/[email protected]/3.10.14_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncore.py", line 214, in loop
    poll_fun(timeout, map)
  File "/usr/local/Cellar/[email protected]/3.10.14_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncore.py", line 151, in poll
    r, w, e = select.select(r, w, e, timeout)
OSError: [Errno 9] Bad file descriptor

@ChristianTremblay
Copy link
Owner

BACpypes3 is tied more closely to the BACnet standard by default so "weird routes" and devices not reachable via normal BACnet mechanism are harder to reach with default options.

First thing I see (that I missed when looking at the code on the phone) is that your network interface IP address is in the same range than the BBMD.

You should not need to register to a BBMD on the same subnet than you. The BBMD will handle your messages and send them where they should go. Normally.

Can you confirm that the BBMD device 10.187.104.102 talks to the 10.10.10.0/? BBMD device (there should be a BBMD on that subnet).

If so, please try without registering to the BBMD­.

import asyncio
import BAC0

async def bac():
    bacnet_dev = {'deviceIp': '10.10.10.15',  'type': 'analogInput', 'objectId': '27'}
    print(BAC0.infos.__version__) # 2024.9.20
    async with BAC0.start(ip='10.187.176.185/16') as bacnet:
        # there is a routing to the external IP to the internal one
        try:
            value = await bacnet.read(f"{bacnet_dev['deviceIp']} {bacnet_dev['type']} {bacnet_dev['objectId']} presentValue")
        except Exception as e:
            print(f"can't read {attempt}/5: {e}")
asyncio.run(bac())

Let start with this...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants