File: info.py

package info (click to toggle)
python-uart-devices 0.1.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 320 kB
  • sloc: python: 107; makefile: 17; sh: 5
file content (30 lines) | stat: -rw-r--r-- 834 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import asyncio
import logging

from uart_devices import BluetoothDevice, NotAUARTDeviceError

logging.basicConfig(level=logging.INFO)
logging.getLogger("usb_devices").setLevel(logging.DEBUG)


async def run() -> None:
    """Run the example."""
    loop = asyncio.get_running_loop()
    for i in range(0, 9):
        dev = BluetoothDevice(i)
        try:
            await loop.run_in_executor(None, dev.setup)
        except NotAUARTDeviceError:
            print(f"hci{i} is not a USB device")
            continue
        except FileNotFoundError:
            print(f"hci{i} not found")
            continue
        assert dev.uart_device is not None  # noqa: S101
        print(
            f"hci{i} manufacturer: {dev.uart_device.manufacturer}, "
            f"product: {dev.uart_device.product} "
        )


asyncio.run(run())