Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
0cadb24
WIP: Device configuration
themarpe May 15, 2021
2325f80
Fixed wrong bindings
themarpe May 16, 2021
589c4e3
Merge branch 'develop' into device_config
themarpe May 18, 2021
cf3599b
Updated example to showcase UsbSpeed settings
themarpe May 20, 2021
a219530
Removed bootloader configuration
themarpe May 21, 2021
64d7e87
Merge branch 'develop' into device_config
themarpe May 28, 2021
0d9e38d
Updated rgb_preview example
themarpe May 28, 2021
4e90bc9
Merge branch 'develop' into device_config
themarpe May 31, 2021
3449709
Merge branch 'develop' into device_config
themarpe Jul 21, 2021
1471626
Updated bindings for PrebootConfig
themarpe Jul 22, 2021
f0393ac
Merge branch 'develop' into device_config
themarpe Jul 24, 2021
c195c80
Added missing bindings
themarpe Jul 24, 2021
8ffab27
Updated core
themarpe Jul 27, 2021
acad905
Partially revert f6173f9, add back flash_bootloader.py
alex-luxonis Jul 23, 2021
b0410e9
Update core/bootloader
alex-luxonis Jul 28, 2021
147a2df
Updated flash_bootloader example
themarpe Jul 29, 2021
9420ab7
Updated core
themarpe Jul 29, 2021
1ef8c17
Merge branch 'develop' into scripting_gpio_interrupts
themarpe Jul 30, 2021
ab1b6a6
Added documentation of new Script GPIO API
themarpe Jul 30, 2021
c31e9f8
Updated core
themarpe Jul 30, 2021
3fff9f2
Updated core with SPI speed improvements
themarpe Aug 3, 2021
d5d8c03
Merge branch 'develop' into bootloader_updates
themarpe Aug 4, 2021
5992be8
Updated core and flash_bootloader example typo
themarpe Aug 4, 2021
1f1208a
Merge branch 'develop' into bootloader_updates
themarpe Aug 13, 2021
dbd7e48
Updated flash_bootloader.py example
themarpe Aug 17, 2021
e53ca51
Added bindings for DeviceBootloader Config
themarpe Aug 21, 2021
39871af
Updated flash_bootloader example
themarpe Aug 21, 2021
34d2993
Updated bindings and example name
themarpe Aug 23, 2021
dde13ab
Updated core
themarpe Aug 23, 2021
cb17db2
Updated core
themarpe Aug 23, 2021
7c9d4bb
Merge branch 'bootloader_updates' into develop_embedded
themarpe Aug 24, 2021
0c037d8
Merge branch 'device_config' into develop_embedded
themarpe Aug 24, 2021
ebabd54
Added bindings for bootBootloader
themarpe Aug 24, 2021
b591e25
Updated core
themarpe Aug 25, 2021
f9ec223
Fixed incorrect constructors for DeviceBase
themarpe Aug 26, 2021
98a61ef
Merge branch 'scripting_gpio_interrupts' into develop_embedded
themarpe Aug 26, 2021
da57c1b
Updated core
themarpe Aug 26, 2021
2ace2ca
Updated core
themarpe Sep 2, 2021
cbee9c3
Added capability to not install signal handlers
themarpe Sep 2, 2021
57b0e5b
Updated core
themarpe Sep 6, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ target_link_libraries(${TARGET_NAME}
pybind11::pybind11
depthai::core # Use non-opencv target as we use opencv-python in bindings
hedley
pybind11_json
)

