Script UART communication¶
This example uses Script node for UART communication. Note that OAK cameras don’t have UART pins easily disposed, and we soldered wires on OAK-FFC-4P to expose UART pins.
Note
This should only be run on OAK-FFC-4P, as other OAK cameras might have different GPIO configuration.
Demo¶
Setup¶
Please run the install script to download all required dependencies. Please note that this script must be ran from git context, so you have to download the depthai-python repository first and then run the script
git clone https://github.com/luxonis/depthai-python.git
cd depthai-python/examples
python3 install_requirements.py
For additional information, please follow installation guide
Source code¶
Also available on GitHub
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 36 37 38 39 40 | #!/usr/bin/env python3
'''
NOTE: This should only be run on OAK-FFC-4P, as other OAK cameras might have different GPIO configuration!
'''
import depthai as dai
import time
# Start defining a pipeline
pipeline = dai.Pipeline()
script = pipeline.create(dai.node.Script)
script.setScript("""
import serial
import time
ser = serial.Serial("/dev/ttyS0", baudrate=115200)
i = 0
while True:
i += 1
time.sleep(0.1)
serString = f'TEST_{i}'
ser.write(serString.encode())
""")
# Define script for output
script.setProcessor(dai.ProcessorType.LEON_CSS)
config = dai.Device.Config()
# Get argument first
GPIO = dai.BoardConfig.GPIO
config.board.gpio[15] = GPIO(GPIO.OUTPUT, GPIO.ALT_MODE_2)
config.board.gpio[16] = GPIO(GPIO.INPUT, GPIO.ALT_MODE_2)
config.board.uart[0] = dai.BoardConfig.UART()
with dai.Device(config) as device:
device.startPipeline(pipeline)
print("Pipeline started")
while True:
time.sleep(1)
|
Not yet available