examples/a2/multiple_modules.py#
1# Copyright (c) Acconeer AB, 2024-2026
2# All rights reserved
3
4from __future__ import annotations
5
6from acconeer.exptool import a2
7
8
9###############################################################################
10# For auto detection of the connected modules you can use the following code:
11#
12# from acconeer.exptool import get_usb_devices
13#
14# usb_devices = get_usb_devices()
15#
16# if not usb_devices:
17# print("No USB devices available")
18# else:
19# print("USB devices detected:")
20# print("".join([f" - {dev}\n" for dev in usb_devices]))
21#
22# clients = {}
23# for dev in usb_devices:
24# # Only use XE212
25# if dev.name == "XE212":
26# clients[dev.serial] = a2.Client.open(usb_device=dev.serial)
27###############################################################################
28
29# Get the list of connected modules from command line:
30#
31# $ python -m acconeer.exptool.flash list
32# == USB Devices ==
33# - XE212: USB_VID=0xacc0, USB_PID=0xa561 serial=353934643330
34# - XE212: USB_VID=0xacc0, USB_PID=0xa561 serial=384435543231
35
36clients = {}
37clients["353934643330"] = a2.Client.open(usb_device="353934643330")
38clients["384435543231"] = a2.Client.open(usb_device="384435543231")
39
40# Start session for all connected modules
41for client in clients.values():
42 client.setup_session(a2.SessionConfig.default())
43 client.start_session()
44
45# Get data for all connected modules and print the tick value for each:
46for _ in range(5):
47 for serial, client in clients.items():
48 result = client.get_next()
49 print(f"[{serial}] - client tick:", result.tick)
50
51# Stop session and disconnect all modules
52for client in clients.values():
53 client.stop_session()
54 client.close()
55
56# This is what the output will be for two connected modules
57#
58# $ python examples/a2/multiple_modules.py
59#
60# [353934643330] - client tick: 33745
61# [384435543231] - client tick: 23873
62# [353934643330] - client tick: 33757
63# [384435543231] - client tick: 23890
64# [353934643330] - client tick: 33960
65# [384435543231] - client tick: 23907
66# [353934643330] - client tick: 33978
67# [384435543231] - client tick: 23924
68# [353934643330] - client tick: 33994
69# [384435543231] - client tick: 23941
View this example on GitHub: acconeer/acconeer-python-exploration