# Find Git
Expand Down
2 changes: 1 addition & 1 deletion depthai-core
Submodule depthai-core updated 43 files
+7 −0 CMakeLists.txt
+4 −2 cmake/Depthai/DepthaiBootloaderConfig.cmake
+1 −1 cmake/Depthai/DepthaiDeviceSideConfig.cmake
+13 −3 cmake/Hunter/config.cmake
+9 −2 cmake/depthaiDependencies.cmake
+5 −2 examples/CMakeLists.txt
+68 −0 examples/src/bootloader_config.cpp
+68 −0 examples/src/flash_bootloader.cpp
+2 −3 examples/src/rgb_preview.cpp
+6 −9 include/depthai/common/CameraBoardSocket.hpp
+8 −11 include/depthai/common/UsbSpeed.hpp
+16 −2 include/depthai/device/Device.hpp
+100 −9 include/depthai/device/DeviceBase.hpp
+233 −16 include/depthai/device/DeviceBootloader.hpp
+3 −0 include/depthai/openvino/OpenVINO.hpp
+34 −10 include/depthai/pipeline/Pipeline.hpp
+9 −8 include/depthai/pipeline/datatype/Tracklets.hpp
+2 −0 include/depthai/pipeline/node/Script.hpp
+1 −1 include/depthai/utility/Initialization.hpp
+1 −5 include/depthai/xlink/XLinkConnection.hpp
+0 −1 include/depthai/xlink/XLinkStream.hpp
+1 −1 shared/depthai-bootloader-shared
+3 −2 shared/depthai-bootloader-shared.cmake
+1 −1 shared/depthai-shared
+3 −2 shared/depthai-shared.cmake
+1 −1 src/device/CallbackHandler.cpp
+1 −1 src/device/DataQueue.cpp
+8 −1 src/device/Device.cpp
+164 −131 src/device/DeviceBase.cpp
+480 −108 src/device/DeviceBootloader.cpp
+3 −0 src/openvino/OpenVINO.cpp
+30 −15 src/pipeline/Pipeline.cpp
+0 −68 src/utility/BootloaderHelper.hpp
+25 −7 src/utility/Initialization.cpp
+52 −0 src/utility/Platform.cpp
+13 −0 src/utility/Platform.hpp
+178 −110 src/utility/Resources.cpp
+5 −4 src/utility/Resources.hpp
+42 −19 src/xlink/XLinkConnection.cpp
+0 −1 src/xlink/XLinkStream.cpp
+4 −1 tests/CMakeLists.txt
+51 −0 tests/src/bootloader_config_test.cpp
+24 −0 tests/src/device_usbspeed_test.cpp
31 changes: 25 additions & 6 deletions docs/source/components/nodes/script.rst
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,34 @@ Usage
Interfacing with GPIOs
######################

In the script node you can interface with GPIOs of the VPU. Currently supported functions are:
In the script node you can interface with GPIOs of the VPU using module GPIO. Currently supported functions are:

.. code-block:: python

import GPIO # module
GPIO.read(pin)
GPIO.write(pin, value)
GPIO.setPwm(pin, highCount, lowCount, repeat=0) # repeat == 0 means indefinite
GPIO.enablePwm(pin, enable)
# Module
import GPIO

# General
GPIO.setup(gpio, dir, pud, exclusive)
GPIO.release(gpio)
GPIO.write(gpio, value)
GPIO.read(gpio)

# Interrupts
GPIO.waitInterruptEvent(gpio = -1) # blocks until any interrupt or interrupt by specified gpio is fired. Interrupts with callbacks are ignored here
GPIO.hasInterruptEvent(gpio = -1) # returns whether interrupt happened on any or specfied gpio. Interrupts with callbacks are ignored here
GPIO.setInterrupt(gpio, edge, priority, callback = None) # adds interrupt to specified pin
GPIO.clearInterrupt(gpio) # clears interrupt of specified pin

# PWM
GPIO.setPwm(gpio, highCount, lowCount, repeat=0) # repeat == 0 means indefinite
GPIO.enablePwm(gpio, enable)

# Enumerations
GPIO.Direction: GPIO.IN, GPIO.OUT
GPIO.State: GPIO.LOW, GPIO.HIGH
GPIO.PullDownUp: GPIO.PULL_NONE, GPIO.PULL_DOWN, GPIO.PULL_UP
GPIO.Edge: GPIO.RISING, GPIO.FALLING, GPIO.LEVEL_HIGH, GPIO.LEVEL_LOW

Using DepthAI :ref:`Messages <components_messages>`
###################################################
Expand Down
53 changes: 53 additions & 0 deletions examples/bootloader_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/usr/bin/env python3

import depthai as dai
import sys

usage = False
read = True
clear = False
path = ''
if len(sys.argv) >= 2:
op = sys.argv[1]
if op == 'read':
read = True
elif op == 'flash':
read = False
if len(sys.argv) >= 3:
path = sys.argv[2]
elif op == 'clear':
clear = True
read = False
else:
usage = True
else:
usage = True

