Skip to content

Commit

Permalink
[RVC3] Update FW with updated .get() bindings with timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
Matevz Morato committed Dec 10, 2024
1 parent 654796b commit 78bb23c
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
2 changes: 1 addition & 1 deletion depthai-core
42 changes: 42 additions & 0 deletions examples/Script/rvc3_timeout_example.py
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)

0 comments on commit 78bb23c

Please sign in to comment.