Skip to content

Commit 78bb23c

Browse files
author
Matevz Morato
committed
[RVC3] Update FW with updated .get() bindings with timeout
1 parent 654796b commit 78bb23c

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

depthai-core

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/usr/bin/env python3
2+
import depthai as dai
3+
import time
4+
5+
# Start defining a pipeline
6+
pipeline = dai.Pipeline()
7+
8+
# Script node
9+
script = pipeline.create(dai.node.Script)
10+
script.setScript("""
11+
from datetime import timedelta
12+
while True:
13+
node.warn("Waiting for message")
14+
message = node.inputs['test'].get(timedelta(milliseconds=500))
15+
# message = node.inputs['test'].get()
16+
if message is None:
17+
node.warn("Timeout")
18+
continue
19+
node.warn("Received message")
20+
buf = NNData(150)
21+
node.outputs['host'].send(buf)
22+
""")
23+
24+
# XLinkOut
25+
xout = pipeline.create(dai.node.XLinkOut)
26+
xout.setStreamName('host')
27+
script.outputs['host'].link(xout.input)
28+
29+
# XLinkIn
30+
xin = pipeline.create(dai.node.XLinkIn)
31+
xin.setStreamName('test')
32+
xin.out.link(script.inputs['test'])
33+
34+
# Connect to device with pipeline
35+
with dai.Device(pipeline) as device:
36+
device.setLogLevel(dai.LogLevel.WARN)
37+
device.setLogOutputLevel(dai.LogLevel.WARN)
38+
inp = device.getInputQueue("test")
39+
inp.send(dai.NNData())
40+
nndata = device.getOutputQueue("host").get()
41+
print("Host received NNData")
42+
time.sleep(30)

0 commit comments

Comments
 (0)