if usage:
print(f'Usage: {sys.argv[0]} [read/flash/clear] [flash: path/to/config/json]')
exit(-1)

(res, info) = dai.DeviceBootloader.getFirstAvailableDevice()

if res:
print(f'Found device with name: {info.desc.name}');
with dai.DeviceBootloader(info) as bl:
if read:
print('Current flashed configuration')
print(f'{bl.readConfigData()}')
else:
success = None
error = None
if clear:
(success, error) = bl.flashConfigClear()
else:
if path == '':
(success, error) = bl.flashConfig(dai.DeviceBootloader.Config())
else:
(success, error) = bl.flashConfigFile(path)
if success:
print('Successfully flashed bootloader configuration')
else:
print(f'Error flashing bootloader configuration: {error}')
else:
print('No devices found')
51 changes: 51 additions & 0 deletions examples/flash_bootloader.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/usr/bin/env python3

import depthai as dai
import sys
import time

blType = dai.DeviceBootloader.Type.AUTO
if len(sys.argv) > 1:
if sys.argv[1] == 'usb':
blType = dai.DeviceBootloader.Type.USB
elif sys.argv[1] == 'network':
blType = dai.DeviceBootloader.Type.NETWORK
else:
print("Specify either 'usb' or 'network' bootloader type")
exit()

print("Warning! Flashing bootloader can potentially soft brick your device and should be done with caution.")
print("Do not unplug your device while the bootloader is flashing.")
print("Type 'y' and press enter to proceed, otherwise exits: ")
if input() != 'y':
print("Prompt declined, exiting...")
exit(-1)

(found, info) = dai.DeviceBootloader.getFirstAvailableDevice()
if not found:
print("No device found to flash. Exiting.")
exit(-1)

# Open DeviceBootloader and allow flashing bootloader
print(f"Booting latest bootloader first, will take a tad longer...")
with dai.DeviceBootloader(info, allowFlashingBootloader=True) as bl:
currentBlType = bl.getType()

# Check if bootloader type is the same
if blType != dai.DeviceBootloader.Type.AUTO and currentBlType != blType:
print(f"Are you sure you want to flash '{blType.name}' bootloader over current '{currentBlType.name}' bootloader?")
print(f"Type 'y' and press enter to proceed, otherwise exits: ")
if input() != 'y':
print("Prompt declined, exiting...")
exit(-1);

# Create a progress callback lambda
progress = lambda p : print(f'Flashing progress: {p*100:.1f}%')

print(f"Flashing {currentBlType.name} bootloader...")
startTime = time.monotonic()
(res, message) = bl.flashBootloader(dai.DeviceBootloader.Memory.FLASH, currentBlType, progress)
if res:
print("Flashing successful. Took", time.monotonic() - startTime, "seconds")
else:
print("Flashing failed:", message)
8 changes: 4 additions & 4 deletions examples/rgb_preview.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
# Linking
camRgb.preview.link(xoutRgb.input)

# Connect to device and start pipeline
with dai.Device(pipeline) as device:

# Connect to the device
with dai.Device(pipeline, dai.UsbSpeed.SUPER) as device:
# Print out available cameras
print('Connected cameras: ', device.getConnectedCameras())
# Print out usb speed
print('Usb speed: ', device.getUsbSpeed().name)
Expand All @@ -31,7 +31,7 @@
qRgb = device.getOutputQueue(name="rgb", maxSize=4, blocking=False)

while True:
inRgb = qRgb.get() # blocking call, will wait until a new data has arrived
inRgb = qRgb.get() # blocking call, will wait until a new data has arrived

# Retrieve 'bgr' (opencv format) frame
cv2.imshow("rgb", inRgb.getCvFrame())
Expand Down
4 changes: 3 additions & 1 deletion external/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# Add 'hedley' library
add_subdirectory(hedley)
add_subdirectory(hedley)
# Add 'pybind11_json' library
add_subdirectory(pybind11_json)
3 changes: 3 additions & 0 deletions external/pybind11_json/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# pybind11_json library
add_library(pybind11_json INTERFACE)
target_include_directories(pybind11_json INTERFACE "${CMAKE_CURRENT_LIST_DIR}/include")
Loading