-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests/multithread.py, can replicate a few failures:
- depthai.XLinkWriteError: Couldn't write data to stream: '__bootloader' (X_LINK_ERROR) - RuntimeError: Error trying to connect to device - ...ping was missed, closing the device connection Tested on PoE, 5+ devices connected. Fix will follow in next commit
- Loading branch information
1 parent
152bd06
commit 20f716a
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# TODO: increase defaults in depthai! Below is a workaround for this issue on some setups: | ||
# Failed to find device after booting, error message: X_LINK_DEVICE_NOT_FOUND | ||
# If this error is still observed, might be a FW crash on initialization | ||
if 1: | ||
import os | ||
os.environ["DEPTHAI_WATCHDOG_INITIAL_DELAY"] = "40000" | ||
os.environ["DEPTHAI_BOOTUP_TIMEOUT"] = "40000" | ||
|
||
import depthai as dai | ||
import threading | ||
import traceback | ||
import time | ||
import os | ||
|
||
def worker(devinfo, id): | ||
print(f'[{id}] opening bootloader...') | ||
try: | ||
with dai.DeviceBootloader(devinfo) as bl: | ||
print(f'[{id}] bootloader version: {bl.getVersion()}') | ||
with dai.Device(devinfo) as dev: | ||
print(f'[{id}] device started, name: {dev.getDeviceName()}') | ||
time.sleep(6) | ||
# Exceptions aren't propagated, so simply exit the app with an error | ||
except Exception as e: | ||
print(f'[{id}] FAILED: {e}') | ||
traceback.print_exc() | ||
os._exit(-1) | ||
|
||
device_infos = dai.Device.getAllAvailableDevices() | ||
n = len(device_infos) | ||
if n <= 0: | ||
print('No devices found!') | ||
os._exit(-1) | ||
print(f'Found {n} devices, handling each in a thread...') | ||
threads = [] | ||
for devinfo in device_infos: | ||
id = devinfo.name # IP address for PoE | ||
t = threading.Thread(target=worker, args=(devinfo, id, )) | ||
t.name += f'-{id}' # Thread name useful for debugging | ||
t.start() | ||
threads.append(t) | ||
|
||
for t in threads: | ||
t.join() | ||
|
||
print('Multi-threading test succeeded!') |