-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[RVC3] Update FW with updated .get() bindings with timeout
- Loading branch information
Matevz Morato
committed
Dec 10, 2024
1 parent
654796b
commit 78bb23c
Showing
2 changed files
with
43 additions
and
1 deletion.
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,42 @@ | ||
#!/usr/bin/env python3 | ||
import depthai as dai | ||
import time | ||
|
||
# Start defining a pipeline | ||
pipeline = dai.Pipeline() | ||
|
||
# Script node | ||
script = pipeline.create(dai.node.Script) | ||
script.setScript(""" | ||
from datetime import timedelta | ||
while True: | ||
node.warn("Waiting for message") | ||
message = node.inputs['test'].get(timedelta(milliseconds=500)) | ||
# message = node.inputs['test'].get() | ||
if message is None: | ||
node.warn("Timeout") | ||
continue | ||
node.warn("Received message") | ||
buf = NNData(150) | ||
node.outputs['host'].send(buf) | ||
""") | ||
|
||
# XLinkOut | ||
xout = pipeline.create(dai.node.XLinkOut) | ||
xout.setStreamName('host') | ||
script.outputs['host'].link(xout.input) | ||
|
||
# XLinkIn | ||
xin = pipeline.create(dai.node.XLinkIn) | ||
xin.setStreamName('test') | ||
xin.out.link(script.inputs['test']) | ||
|
||
# Connect to device with pipeline | ||
with dai.Device(pipeline) as device: | ||
device.setLogLevel(dai.LogLevel.WARN) | ||
device.setLogOutputLevel(dai.LogLevel.WARN) | ||
inp = device.getInputQueue("test") | ||
inp.send(dai.NNData()) | ||
nndata = device.getOutputQueue("host").get() | ||
print("Host received NNData") | ||
time.sleep(30) |