forked from luxonis/depthai-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript_get_ip.py
More file actions
executable file
·35 lines (29 loc) · 921 Bytes
/
script_get_ip.py
File metadata and controls
executable file
·35 lines (29 loc) · 921 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env python3
import depthai as dai
# MAKE SURE U HAVE LATEST BOOTLOADER KTNXBAI
# Start defining a pipeline
pipeline = dai.Pipeline()
# Script node
script = pipeline.create(dai.node.Script)
script.setProcessor(dai.ProcessorType.LEON_CSS)
script.setScript("""
import socket
import fcntl
import struct
def get_ip_address(ifname):
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
return socket.inet_ntoa(fcntl.ioctl(
s.fileno(),
-1071617759, # SIOCGIFADDR
struct.pack('256s', ifname[:15].encode())
)[20:24])
ip = get_ip_address('re0') # '192.168.0.110'
node.warn(f'IP of the device: {ip}')
node.io['end'].send(Buffer())
""")
xout = pipeline.create(dai.node.XLinkOut)
xout.setStreamName('end')
script.outputs['end'].link(xout.input)
# Connect to device with pipeline
with dai.Device(pipeline) as device:
device.getOutputQueue("end").get() # Wait for the "end" msg