2 Star 0 Fork 0

dongbaohua/python-dali

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
hasseb_tests.py 1.45 KB
一键复制 编辑 原始数据 按行查看 历史
dongbaohua 提交于 2024-10-14 16:53 . add hasseb_test.py
#!/usr/bin/env python3
import sys
from dali.driver import hasseb
from dali import bus
from dali import address
import dali.gear.general as gear
# Create hasseb USB DALI driver instance to handle messages
DALI_device = hasseb.SyncHassebDALIUSBDriver()
# Create DALI bus
DALI_bus = bus.Bus('hasseb DALI bus', DALI_device)
# Print help if no arguments
if len(sys.argv) == 1:
print("Give test number as an argument")
print("1: Initialize bus")
print("2: Scan bus")
# Make test if only one argument
elif len(sys.argv) == 2:
# Initialize bus
if sys.argv[1] == '1':
print("Initializing bus...")
DALI_bus.initialize_bus()
print("Address | Random address | Groups | Device type")
for i in range(len(DALI_bus._devices)):
print(f"{DALI_bus._devices[i].address} | {DALI_bus._devices[i].randomAddress} | {DALI_bus._devices[i].groups} | {DALI_bus._devices[i].deviceType}")
# Scan bus
elif sys.argv[1] == '2':
print("Scanning bus...")
DALI_bus.assign_short_addresses()
print("Address | Groups | Device type")
for i in range(len(DALI_bus._devices)):
print(f"{DALI_bus._devices[i].address} | {DALI_bus._devices[i].groups} | {DALI_bus._devices[i].deviceType}")
else:
print(f"Invalid argument {sys.argv[1]}")
# Print error if invalid argument
else:
print("Give only one argument")
# adr = address.Short(0)
# print(DALI_device.send(gear.QueryActualLevel(adr)))
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/dongbaohua/python-dali.git
[email protected]:dongbaohua/python-dali.git
dongbaohua
python-dali
python-dali
master

搜索帮助