Open leaf188 opened 2 weeks ago
You must run
python -m asyncio
This way, an event loop will be available.
Then
import BAC0
bacnet = BAC0.start()
You can also play with a Jupyter Notebook. It will work
I am facing with the same issue on Mac M1, python 3.12.6 (via pyenv)
also tried,
python -m asyncio
asyncio REPL 3.12.6 (main, Sep 6 2024, 19:03:47) [Clang 15.0.0 (clang-1500.3.9.4)] on darwin
Use "await" directly instead of "asyncio.run()".
Type "help", "copyright", "credits" or "license" for more information.
>>> import asyncio
>>> import BAC0
Traceback (most recent call last):
File "/opt/homebrew/Cellar/python@3.12/3.12.6/Frameworks/Python.framework/Versions/3.12/lib/python3.12/concurrent/futures/_base.py", line 456, in result
return self.__get_result()
^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/python@3.12/3.12.6/Frameworks/Python.framework/Versions/3.12/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result
raise self._exception
File "/opt/homebrew/Cellar/python@3.12/3.12.6/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/__main__.py", line 33, in callback
coro = func()
^^^^^^
File "<console>", line 1, in <module>
ModuleNotFoundError: No module named 'BAC0'
>>>
@ChristianTremblay can you please have a look, do I need a Linux or Windows machine?
update, I have switched to python 3.10.15, now
>>> import asyncio
>>> import BAC0
>>> bacnet = BAC0.start()
it says
2024-09-23 17:10:49,560 - INFO | Starting Asynchronous BAC0 version 2024.09.10 (Lite)
2024-09-23 17:10:49,560 - INFO | Using bacpypes3 version 0.0.98
2024-09-23 17:10:49,560 - INFO | Use BAC0.log_level to adjust verbosity of the app.
2024-09-23 17:10:49,560 - INFO | Ex. BAC0.log_level('silence') or BAC0.log_level('error')
Unsupported platform
2024-09-23 17:10:49,607 - INFO | Installing recurring task Ping Task (id:4317581888)
.pyenv/versions/3.10.15/lib/python3.10/ipaddress.py", line 472, in _report_invalid_netmask
raise NetmaskValueError(msg) from None
ipaddress.NetmaskValueError: 'None' is not a valid netmask
the I tried to run the code from PyCharm, that console said
loop = events.get_running_loop()
RuntimeError: no running event loop
sys:1: RuntimeWarning: coroutine 'Task.execute' was never awaited
finally, I found the ip/mask of the macbook then start on them, then it seems BAC0 is now working, but this still happens in PyCharm IDE
loop = events.get_running_loop()
RuntimeError: no running event loop
sys:1: RuntimeWarning: coroutine 'Task.execute' was never awaited
I will try to read and write data via BAC0 into a YABE device then update the result into this ticket.
2024-09-23 17:17:01,292 - INFO | Using default JSON configuration file
2024-09-23 17:17:01,310 - INFO | Registered as BACnet/IP App | mode normal
2024-09-23 17:17:01,312 - INFO | Device instance (id) : 3056656
>>> 2024-09-23 17:17:01,312 - INFO | Installing recurring task Ping Task (id:4331449616)
hi guys, I have succeed read data from a BACnet device (Yabe), confirm BAC0 works fine.
@leaf188 , you have to place BAC0 instance somewhere that you keep it alive, for now, I have to put in into Flask middleware (for workaround).
thank you @ChristianTremblay, this issue can be closed I think. and we can have a more detail example the perfect for developer who is not much familiar with Python.
p/s: the legacy versions 23.07.03 is still good, there is some news in asyncio version need to be learned before using.
The following error message appears when you run BAC0.lite() ` root@vm01:~# python Python 3.12.0 (main, Oct 21 2023, 17:42:12) [GCC 11.4.0] on linux Type "help", "copyright", "credits" or "license" for more information.